[R] Odp: multiphasic growth curve analysis
Although I am not an expert in NLME modelling, looking at your data it seems to me that there seems to be no growth pattern in it. Try library(nlme) library(reshape) goat-read.table(clipboard, header=T) str(goat) 'data.frame': 18 obs. of 15 variables: $ NoC : int 52 48 54 60 58 42 44 47 50 56 ... $ PL1 : int 490 970 1450 620 1370 1200 1200 1000 1300 950 ... $ PL2 : int 950 1020 1420 1250 1350 920 1560 1100 1150 1250 ... $ PL3 : int 800 980 1430 1100 1200 1150 1650 1000 1200 1200 ... $ PL4 : int 900 740 1120 1150 1300 850 1600 870 1030 1280 ... goat.m - melt(goat, id=NoC) levels(goat.m$variable) - 1:14 goat.m$variable - as.numeric(as.character(goat.m$variable)) names(goat.m)[2] - week goat.m$NoC - ordered(goat.m$NoC) goat.g - groupedData(value~week|NoC, data=goat.m) plot(goat.g) But maybe I am completely mistaken. Regards Petr [EMAIL PROTECTED] napsal dne 04.09.2007 18:02:09: Greetings R Help Group, How does one effect a multiphasic logistic growth model with 4 phases (e.g. Koops 1986; Weigel, Craig, Bidwell and Bates 1992; Grossman and Koops 2003) with R. Before writing to the group, the R help archives were searched, the web was searched with Google, Venables and Ripley 2002 was consulted, Pinheiro and Bates 2000 was consulted, Bates and Watts 2007 was bought and consulted, ETC. but to no avail. I have not written to any other group with respect to this problem. The following data are offered as an example of the type of problem I am dealing with and are average daily goat milk production in ml. for 14 weeks. NoC is the goat number. PL1 is the production during the first week; PL2 is the production during the second week, etc. NoC PL1 PL2 PL3 PL4 PL5 PL6 PL7 PL8 PL9 PL10 PL11 PL12 PL13 PL14 52 490 950 800 900 850 850 750 610 640 900 980 890 890 910 48 970 1020 980 740 1050 970 850 790 900 920 1120 1120 1030 1300 54 1450 1420 1430 1120 1330 1230 1030 1170 1350 1530 1490 1500 1310 910 60 620 1250 1100 1150 780 930 990 940 760 730 790 1050 840 850 58 1370 1350 1200 1300 1350 1310 1070 910 1010 1300 1110 1070 990 660 42 1200 920 1150 850 720 630 630 710 850 810 930 980 820 1570 44 1200 1560 1650 1600 1450 1600 1160 1010 1440 1450 1530 1500 1550 850 47 1000 1100 1000 870 760 900 820 865 910 820 930 900 1130 1070 50 1300 1150 1200 1030 1070 970 860 900 950 1190 1250 1130 800 1400 56 950 1250 1200 1280 1220 1155 840 1016 1370 1220 1570 1520 1500 1150 1 870 1250 1160 1270 1200 1410 1110 1008 970 1130 1490 1330 1320 820 3 1000 1100 1200 1120 1250 980 750 890 1050 1160 1340 1210 1150 760 4 551 760 550 580 540 620 550 520 470 720 680 790 750 1230 5 810 1100 820 950 930 830 850 650 810 1070 1120 1300 1040 1320 6 800 1000 620 850 750 670 660 620 600 610 760 900 758 1070 7 720 830 1120 1050 820 820 850 810 800 750 780 940 1050 1310 8 950 1550 1560 1500 1230 1330 1150 1005 1020 1200 1440 1400 1290 1080 10 660 850 1100 980 1070 1100 870 790 880 950 1000 1210 1050 1220 It seems to me that it should be possible to effect the modeling process with nlme. Any suggestions and or recommendations would be greatly appreciated. Peter B. Douglas M. Bates and Donald G. Watts. 2007. Nonlinear Regression Analysis and Its Applications. Wiley Series in Probability and Statistics. John Wiley Sons, Inc., New York, NY, USA. M. Grossman and W.J. Koops. 2003. Modeling Extended Lactation Curves of Dairy Cattle: A Biological Basis for the Multiphasic Approach. J. Dairy Sci. 86:988-998. W. J. Koops. 1986. Multiphasic Growth Curve Analysis. Growth 50:169-177. Jose C. Pinheiro and Douglas M. Bates 2000. Mixed-Effects Models in S and S- Plus. Statistics and Computing. Springer-Verlag New York, New York, NY, USA. W. H. Venables and B. D. Ripley. 2002. Modern Applied Statistics with S. Fourth edition. Statistics and Computing. Springer-Verlag New York, Inc., New York, NY, USA. K. A. Weigel, B. A. Craig, T. R. Bidwell and D. M. Bates. 1992. Comparison of Alternative Diphasic Lactation Curve Models under Bovine Somatotropin Administration. J. Dairy Sci. 75:580-589. Peter B. Mandeville cel: 444 860 3204 tel: 52 444 826 2346-49 ext 532 fax: 52 444 826 2352 P.D. Favor de confirmar la llegada de este correo. Gracias. _ Discover the new Windows Vista [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch
Re: [R] by group problem
Hi now I understand better what you want topN.2 - function(data,n=5) data[order(data[,3], decreasing=T),][1:n] # I presume data is data frame with 3 columns and the third is percent lapply(split(data,data$state), topN.2) Regards Petr [EMAIL PROTECTED] Cory Nissen [EMAIL PROTECTED] napsal dne 31.08.2007 17:21:01: That didn't work for me... Here's some data to help with a solution. data - NULL data$state - c(rep(Illinois, 10), rep(Wisconsin, 10)) data$county - c(Adams, Brown, Bureau, Cass, Champaign, Christian, Coles, De Witt, Douglas, Edgar, Adams, Ashland, Barron, Bayfield, Buffalo, Burnett, Chippewa, Clark, Columbia, Crawford) data$percentOld - c(17.554849, 16.826594, 18.196593, 17.139242, 8.743823, 17.862746, 13.747967, 16.626302, 15.258940, 18.984435, 19.347022, 17.814436, 16.903067, 17.632781, 16.659305, 20.337817, 14.293354, 17.252820, 15.647179, 16.825596) return something like this... $Illinois Edgar 18.984435 Bureau 18.196593 ... $Wisconsin Burnett 20.33782 Adams 19.34702 ... My Solution gives... topN - function(column, n=5) { column - sort(column, decreasing=T) return(column[1:n]) } tapply(data$percentOld, data$state, topN) $Illinois [1] 18.98444 18.19659 17.86275 17.55485 17.13924 $Wisconsin [1] 20.33782 19.34702 17.81444 17.63278 17.25282 I get an error with this try... aggregate(data$percentOld, list(data$state, data$county), topN) Error in aggregate.data.frame(as.data.frame(x), ...) : 'FUN' must always return a scalar Thanks cn From: Petr PIKAL [mailto:[EMAIL PROTECTED] Sent: Fri 8/31/2007 8:15 AM To: Cory Nissen Cc: r-help@stat.math.ethz.ch Subject: Odp: [R] by group problem Hi I am working with census data. My columns of interest are... PercentOld - the percentage of people in each county that are over 65 County - the county in each state State - the state in the US There are about 3100 rows, with each row corresponding to a county within a state. I want to return the top five PercentOld by state. But I want the County and the Value. I tried this... topN - function(column, n=5) { column - sort(column, decreasing=T) return(column[1:n]) } top5PerState - tapply(data$percentOld, data$STATE, topN) Try aggregate(data$PercentOld, list(data$State, data$County), topN) Regards Petr But this only returns the value for percentOld per state, I also want the corresponding County. I think I'm close, but I just can't get it... Thanks cn [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: element wise opertation between a vector and a list
Hi mapply(+, a, b) Regards Petr [EMAIL PROTECTED] napsal dne 03.09.2007 08:36:10: I want to try to get a result of element wise addition between a vector and a list. It can be done with for statement. In order to reducing computing time, I have tried to avoid for state. If anybody give me an idea, I would apprecite it much. for example, with a b as below lines, a- list(c(1,3),c(1,2),c(2,3)) b-c(10,20,30) I would like to have a list (like d) or a vector (like e) as below. d-list(c((1+10),(3+10)),c((1+20),(2+20)),c((2+30),(3+30))) e- c((1+10)+(3+10),(1+20)+(2+20),(2+30)+(3+30)) Thanks, Yongwan Chun __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplot will remember the factor levels
Try: boxplot(mLength ~ puntar[drop=T],data=test) -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 30/08/2007, Luis Ridao Cruz [EMAIL PROTECTED] wrote: R-help, I'm trying to do a simple box-and-whisker plot to some data. The data are a subset of a large data frame but when running the boxplot function on the subset data all the factors are still present in the graph leaving a huge empty space until the actuals factors are shown. This produces a spurious box-and-whisker plot. If the subset data are exported to another R session the problem is gone. Why are the factors still remembered by the boxplot? Actually puntar remembers all levels, not boxplot. Look at ?factor and drop parameter as Henrique pointed. Regards Petr Attached is a copy of the data. Thanks in advance ## the line code boxplot(mLength ~ puntar,data=test) version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 5.1 year 2007 month 06 day27 svn rev42083 language R version.string R version 2.5.1 (2007-06-27) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: by group problem
Hi I am working with census data. My columns of interest are... PercentOld - the percentage of people in each county that are over 65 County - the county in each state State - the state in the US There are about 3100 rows, with each row corresponding to a county within a state. I want to return the top five PercentOld by state. But I want the County and the Value. I tried this... topN - function(column, n=5) { column - sort(column, decreasing=T) return(column[1:n]) } top5PerState - tapply(data$percentOld, data$STATE, topN) Try aggregate(data$PercentOld, list(data$State, data$County), topN) Regards Petr But this only returns the value for percentOld per state, I also want the corresponding County. I think I'm close, but I just can't get it... Thanks cn [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R Help
[EMAIL PROTECTED] napsal dne 28.08.2007 13:33:13: You don't have installed the akima pakage. install.packages(akima, dep=T) And wait about two months and update your R version to 2.6.0. Or update now to 2.5.1 Regards Petr -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O On 28/08/07, Ola Asteman [EMAIL PROTECTED] wrote: I got the Warning message below when I tried to load Locfit. What is wrong? Regards Ola Asteman -- R version 2.4.0 (2006-10-03) Copyright (C) 2006 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. library(foreign) library(mgcv) This is mgcv 1.3-19 library(locfit) Loading required package: akima Error: package 'akima' could not be loaded In addition: Warning message: there is no package called 'akima' in: library(pkg, character.only = TRUE, logical = TRUE, lib.loc = lib.loc) -- This e-mail and any attachment may be confidential and m...{{dropped}} __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: displaying the means on a scatter diagram
Hi [EMAIL PROTECTED] napsal dne 22.08.2007 09:10:26: Hello, I created a simple scatter diagram: x= c(53, 52, 55, 65, 71, 69, 75, 78, 88, 70) y= c(162, 165, 165, 171, 173, 175, 179, 181, 184, 176) plot(x, y) Now I would like to display the mean on that diagram. do you think points(mean(x), mean(y)) or e.g. abline(h=mean(y)) abline(v=mean(x)) Regards Petr Can anyone tell me what possibilities I have to do that? Thanks in advance Tobias -- View this message in context: http://www.nabble.com/displaying-the-means-on-a- scatter-diagram-tf4309832.html#a12269270 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Variable c and function c
Hi [EMAIL PROTECTED] napsal dne 21.08.2007 17:07:05: I have found the error in my script which was semi-automatically translated from the other person's MATLAB code. The error is that c was assigned a value inside a function. That is the function body contained the following instructions c-nw*czr d-nw*cz rFren-0.5*(abs((cz-c)/(cz+c))^2+abs((d-czr)/(d+czr))^2) My guess is that rFren is computed with c defined above and firstguess-c( 0,0,0,3,0.5, 0 , 0 , 0.01) firstguess is assigned above numbers See fff-function(nw=10, czr=5, cz=3) { c-nw*czr d-nw*cz rFren-0.5*(abs((cz-c)/(cz+c))^2+abs((d-czr)/(d+czr))^2) firstguess-c( 0,0,0,3,0.5, 0 , 0 , 0.01) list(rFren, firstguess) } fff() [[1]] [1] 0.6483025 [[2]] [1] 0e+00 0e+00 0e+00 3e+00 5e-01 0e+00 0e+00 1e-06 fff(1) [[1]] [1] 0.0625 [[2]] [1] 0e+00 0e+00 0e+00 3e+00 5e-01 0e+00 0e+00 1e-06 Regards Petr I have already run this function and obtained the results, it was rather long process, therefore I don't want to rerun it. I was not given any warnings. How did the interpreter treat this? Will the result change, if I change the variable from c to, say, c. ? This variable is not used anywhere else in the function. -- View this message in context: http://www.nabble.com/Variable-c-and-function-c- tf4305781.html#a12256590 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: beta distrib function was(no subject)
Hi you do not give much information, even subject line is missing. Try to follow posting guide and try to explain what you did and how did you fail. Regards Petr [EMAIL PROTECTED] napsal dne 16.08.2007 17:24:24: hi, i'm new to R and i'm trying to port a quattro pro spreadsheet into R. spreadsheets have optional lower and upper limit parameters on the beta distribution function. i would like to know how to incorporate this with R's pbeta function. thanks in advance, mara. Park yourself in front of a world of choices in alternative vehicles. Visit [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] time series periodic data
Thank you. I will try to get the book, althoug I am not sure if I with my tiny knowledge of mathematics will be able to digest it. Meanwhile I tried to make 7 min average and then to reanalyze by spectrum, but the output was not very convincing. Regards Petr Pikal [EMAIL PROTECTED] Rolf Turner [EMAIL PROTECTED] napsal dne 15.08.2007 22:12:15: On 16/08/2007, at 12:26 AM, Petr PIKAL wrote: Dear all Please help me with analysis of some periodic data. I have an output from measurement each minute and this output is modulated by rotation of the equipment (approx 6.5 min/revolution). I can easily spot this frequency from spectrum(mydata, some suitable span) However from other analysis I suspect there is a longer term oscilation (about 70-80 min) I am not able to find it from mentioned data. Plese give me some hint how I could prove that such long term modulation of my data exist in presence of quite strong modulation by this short term oscilations. You may be able to get some mileage out of complex demodulation (at, say, frequencies of 1/70, 1/71, ..., 1/80 cycles per minute). See Peter Bloomfield's book (``Fourier Analysis of Time Series: An Introduction'', 2nd ed., Wiley, 2000) for a good introduction to complex demodulation. cheers, Rolf Turner ## Attention: This e-mail message is privileged and confidential. If you are not the intended recipient please delete the message and notify the sender. Any views or opinions presented are solely those of the author. This e-mail has been scanned and cleared by MailMarshal www.marshalsoftware.com ## __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: combine 2 data frames with missing values
Hi for this particular task rowSums(cbind(a,b), na.rm=T) gives you c column Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 16.08.2007 13:03:51: Hi All, I have 2 data frames as follows: abc 1 NA 1 2 NA 2 NA 3 3 So a, b are the input values and c is the output which I am interested in. NA - Missing values. I used rbind, but its not working. Let me know if anyone can help me Thanks, Pratap - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] time series periodic data
Dear all Please help me with analysis of some periodic data. I have an output from measurement each minute and this output is modulated by rotation of the equipment (approx 6.5 min/revolution). I can easily spot this frequency from spectrum(mydata, some suitable span) However from other analysis I suspect there is a longer term oscilation (about 70-80 min) I am not able to find it from mentioned data. Plese give me some hint how I could prove that such long term modulation of my data exist in presence of quite strong modulation by this short term oscilations. Thank you Best regards Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Linear Regression with slope equals 0
Hi Not being a trained statistician regression with slope = 0 seems odd to me. If you do fit-lm(d~t) summary(fit) Call: lm(formula = d ~ t) Residuals: 123456 0.04762 -1.43810 0.07619 1.59048 2.10476 -2.38095 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 302.4667 1.7849 169.45 7.28e-09 *** t 0.4857 0.45831.060.349 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.917 on 4 degrees of freedom Multiple R-Squared: 0.2192, Adjusted R-squared: 0.02402 F-statistic: 1.123 on 1 and 4 DF, p-value: 0.349 you will get estimate of your coeficients and AFAIK they are tested against Ho that they differ from 0. So as you see your t is not statistically different from 0. Regards Petr [EMAIL PROTECTED] napsal dne 14.08.2007 13:36:37: Hi there, am trying to run a linear regression with a slope of 0. I have a dataset as follows t d 1 303 2 302 3 304 4 306 5 307 6 303 I would like to test the significance that these points would lie on a horizontal straight line. The standard regression lm(d~t) doesn't seem to allow the slope to be set. Any help very welcome. ed __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Problem with by: does not work with ttest (but with lme)
Hi [EMAIL PROTECTED] napsal dne 14.08.2007 15:11:11: Hello, I would like to do a large number of e.g. 1000 paired ttest using the by- function. But instead of using only the data within the 1000 groups, R caclulates 1000 times the ttest for the full data set(The same happens with Wilcoxon test). However, the by-function works fine with the lme function. Did I just miss something or is it really not working? If not, is there any other possibility to avoid loops? Thanks Daniel Here is the R help example for by require(stats) attach(warpbreaks) by(warpbreaks, tension, function(x) lm(breaks ~ wool, data = x)) *-works great by(warpbreaks,tension,function(x)t.test(breaks ~ wool,data=warpbreaks,paired = TRUE)) What about by(warpbreaks,tension,function(x)t.test(breaks ~ wool,data=x,paired = TRUE)) Regards Petr *Same output for each level of tension: tension: L Paired t-test data: breaks by wool t = 1.9956, df = 26, p-value = 0.05656 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -0.1735803 11.7291358 sample estimates: mean of the differences 5.78 tension: M Paired t-test data: breaks by wool t = 1.9956, df = 26, p-value = 0.05656 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -0.1735803 11.7291358 sample estimates: mean of the differences 5.78 tension: H Paired t-test data: breaks by wool t = 1.9956, df = 26, p-value = 0.05656 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -0.1735803 11.7291358 sample estimates: mean of the differences 5.78 -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Very new - beginners questions
Hi [EMAIL PROTECTED] napsal dne 13.08.2007 14:04:50: Dear all, I have 4 sites and want to determine how different they are from each other. For this I have decided to use R though it seems a bit daunting to learn. I have read data in from a CSV the structure is : Species1 Species2 Species3 Site1 4 4 7 Site2 3 1 0 Site3 0 99 6 Site4 75 3 33 There are many more species than shown above this is just an example. Here are the questions. How do I read one row of data so as to load site2 into a variable called site2? ?read.table and other read. commands. Do not work with variables but with data frames. Once I plot a graph using ordiplot how do I extract it from R so that I can put it into a Word for Windows document? 1. save a graph from menu 2. use ?png, ?jpeg and others to see how to output graph to files (devices) Once I have the data in varables I hope to use designdist and Sřrensen to discover diversity indices. I had a crack at this once but because I had sites as the columns it didn't work. Now that I think I have the data correct I can proceed. x Input data (this will be the whole data set that I read into my variable 'allSites' from a CSV.)? The variables for Sřrensen will contain terms J for shared quantity, A and B for totals, N for the number of rows (sites) and P for the number of columns (species) and 'Binary' as the term. How do I get the shared number of species for each row? Probably very beginner type questions but I want to get on an haven't yet found the answers in my trawl throgh the help. Is there a book that I can buy to learn R? look at CRAN. You can find various books from beginners to quite advanced. e.g. P.Dalgaard Introductory statistics with R isd quite good for first steps. Or you can consult Rtips from Paul Johnson. (Just type statsrus into Google). Good idea is also to look into posting guide. Regards Petr All the best, Richard Price MSc student University Birmingham. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: having problems with factor()
Hi [EMAIL PROTECTED] napsal dne 10.08.2007 13:41:53: Dear R Help, I have a set of data of heights of trees described by area that they are in. The areas are numerical (0 to 7). htarea 1 320 3 2 410 4 3 230 2 4 360 3 5 126 1 6 280 2 7 260 2 8 280 2 9 280 2 10 260 2 ... 180 450 4 181 90 1 182 120 1 183 440 4 184 210 2 185 330 3 186 210 2 187 100 1 188 0 0 I want to convert the area column values to factors, to do an anova. However, if I use: df$areaf - factor(df$area, labels=c(0,I,II,III,IV,V,VI,VII)) it gives the following message: Hm, maybe some of the values are missing num-sample(1:3, 10, replace=T) num [1] 1 3 1 2 3 3 1 3 3 3 factor(num, labels=c(O, I, II)) [1] O II O I II II O II II II Levels: O I II factor(num, labels=c(O, I, II, III)) Error in factor(num, labels = c(O, I, II, III)) : invalid labels; length 4 should be 1 or 3 try table(df$area) to see what level you really have Regards Petr Error in factor(df$area, labels = c(0, I, II, III, IV, V, VI, : invalid labels; length 8 should be 1 or 7 Can anyone help? Jabez ___ now. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: help with counting how many times each value occur in each column
Hi mat-sample(c(-50,0,-100), 100,replace=T) dim(mat)-c(10,10) mat [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]0000 -500000 0 [2,] -100 -100 -50 -5000 -100 -50 -100 -50 [3,]0 -50 -100 -1000 -50 -10000 -100 [4,]0 -1000 -50 -100 -100 -50 -500 -100 [5,] -50 -50000 -100 -100 -1000 -100 [6,]00 -50 -5000 -100 -100 -50 -100 [7,] -100 -100 -100 -50 -1000 -100 -1000 -100 [8,] -1000000 -1000 -1000 -100 [9,] -1000 -50 -100 -5000 -500 -100 [10,] -50 -10000 -50 -50 -50 -50 -100 -100 apply(mat, 2, table) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] -100442223542 8 -50 223432241 1 0 445455327 1 Transposing and ordering columns is up to you. Regards Petr [EMAIL PROTECTED] napsal dne 10.08.2007 14:01:44: Dear list, I have the following dataset and want to know how many times each value occur in each column. data [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] -100 -100 -100000000 -100 [2,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [3,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [4,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [5,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -50 [6,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [7,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [8,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [9,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [10,] -100 -100 -100 -50 -100 -100 -100 -100 -100 -100 [11,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [12,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [13,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [14,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [15,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [16,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [17,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [18,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 [19,] -100 -100 -100000000 -100 [20,] -100 -100 -100 -100 -100 -100 -100 -100 -100 -100 The result matrix should look like -100 0 -50 [1] 20 [2] 20 [3] 20 [4] 17 [5] 18 [6] 18 [7] 18 and so on [8] [9] [10] How can I do this in R ? Thanks alot for your help, Tom - Jämför pris pĺ flygbiljetter och hotellrum: http://shopping.yahoo.se/c-169901- resor-biljetter.html [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Successively eliminating most frequent elemets
Hi your construction is quite complicated so instead of refining it I tried to do such task different way. If I understand what you want to do you can use set.seed(1) T - matrix(trunc(runif(20)*10), nrow=10, ncol=2) T [,1] [,2] [1,]22 [2,]31 [3,]56 [4,]93 [5,]27 [6,]84 [7,]97 [8,]69 [9,]63 [10,]07 m-table(T) # matrix is vector with dimensions todel-rowSums(T==as.numeric(names(which.max(m0 # check which element of matrix is the first frequent T[todel,] [,1] [,2] [1,]22 [2,]27 T[!todel,] [,1] [,2] [1,]31 [2,]56 [3,]93 [4,]84 [5,]97 [6,]69 [7,]63 [8,]07 You can put all of these to cycle but you have to decide when to end the cycle. Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 08.08.2007 15:33:58: Dear experts, I have a 10x2 matrix T containing random integers. I would like to delete pairs (rows) iteratively, which contain the most frequent element either in the first or second column: T - matrix(trunc(runif(20)*10), nrow=10, ncol=2) G - matrix(0, nrow=6, ncol=2) for (i in (1:6)){ print(** Start iteration ~i~ ***) print(Current matrix:) print(T) m - append(T[,1], T[,2]) print(Concatenated columns:) print(m) # build frequency table F - data.matrix(as.data.frame(table(m))) dimnames(F)-NULL # pick up the most frequent element: sort decreasing and take is from the top F - F[order(F[,2], decreasing=TRUE),] print(Freq. table:) print(F[1:5,]) todel - F[1,1] #rows containing the most frequent element will be deleted G[i,1] - todel G[i,2] - F[1,2] print(todel=~todel) # eliminate rows containing the most frequent element # either the first or the second column contains this element id - which(T[,1]==todel) print(Indexes of rows to be deleted:) print(id) if (length(id)0){ T - T[-1*id, ] } id - which(T[,2]==todel) print(Indexes of rows to be deleted:) print(id) if (length(id)0){ T - T[-1*id, ] } print(nrow(T)=~nrow(T)) } print(Result matrix:) print(G) The output of the first two iterations looks like as follows. As one can see, the frequency table in the second iteration still contains the element deleted in the first iteration! Is this a bug or what am I doing here wrong? Any help greatly appreciated! [1] ** Start iteration 1 *** [1] Current matrix: [,1] [,2] [1,]22 [2,]67 [3,]99 [4,]35 [5,]40 [6,]79 [7,]57 [8,]17 [9,]96 [10,]33 [1] Concatenated columns: [1] 2 6 9 3 4 7 5 1 9 3 2 7 9 5 0 9 7 7 6 3 [1] Freq. table: [,1] [,2] [1,]84 [2,]94 [3,]43 [4,]32 [5,]62 [1] todel=8 [1] Indexes of rows to be deleted: integer(0) [1] Indexes of rows to be deleted: integer(0) [1] nrow(T)=10 [1] ** Start iteration 2 *** [1] Current matrix: [,1] [,2] [1,]22 [2,]67 [3,]99 [4,]35 [5,]40 [6,]79 [7,]57 [8,]17 [9,]96 [10,]33 [1] Concatenated columns: [1] 2 6 9 3 4 7 5 1 9 3 2 7 9 5 0 9 7 7 6 3 [1] Freq. table: [,1] [,2] [1,]84 [2,]94 [3,]43 [4,]32 [5,]62 [1] todel=8 [1] Indexes of rows to be deleted: integer(0) [1] Indexes of rows to be deleted: integer(0) [1] nrow(T)=10 [1] ** Start iteration 3 *** [1] Current matrix: ... __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Error in as.double.default(x) : (list) object cannot be coerced to 'double'
Hi Far from beeing an expert I can decide from your post that you probably mix R objects matrix x data frame x list. All of them have specific features and you sometimes cannot convert one to another easily. See what your objects are and how they look like by e.g. str(X1) or mode or typeof I suspect that your X are lists and using c(some lists) result again into list. Plot expect x and y values usually as vectors but there are plot methods for other objects (data.frames, functions, ...) Best starting point would be help page for plot. Regards Petr [EMAIL PROTECTED] napsal dne 07.08.2007 15:33:41: Dear experts, I have in all 14 matrices which stands for gene expression divergence and 14 matrices which stands for gene sequence divergence. I have tried joining them by using the concatanation function giving SequenceDivergence - c(X1,X2,X3,X4,X5,X6,X7,X8,X9,X10,X11,X12,X13,X14) ExpressionDivergence - c(Y1,Y2,Y3,Y4,Y5,Y6,Y7,Y8,Y9,Y10,Y11,Y12,Y13,Y14) where X1,X2..X14 are the expression matrices containing r-values and Y1,Y2..Y14 are the ones with patristic distances Now, I want to plot SequenceDivergence vs. Expression Divergence Tried doing that using plot (Sequence Divergence vs. Expression Divergence) But then getting the error Error in as.double.default(x) : (list) object cannot be coerced to 'double' Note: The diagonal values for X1 was neglected as its seems to give some bias in my results. Code to derive X1,X2,X3..and Y1,Y2,Y3 is given as: EDant - read.table(C:/ant.txt,sep=\t) ED1 - as.matrix(EDant) X1 - lapply(1:ncol(ED15), function(a) ED15[-a, a]) # to neglect diagonal values I am attaching couple of matrices for your reference. ANT.txt is X1 after deleting the diagnol values, similarly,ANTEXP.TXT is Y1, apetella.txt is X2 and apetellaexp.txt is Y2 I tried reading R-manual and other sources but have'nt cracked it yet. Can anyone please help me regarding that? Thanks very much Yours sincerely, Urmi Trivedi. - Once upon a time there was 1 GB storage in your inbox. Click here for happy ending.0 1.21133 1.420221 1.499358 1.475149 1.513886 1.608816 1. 675916 1.859038 1.992958 2.420123 2.309414 2.413222 1.21133 0 1.463585 1.542722 1.518513 1.55725 1.65218 1.71928 1.902402 2.036322 2.463487 2.352778 2.456586 1.420221 1.463585 0 1.418619 1.39441 1.433147 1.528077 1.595177 1.778299 1.912219 2.339384 2.228675 2.332483 1.499358 1.542722 1.418619 0 0.931235 0.969972 1.354498 1.421598 1.60472 1.73864 2.165805 2.055096 2.158904 1.475149 1.518513 1.39441 0.931235 0 0.206013 1.330289 1.397389 1.580511 1.714431 2.141596 2.030887 2.134695 1.513886 1.55725 1.433147 0.969972 0.206013 0 1.369026 1.436126 1.619248 1.753168 2.180333 2.069624 2.173432 1.608816 1.65218 1.528077 1.354498 1.330289 1.369026 0 0.604972 1.537696 1.671616 2.098781 1.988072 2.09188 1.675916 1.71928 1.595177 1.421598 1.397389 1.436126 0.604972 0 1.604796 1.738716 2.165881 2.055172 2.15898 1.859038 1.902402 1.778299 1.60472 1.580511 1.619248 1.537696 1. 604796 0 1.09121 1.968427 1.857718 1.961526 1.992958 2.036322 1.912219 1.73864 1.714431 1.753168 1.671616 1. 738716 1.09121 0 2.102347 1.991638 2.095446 2.420123 2.463487 2.339384 2.165805 2.141596 2.180333 2.098781 2.165881 1.968427 2.102347 0 1.128701 1.232509 2.309414 2.352778 2.228675 2.055096 2.030887 2.069624 1.988072 2.055172 1.857718 1.991638 1.128701 0 0.91546 2.413222 2.456586 2.332483 2.158904 2.134695 2.173432 2.09188 2. 15898 1.961526 2.095446 1.232509 0.91546 0 1 -0.046373 -0.033044 0.003902 0.466827 0.389327 0.131989 -0. 063346 -0.118093 0.016386 -0.140215 0.34511 0.233074 -0.046373 1 0.000717 0.832227 0.077053 -0.106815 -0.050838 0. 936431 0.297387 0.031358 -0.127265 0.31245 -0.053169 -0.033044 0.000717 1 0.011265 -0.018602 -0.023669 -0.028744 -0. 007588 0.148827 -0.007067 0.005362 -0.029172 -0.017367 0.003902 0.832227 0.011265 1 0.071247 -0.101225 0.097117 0. 829167 0.294396 0.017809 -0.129199 0.278831 -0.106427 0.466827 0.077053 -0.018602 0.071247 1 0.078241 0.140679 0. 070069 0.055744 0.013194 -0.196092 -0.027692 0.028857 0.389327 -0.106815 -0.023669 -0.101225 0.078241 1 0.140146 -0. 086806 0.079 0.194904 0.068378 0.213288 0.194006 0.131989 -0.050838 -0.028744 0.097117 0.140679 0.140146 1 -0. 075079 0.137652 0.065127 -0.072768 -0.120751 -0.101777 -0.063346 0.936431 -0.007588 0.829167 0.070069 -0.086806 -0.075079 1 0.312154 0.023108 -0.122502
Re: [R] Problems using lm in combination with predict
Hi [EMAIL PROTECTED] napsal dne 04.08.2007 15:04:56: Hi, I am sorry I meant: mod - lm(y~Worktime+Vacation+Illnes+Bankholidays) newdate=data.frame(x=c(324,123,0.9,0.1)) your data frame shall have correct column names (Worktime, Vacation, ...) Regards Petr predict(mod,newdate) And get this error. Yours, Maja Original-Nachricht Datum: Sat, 4 Aug 2007 04:42:14 -0700 (PDT) Von: Stephen Tucker [EMAIL PROTECTED] An: Maja \\Schröter\\ [EMAIL PROTECTED], r-help@stat.math.ethz.ch Betreff: Re: [R] Problems using lm in combination with predict I think you need predict(mod,newdate) instead of predict(y,newdate) --- Maja Schröter [EMAIL PROTECTED] wrote: Hello everybody, I'm trying to predict a linear regression model but it does not work. My Model: y = Worktime + Vacation + Illnes + Bankholidays My modelmatrix is of dimension 28x4 Then I want to make use of the function predict because there confidence.intervals are include. My idea was: mod - lm(y~Worktime+Vacation+Illnes+Bankholidays) newdate=data.frame(x=c(324,123,0.9,0.1)) predict(y,newdate) But I always get the message: 'newdata' had 1 rows but variable(s) found have 28 rows What can I do? Yours, Maja -- Pt! Schon vom neuen GMX MultiMessenger gehört? Der kanns mit allen: http://www.gmx.net/de/go/multimessenger __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase. http://farechase.yahoo.com/ -- Pt! Schon vom neuen GMX MultiMessenger gehört? Der kanns mit allen: http://www.gmx.net/de/go/multimessenger __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sorting data for multiple regressions
Hi [EMAIL PROTECTED] napsal dne 04.08.2007 07:49:16: Well, R has a by() function that does what you want, and its help page contains an example of doing regression by group. (There are other ways.) E.g. you can split your data into list d.s - split(data, data$site) and then use lapply to perform your task on all parts of this list result - lapply(d.s, function) Regards Petr On Fri, 3 Aug 2007, Paul Young wrote: So I am trying to perform a robust regression (fastmcd in the robust package) on a dataset and I want to perform individual regressions based fastmcd does not do regression ... or I would have adapted the ?by example to show you. on the groups within the data. We have over 300 sites and we want to perform a regression based on the day of week and the hour for every site. I was wondering if anyone knows of a 'by' command similar to the one used in SAS that automatically groups the data for the regressions. If not, does anyone have any tips on how to split the data into smaller sets and then perform the regression on each set. I am new to R, so I don't know all of the common work arounds and such. At the moment the only method I can think of is to split the data using condition statements and manually running the regression on each set. Thanks or your help -Paul -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: variance
Hi [EMAIL PROTECTED] napsal dne 06.08.2007 11:41:56: hello, I wanna calculate some variances for the bartlett test and I used the var() function but I think it isn't a good estimation for the variance I don't understand why. In fact when I calculate the variances by myself I don't find the same results. And why do you think that your variance calculation is better than the one used in R? Do you know some details about this? Yes PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Thanks. You're welcome Petr _ l [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] array loop
Hi Dong GUO 郭东 [EMAIL PROTECTED] napsal dne 31.07.2007 15:27:35: Thanks, Petr. I changed the equation mark from = to -, then, it works fine. Dont know what difference it has made between the = and -.. from help page The operators - and = assign into the environment in which they are evaluated. The operator- can be used anywhere, whereas the operator = is only allowed at the top level (e.g., in the complete expression typed at the command prompt) or as one of the subexpressions in a braced list of expressions. Although I do not fully understand where I can use - and where =, to be on safe side I use - everywhere when I want to do assignment of some value(s). Regards Petr Regards, Dong On 7/31/07, Petr PIKAL [EMAIL PROTECTED] wrote: Hi as you say that the computing is part of a function than the best way to see what is hapenning is to use debug(your.function) see ?debug for options. Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 31.07.2007 00:11:00: Dear all, here are two arrays: region(26,31,8), nation(8) I tried to get a new array, say, giGi(26,31,8) giGi - array(0,dim = c(region_dim)) for (i in (1:region_dim[3])) { giGi[,,i] = region[,,i]-nation[,i] } As the above is part of function, but results shows only giGi[,,1] has the right answers, all the others (giGi[,,2],..giGi[..8]) are zeros. I have checked array of region and nation, they are not zeros at all when I do manually, it is not the case, giGi has meanful numbers. can some one tell me the trick in this process?? Many thanks in advance. Dong [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: array loop
Hi as you say that the computing is part of a function than the best way to see what is hapenning is to use debug(your.function) see ?debug for options. Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 31.07.2007 00:11:00: Dear all, here are two arrays: region(26,31,8), nation(8) I tried to get a new array, say, giGi(26,31,8) giGi - array(0,dim = c(region_dim)) for (i in (1:region_dim[3])) { giGi[,,i] = region[,,i]-nation[,i] } As the above is part of function, but results shows only giGi[,,1] has the right answers, all the others (giGi[,,2],..giGi[..8]) are zeros. I have checked array of region and nation, they are not zeros at all when I do manually, it is not the case, giGi has meanful numbers. can some one tell me the trick in this process?? Many thanks in advance. Dong [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Bind together two vectors of different length...
Hi [EMAIL PROTECTED] napsal dne 30.07.2007 12:09:59: Dear everyone, I've got difficulties in realizing the following task: I have two vectors: A - c(1:10) B- seq(1,10,2) Now I want to make a table form vectors A and B as rows, and if a value of A isn't present B, then I want to put a N/A symbol in it: Output should look like this: 1 2 3 4 5 6 7 8 9 10 1 0 3 0 5 0 7 0 9 0 How can I do this in R? in your particular case rbind(A,A*(A %in% B)) will give you such output, but 0 is not NA thereofore AO-A*(A %in% B) AO[!(A %in% B)]-NA rbind(A, AO) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] A 12345678910 AO1 NA3 NA5 NA7 NA9NA gives you such output but with NA values instead of zeroes Regards Petr Thank you. -- Andris Jankevics Assistant Department of Medicinal Chemistry Latvian Institute of Organic Synthesis Aizkraukles 21, LV-1006, Riga, Latvia __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: data order by different level of variables
Hi [EMAIL PROTECTED] napsal dne 28.07.2007 02:18:33: Dear useR, I have a data matrix, it has n columns, each column is a two-level variable with entires -1 and +1. They are randomly generated, now I want to order them like (for example, 5 columns case) --- - - -- - -- . (first several rows are the samples with all variables in low level) + - -- - + - --- . - + -- - + + -- - + + + + + Is there any function in R that could let me do this order by Var1 then order by Var2 then...order by Var n Did you try ?order Regards Petr Thanks very much in advance! Best, Leon [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Looping through all possible combinations of cases
Hi I am not sure about using loops but something like colSums(combn(DATA[,1],2)) gives you sums of all pairs and colSums(combn(DATA[,1],3)) sums of all triplets etc. if you want to know which ones they are just use combn on names. e.g. y X1.5 a1 b2 c3 d4 e5 colSums(combn(y[,1],2)) [1] 3 4 5 6 5 6 7 7 8 9 combn(row.names(y),2) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] a a a a b b b c c d [2,] b c d e c d e d e e Regards Petr [EMAIL PROTECTED] napsal dne 27.07.2007 20:35:39: Hello! I have a regular data frame (DATA) with 10 people and 1 column ('variable'). Its cases are people with names ('a', 'b', 'c', 'd', 'e', 'f', etc.). I would like to write a function that would sum up the values on 'variable' of all possible combinations of people, i.e. 1. I would like to write a loop - in such a way that it loops through each possible pair of cases (i.e., ab, ac, ad, etc.) and sums up their respective values on 'variable' 2. I would like to write a loop - in such a way that it loops through each possible trio of cases (i.e., abc, abd, abe, etc.) and sums up their respective values on 'variable'. 3. I would like to write a loop - in such a way that it loops through each possible quartet of cases (i.e., abcd, abce, abcf, etc.) and sums up their respective values on 'variable'. etc. Then, at the end I want to capture all possible combinations that were considered (i.e., what elements were combined in it) and get the value of the sum for each combination. How should I do it? Thanks a lot! Dimitri __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: multiple graphs
Hi this particular graph is a combination of several approaches see layout # how to split plot window (or ?split) par(new=TRUE) # how to plot several times to the same window without erasing previous plot and of course sophisticated use of all other stuff which is available in R. See also par(fig=...) plot(1:10) par(fig=c(0.1,.5,0.1,.5), new=T) boxplot(rnorm(10)) Petr [EMAIL PROTECTED] napsal dne 26.07.2007 09:26:16: Does anyone have a simple explanation and example on how to add histograms or barcharts to an other graph like in the example at the R-graph gallery: http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=109 looking at the code I'not undertand very well how to add graphs in arbitrary/clever position with an adequate scale. If somebody have a simplier example with explanations it will be highly appreciate. Best Daniele -- Scegli infostrada: ADSL gratis per tutta l’estate e telefoni senza canone Telecom __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: plots
Hi [EMAIL PROTECTED] napsal dne 25.07.2007 12:17:54: Hi Sir I did not find any function of graph which plot one variable on x-axis and 2 or more than 2 variables on y-axis. ?matplot or you can do plot(x,y, ylim=range(all.your.y), type=n) and add lines/points by lines(x, one.of.your.y) points(x, other.of.your.y) Regards Petr Moreover, how can I change the labels of L-moments diagram obtained by plotlmrdia(lmrdia()) Thank you -- AMINA SHAHZADI Department of Statistics GC University Lahore, Pakistan. Email: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Operator and
Hi you definitely shall make a quick glance to some documentation which comes with R e.g. R intro manual. Or look at CRAN where is quite impressive amount of literature from basic stuff to advanced papers. To your question: [EMAIL PROTECTED] napsal dne 25.07.2007 14:23:58: Hello, I'am new to the R world and have a lot of question but the first is : How to deal with opertor in table objects? (Or how to deal with in general...) I explain my problem. I read a file with the read.table expression. I then obtain a matrix. I read the first line for example with the commande data[,1]. Then I would like to You did not select line but column. data[,1] 2 will give you logical vector which you can use for selection of rows from data. data[data[,1] 2,] Regards. Petr select only the element in this line that are greater than 2. Is there an elegant way to achieve that ? Thanks by advance... -- View this message in context: http://www.nabble.com/Operator-%3E-and-%3C- tf4141869.html#a11781567 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Open two graphic devices at a time
Hi far from beeing an expert in graphic devices AFAIK you can either see your graph on screen (x11 device) or to open other device (pdf, png, ...) and to issue plotting commands to that device. Do not forget dev.off() after your plot is finished. Or you can save your plot by menu command File/Save as... (on Windows), which you did not specify. Regards Petr [EMAIL PROTECTED] napsal dne 25.07.2007 15:55:12: Hello, I would like to export my plots to harddisk (jpeg or pdf). I know that could be done with pdf(...) and jpeg(...). But my problem is that if I open e.g. the pdf device my plot does not appear on the screen. If I plot to the x11 device and try to export later the outputfile is damaged. How can I manage that problem? I want to see my plots on screen and want to export them. Is there a chance to open two different devices, or is the only way printing twice. One time to x11() and one time to pdf()? Thanks a lot for any idea -- View this message in context: http://www.nabble.com/Open-two-graphic-devices- at-a-time-tf4142321.html#a11783029 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Adding data to existing plot with new=TRUE does not appear to work
Hi if you change your code plot(1,10, xlim=range(0,3), ylim=range(0,10), type='n') aa - rep(1,10) bb - 1:10 plot(aa,bb, xlim=range(0,3), ylim=range(0,10), new=TRUE) aa - rep(2,10) par(new=T) plot(aa,bb, xlim=range(0,3), ylim=range(0,10), new=TRUE) you will get both columns plotted. However you can get similar result with using points plot(1,10, xlim=range(0,3), ylim=range(0,10), type='n') aa - rep(1,10) bb - 1:10 points(aa,bb) aa - rep(2,10) points(aa,bb) Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 04.07.2007 09:48:15: Dear all, I am trying to shove a number of cmdscale() results into a single plot (k=1 so I'm trying to get multiple columns in the plot). From ?par I learned that I can/should set new=TRUE in either par() or the plot function itself. However with the following reduced code, I get only a plot with a column of data points with x==2. plot(1,10, xlim=range(0,3), ylim=range(0,10), type='n') aa - rep(1,10) bb - 1:10 plot(aa,bb, xlim=range(0,3), ylim=range(0,10), new=TRUE) aa - rep(2,10) plot(aa,bb, xlim=range(0,3), ylim=range(0,10), new=TRUE) Also, when I insert a op - par(new=TRUE) either before or immediately after the first plot statement (the type='n' one) in the above code fragment, the resulting graph still only shows one column of data. Have I misinterpreted the instructions or the functionality of new=TRUE? Thank you, Paul Lemmens __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Combine graphical and textual output
Hi try to look at R2HTML package, it can produce report like output. Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 02.07.2007 11:08:46: Hi, I would like to know whether anybody knows a simple way to combine textual and graphical output in R. A typical analysis produces textual output (e.g. model fits) and plots in R. I would like to know whether R has the possibility of combining these into a single 'report' or output. An example of a program that does this is SPSS. After running the analysis you have a combination of textual output (tables) and plots that are easy to print and distribute. I know of the possibility to embed R code into LATEX (using Sweave), but I wouldn't call this quick since a lot of coding will go into writing the Sweave file. Any other suggestions? Regards, Dieter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] no applicable method
Hi From help page A data frame is a list of variables of the same length with unique row names, given class data.frame. so something completely different from matrix (which is AFAIK a vector with dimensions attribute). Therefore matrix needs to have all its values of the same type (numeric, character) but in data framwe you can mix columns with different types. Regards Petr Pikal [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 28.06.2007 20:12:49: You actually got it right. I didn't realize there was a difference between a data frame and matrix. What is the difference any way? Seems like all two dimensional arrays should be equivalent. Kyle On Wed, 27 Jun 2007, Kyle Ellrott wrote: I'm getting started in R, and I'm trying to use one of the gradient boosting packages, mboost. I'm already installed the package with install.packages(mboost) and loaded it with library(mboost). My problem is that when I attempt to call glmboost, I get a message that Error in glmboost() : no applicable method for glmboost . Does anybody have an idea of what kind of problem this is indicative of? The wrong class of input object 'x'. The help page for glmboost is written obscurely, but it seems to imply that it has methods for 'formula' and 'matrix'. Perhaps you passed a data frame? PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. is pertinent. With an example and its output we would have been much better placed to help you. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Import from excel
Hi [EMAIL PROTECTED] napsal dne 27.06.2007 15:43:53: Thank you, but it still doesn't work completely Thanks to you and the dec=, option, I can now do cours[5,5]*5 and get the exact value But I still cannot do matrix operations like cours[2,]%*%cours[5,] As only you have cours we can only guess. You read it into data.frame which can have columns of different type. So my bet is, that you have one or more columns which is not numeric. See how your cours looks like by str(cours) Regards Petr BTW. Maybe is time to look at some docummentation to R, especially R intro. It says the arguments are neither matrix nor vectors. :( Date: Wed, 27 Jun 2007 09:30:32 -0400 From: [EMAIL PROTECTED] Subject: Re: [R] Import from excel To: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] math.ethz.ch Bruce Willy wrote: Hello,I have imported data from Excel using the command cours=read.delim(w:/apprentissage/cours_2.txt) after transforming my initial file with tab delimitersIt seemed to workIt is 2-dimensionnal. When I type cours[5,5], I get this type of message : [1] 0,9760942761824 Levels: 0,495628477 0,893728761 0,89640592 0,903398558 ... 3,864414217 And when I want to multiply it, for example by 2 (cours[5,5]*2), I get : Warning message:* ceci n'est pas pertinent pour des variables facteurs in: Ops.factor(cours[5, 5], 2) i.e. approximately this is not relevant for factor variables.What can I do if I want to manipulate my variables ?Thank you very much You might try the following: cours - read.delim(w:/apprentissage/cours_2.txt, dec=,) See the dec argument on the help page for read.delim(). _ stallées directement dans votre Messenger ![[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Chuck Cleland, Ph.D. NDRI, Inc. 71 West 23rd Street, 8th floor New York, NY 10010 tel: (212) 845-4495 (Tu, Th) tel: (732) 512-0171 (M, W, F) fax: (917) 438-0894 _ stallées directement dans votre Messenger ! [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: how to iterate
Hi as you did not specify your code (which you said it had failed) I try to give you a suggestion how I would do such tasks. for (i in 1:100) { sample(something, no, replace =TRUE) result -perform a test store.a result[i] - result } Regards Petr [EMAIL PROTECTED] napsal dne 26.06.2007 16:08:16: for the following example dataset:- Category Variable 1 127 1 261 1 142 1 183 1 234 1 162 2 173 2 321 2 168 2 197 2 213 2 261 3 198 3 126 3 167 3 154 3 134 3 187 3 109 3 210 I have performed Anova on the measured variable (column#2) for the groups 1,23 (column#1). Now I want to randomize the values in C#2 and reperform the test, say, a hundred times. Please suggest a way for this iteration. The loop I tried to write didn't work. Thanks. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: merge
[EMAIL PROTECTED] napsal dne 20.06.2007 18:02:07: Hello, ok I know how to do to merge matrix or data.frame by row.names but my true objectif is to merge for example this data.frame: A obs Rép1 Rép2 Rép3 Rép4 Rép5 Rép6 Var1 145 145 150 145 140 145 Var2 150 150 160 155 155 150 Var3 155 155 160 150 150 140 Var4 150 145 145 145 140 145 Var5 135 130 145 135 135 130 and B pred Rép1 Rép2 Rép3 Rép4 Rép5 Rép6 Var1 146.00 144.00 151.00 145.00 143.00 141.00 Var2 154.33 152.33 159.33 153.33 151.33 149.33 Var3 152.67 150.67 157.67 151.67 149.67 147.67 Var4 146.00 144.00 151.00 145.00 143.00 141.00 Var5 136.00 134.00 141.00 135.00 133.00 131.00 and the main difficulty is to keep the names and the supernames. Do you know how. I know that the question isn't so easy but it's for a good display. thanks. I may be mistaken but in such a case do you really want to do merge? Or just connecting both objects (data.frames) to list will do what you want? In case you want: pred Rep1... Var1 obs Rep1... Var1 in one object I think list is what I will go for. In case you want: state var Rep1 Rep2 predVar1 obs Var1 predVar2 obs Var2 I would try to fiddle with merge after adding a column state to each object (I hesitate to call it data frame due to supernames) Regards Petr _ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: extract elements
Hi you can use tail tail(data, -95) gives you all but first 95 records. Regards Petr Pikal [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 20.06.2007 12:47:11: Dear R users, just another little question... are there other ways, I mean more easy to write, to obtain the same result I got with: data[95:length(dati[,1]), ] where data is a data frame to extract the last elements starting from a fixed position? thank you very much best regards Manuele PEsenti -- Manuele Pesenti [EMAIL PROTECTED] [EMAIL PROTECTED] http://mpesenti.polito.it __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: outlying
Hi It often depends on your attitude to limits for outlying observations. Boxplot has some identifying routine for selecting outlying points. Any procedure usually requires somebody to choose which observation is outlying and why. You can use e.g. all values which are beyond some threshold based on sd but that holds only if distribution is normal. set.seed(1) x-rnorm(x) ul - mean(x) +3*sd(x) ll - mean(x) -3*sd(x) beyond - (xul) | ( x ll) x[beyond] [1] 3.810277 Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 19.06.2007 11:29:17: hello, are there functions to detecte outlying observations in samples? thanks. ___ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Odp: outlying
[EMAIL PROTECTED] napsal dne 19.06.2007 12:23:58: Hi It often depends on your attitude to limits for outlying observations. Boxplot has some identifying routine for selecting outlying points. Any procedure usually requires somebody to choose which observation is outlying and why. You can use e.g. all values which are beyond some threshold based on sd but that holds only if distribution is normal. set.seed(1) x-rnorm(x) Sorry, it shall be x - rnorm(1000) ul - mean(x) +3*sd(x) ll - mean(x) -3*sd(x) beyond - (xul) | ( x ll) x[beyond] [1] 3.810277 Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 19.06.2007 11:29:17: hello, are there functions to detecte outlying observations in samples? thanks. ___ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: data.frame
Hi Why scratching your left ear with your right hand? If M is numeric matrix d.m - data.frame(M) names(d.m) - paste(Rep, 1:dim(M)[2], sep=) not sure what you want as row names as var is not defined anywhere in your code, but you can use the same principle for changing row names. Jus use row.names(d.m) - whatever vector of names you can elaborate Regards Petr Pikal [EMAIL PROTECTED] BTW. R is not C and you shall use strong features of R not to try to avoid them. [EMAIL PROTECTED] napsal dne 18.06.2007 15:40:38: hello, I'm trying to write a function which take a matrix and give a dataframe with column names and row names but the problem I meet it's that the column number is changing and the vector containing the column names is also changing how can I do to write a good progam for the moment I tryied like follow: dm - ncol(M) v - vector() t - 1 while (dm 0) { v - c(v,paste(Rép,t,sep=)) t - t + 1 dm - dm - 1 } nv - noquote(v) df - function (M,x) { return(data.frame(nv[1] = M[,1], nv[2] = M[,2],nv[3] = M[,3], row.names = var[[1]], check.rows = TRUE, check.names = TRUE)) } I know that there are errors but the important is that R doesn't recognize nv. For more precision the martix M is like follow: M [,1] [,2] [,3] [1,] 6.52 NA 6.59 [2,] 6.99 6.85 6.38 [3,] 6.92 6.72 6.99 [4,] 6.59 5.51 6.45 [5,] 6.65 7.12 6.99 [6,] 6.18 5.71 5.78 [7,] 6.65 6.52 6.72 [8,] 6.65 6.79 6.12 [9,] 6.59 6.65 6.32 [10,] 5.85 6.05 6.38 [11,] 6.38 6.79 6.65 [12,] 6.79 6.52 6.72 [13,] 6.12 6.25 6.38 [14,] 6.99 6.72 6.38 [15,] 6.59 6.65 6.99 [16,] 6.45 6.18 6.59 [17,] 5.65 6.05 6.52 [18,] 6.52 6.85 6.65 [19,] 6.18 6.32 6.32 [20,] 6.99 6.65 6.72 [21,] 6.52 6.99 6.32 Can you help me? thanks. _ Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Selecting all values smaller than X in a dataframe
Hi [EMAIL PROTECTED] napsal dne 11.06.2007 14:09:45: Dear R users, I have a correlation matrix for a dataframe called synth, for which I now want to select only those cells that have correlations larger than +/-0.6: synth=data.frame(x=rnorm(10,1),y=rnorm(10,2),z=rnorm(10,0.5)) w=cor(synth,use=pairwise.complete.obs) w=as.data.frame(w) Why? Better is tu use abs(w).6 and/or which(abs(w).6, arr.ind=T) or, if you want actual values just w[abs(w).6] Regards Petr w[,sapply(w,abs(w),,0.6)] The problem is that using sapply with or doesn´t seem to work. How could I solve this problem? Thank you very much in advance for your help! Best wishes Christoph (I am using R 2.5.0 on Windows XP). -- Christoph Scherber DNPW, Agroecology University of Goettingen Waldweg 26 D-37073 Goettingen +49-(0)551-39-8807 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Svar: Re: help with simple R-question
[EMAIL PROTECTED] napsal dne 06.06.2007 10:56:18: thanks, that works great!! just have another thing...i the same area What if the class is list instead of array, how can you name the first unrecognized column? Hi look in some intro manual and learn about R data structures. Matrix, array, vector, data.frame, list and some others have some distinct features and they sometimes can be interchanged and sometimes not. To learn how objects are organised see str(), class(), typeof(), mode(). Regards Petr Rina John Kane [EMAIL PROTECTED] 06/05/07 3:17 --- Rina Miehs [EMAIL PROTECTED] wrote: hello what do i write for R to recognize both columns? In the R-script downunder you can see that i use tapply to get my information out of my data, and then i need to use it as a dataframe with both columns! It is like R is using the first column as an observationnumber or something, how can i change that?? It is using the names of the variables as rownames. try n.ant - names(antall) antal1 - data.frame(n.antal1, antal1) antal1 -tapply(l1$omlob1,l1$farid,length) antal1 1437987 1100 10007995 10008295 10008792 10010203 10018703 10033401 2 3 3 2 3 1 1 2 10048900 10050492 10055897 10076495 10081892 10094801 10100692 10101395 3 1 3 3 6 2 5 20 10101495 10101595 10104692 10113592 10113697 10114297 10120797 10120897 1 5 4 2 6 11 1 4 10121697 10121897 10121997 10133592 10142892 10142995 10146495 10150497 16 3 6 1 1 6 4 4 10150692 10157092 10157292 10164792 10170892 10171795 10171895 10172300 5 2 4 4 4 4 4 1 10175195 10187802 10192499 10192897 10198295 10200493 10201693 10211593 1 2 2 3 5 1 3 5 antal1 - data.frame(antal1) antal1 antal1 14379872 1100 3 10007995 3 10008295 2 10008792 3 10010203 NA 10018703 NA 10033401 2 10048900 3 10050492 1 10055897 3 10076495 3 10081892 6 10094801 2 10100692 5 Thanks Rina [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R ( http://www.r/ )-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Get news delivered with the All new Yahoo! Mail. Enjoy RSS feeds right on your Mail page. Start today at http://mrd.mail.yahoo.com/try_beta?.intl=ca [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: sampling problem - new to R
Hi If I understand correctly, use split and sample with lapply. If DF is your dataframe lapply(split(DF$Tree, DF$Plot), function(x) sample(x,1)) shall select random tree from each plot. Or you can get it in tabular form with sapply. Regards Petr [EMAIL PROTECTED] napsal dne 05.06.2007 16:29:49: I have a data set of individual trees and the plots that they are in: Tree Plot 567491 634941 873751 374942 927533 348473 387474 etc... So each plot is represented once for every individual that occurrs in it. Plots get different numbers of rows because there can be a different number of individuals in each plot. I want to make a data frame that consists of one individual from each plot. I would like to randomly choose one individual from each plot that is present in the data set. I will have to do this to multiple data sets which may contain different plots, and may contain up to 1200 plots, so I can't choose the plots by hand. Please help me with this. I'm an ecologist and I'm in Panama, with no one around who is educated in R. Whoever solves this problem for me will be acknowledged in any resulting publications. Thanks! -Claire -- View this message in context: http://www.nabble.com/sampling-problem---new-to- R-tf3872130.html#a10970708 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Odp: sampling problem - new to R
Hi If I understand correctly, use split and sample with lapply. If DF is your dataframe lapply(split(DF$Tree, DF$Plot), function(x) sample(x,1)) shall select random tree from each plot. Or you can get it in tabular form with sapply. Regards Petr Sorry, you shall use resample from sample help page as Prof.Ripley pointed if you can have length=1 plot. Regards Petr [EMAIL PROTECTED] napsal dne 05.06.2007 16:29:49: I have a data set of individual trees and the plots that they are in: Tree Plot 567491 634941 873751 374942 927533 348473 387474 etc... So each plot is represented once for every individual that occurrs in it. Plots get different numbers of rows because there can be a different number of individuals in each plot. I want to make a data frame that consists of one individual from each plot. I would like to randomly choose one individual from each plot that is present in the data set. I will have to do this to multiple data sets which may contain different plots, and may contain up to 1200 plots, so I can't choose the plots by hand. Please help me with this. I'm an ecologist and I'm in Panama, with no one around who is educated in R. Whoever solves this problem for me will be acknowledged in any resulting publications. Thanks! -Claire -- View this message in context: http://www.nabble.com/sampling-problem---new-to- R-tf3872130.html#a10970708 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: how to extract the maximum from a matrix?
Hi If you have tried to go through help pages of max you could find out which function, which can tell you position of your maximum. which(x==max(x), arr.ind=T) Regards Petr Pikal [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 01.06.2007 11:09:09: Dear UseRs, I have a very simple question. I have a big matrix (say x) including probabilities (values in (0,1)). I have to store in a list the names of the row and the column where max(x) is located. How can I proceed? Thanks in advance for your assistance! mirko __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: A matrix with mixed character and numerical columns
Hi [EMAIL PROTECTED] napsal dne 31.05.2007 12:48:11: Is it possible to have one? I have a data.frame with two character columns and 6 numerical columns. I converted to a matrix as I needed to use the col() and row() functions. However, if I convert the data.frame to a matrix, using as.matrix, the numerical columns get converted to characters, and that messes up some of the calculations. Do I really have to split it up into two matrices, one character and the other numerical, just so I can use the col() and row() functions? Are there equivalent functions for data.frames? AFAIK I do not remember equivalent functions for data frame. If you just want column or row index you can use 1:dim(DF)[1] or 1:dim(DF)[2] for rows and columns if you want repeat these indexes row or columnwise use rrr-rep(1:dim(DF)[1], dim(DF)[2]) matrix(rrr,dim(DF)[1], dim(DF)[2]) rrr-rep(1:dim(DF)[2], dim(DF)[1]) matrix(rrr,dim(DF)[1], dim(DF)[2], byrow=T) Regards Petr __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] A matrix with mixed character and numerical columns
[EMAIL PROTECTED] napsal dne 31.05.2007 14:32:01: What I am trying to do is create an x-y plot from the numerical values, and the output of row() or col() gives me an excellent way of calculating an x- or y- co-ordinate, with the value in the data.frame being the other half of the pair. Thanks for the code, Petr - I'm sure you would agree, however, that it's a bit 'clumsy' (no fault of yours). Can we just adjust row() and col() for data.frames? col - function (x, as.factor = FALSE) { if (is.data.frame(x)) { x - as.matrix(x) } if (as.factor) factor(.Internal(col(x)), labels = colnames(x)) else .Internal(col(x)) } row - function (x, as.factor = FALSE) { if (is.data.frame(x)) { x - as.matrix(x) } if (as.factor) factor(.Internal(row(x)), labels = rownames(x)) else .Internal(row(x)) } Is there any reason why these won't work? Am I oversimplifying it? Seems to me that both works. At least on data.frame I tried it. Regards Petr Mick -Original Message- From: Petr PIKAL [mailto:[EMAIL PROTECTED] Sent: 31 May 2007 12:57 To: michael watson (IAH-C) Cc: r-help@stat.math.ethz.ch Subject: Odp: [R] A matrix with mixed character and numerical columns Hi [EMAIL PROTECTED] napsal dne 31.05.2007 12:48:11: Is it possible to have one? I have a data.frame with two character columns and 6 numerical columns. I converted to a matrix as I needed to use the col() and row() functions. However, if I convert the data.frame to a matrix, using as.matrix, the numerical columns get converted to characters, and that messes up some of the calculations. Do I really have to split it up into two matrices, one character and the other numerical, just so I can use the col() and row() functions? Are there equivalent functions for data.frames? AFAIK I do not remember equivalent functions for data frame. If you just want column or row index you can use 1:dim(DF)[1] or 1:dim(DF)[2] for rows and columns if you want repeat these indexes row or columnwise use rrr-rep(1:dim(DF)[1], dim(DF)[2]) matrix(rrr,dim(DF)[1], dim(DF)[2]) rrr-rep(1:dim(DF)[2], dim(DF)[1]) matrix(rrr,dim(DF)[1], dim(DF)[2], byrow=T) Regards Petr __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: pie initial angle
Hi [EMAIL PROTECTED] napsal dne 29.05.2007 12:53:14: Dear all, I'd like to produce a simple pie chart for a customer (I know it's bad but they insist), and I have some difficulties setting the initial angle. For example: pie(c(60, 40), init.angle=14) and pie(c(80, 20), init.angle=338) both present the slices in the same direction, where: I presume you misunderstand init angle. Above statements points an arrow of both slices to the similar direction but slices starts at different initial angles. pie(c(60, 40)) pie(c(80, 20)) present the slices in different directions. The arrow slices point to different direction **but** they both **start** at the same initial angle 0 deg. I read everything I could about init.angle argument, I even played with various formulas to compute it, but I just can't figure it out. How can I preserve the desired *direction* of the slices? You probably need to compute initial angle based on proportions in your pie chart (If you really want each pie chart starting at different position). Regards Petr Many thanks in advance, Adrian -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Odp: pie initial angle
From simple geometry pie(c(x, y), init.angle=(300+y/2*360/100)-360) shall do what you request. Although I am not sure if it is wise. Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 29.05.2007 13:30:06: Hi [EMAIL PROTECTED] napsal dne 29.05.2007 12:53:14: Dear all, I'd like to produce a simple pie chart for a customer (I know it's bad but they insist), and I have some difficulties setting the initial angle. For example: pie(c(60, 40), init.angle=14) and pie(c(80, 20), init.angle=338) both present the slices in the same direction, where: I presume you misunderstand init angle. Above statements points an arrow of both slices to the similar direction but slices starts at different initial angles. pie(c(60, 40)) pie(c(80, 20)) present the slices in different directions. The arrow slices point to different direction **but** they both **start** at the same initial angle 0 deg. I read everything I could about init.angle argument, I even played with various formulas to compute it, but I just can't figure it out. How can I preserve the desired *direction* of the slices? You probably need to compute initial angle based on proportions in your pie chart (If you really want each pie chart starting at different position). Regards Petr Many thanks in advance, Adrian -- Adrian Dusa Romanian Social Data Archive 1, Schitu Magureanu Bd 050025 Bucharest sector 5 Romania Tel./Fax: +40 21 3126618 \ +40 21 3120210 / int.101 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Showing NAs when using table()
Hi problem is with your extra empty levels in your d factor. Without it d1-factor(d, exclude=NULL) d1 [1] ABNA NA BCABCABCAB C ABCABCABCABCABC Levels: A B C NA table(b,d1) d1 bA B C NA A 9 0 01 B 0 10 00 C 0 0 91 regards Petr [EMAIL PROTECTED] napsal dne 23.05.2007 17:39:49: I want to use table() to show NA values with factor variables. Using the set up from the help page, I have: b - factor(rep(c(A,B,C), 10)) d - factor(rep(c(A,B,C), 10), levels=c(A,B,C,D,E)) is.na(d) - 3:4 table(b, d) d bA B C D E A 9 0 0 0 0 B 0 10 0 0 0 C 0 0 9 0 0 All of which is fine. But how can I get table() --- or some other function --- to include the observations which are NA for d? This does not do what I want (although I can see how it does what it is documented to do). table(b, d, exclude = NULL) d bA B C D E A 9 0 0 0 0 B 0 10 0 0 0 C 0 0 9 0 0 Note that this dilemma only arises with factor variables. With numeric variables, things work differently. a - c(1, 1, 2, 2, NA, 3); b - c(2, 1, 1, 1, 1, 1); table(a, b) b a 1 2 1 1 1 2 2 0 3 1 0 table(a, b, exclude = NULL) b a 1 2 11 1 22 0 31 0 NA 1 0 How can I get similar behavior with factor variables? Thanks, Dave Kane R.version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 2 minor 5.0 year 2007 month 04 day23 svn rev41293 language R version.string R version 2.5.0 (2007-04-23) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: reading a big file
Hi One possibility is to use scan with combination of skip and nlines parameters in a body of for cycle and adding read portion to some suitable object. Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 23.05.2007 19:38:33: Dear All, I am on WindowsXP with 512 MB of RAM, R 2.4.0, and I want to read in a big file mln100.txt. The file is 390MB big, it contains a column of 100 millions integers. mln100=scan(mln100.txt) Error: cannot allocate vector of size 512000 Kb In addition: Warning messages: 1: Reached total allocation of 511Mb: see help(memory.size) 2: Reached total allocation of 511Mb: see help(memory.size) In fact, I would be quite happy if I could read, say, every tenth integer (line) of the file. Is it possible to do this? Cheers, Rem __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: conversion into capital letter
[EMAIL PROTECTED] napsal dne 15.05.2007 08:41:27: Dear all, I would need a function which convert small letter into capital letter (at least the first letter of a character variable). Does such a function exist in R ? ?toupper, ?tolower Regards Petr Thanks by advance Jessica __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Anova Test
Hi [EMAIL PROTECTED] napsal dne 15.05.2007 16:39:20: Hi, I am very new to R. I am trying to perform an Anova Test and see if it differs or not. Basically, i have 4 tests and 1 control. Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 The inference is at alpha=0.05. they are all independent. I am trying to find if they differ or the same. Maybe t.test? x - c(20,25,15,10) t.test(x-17) One Sample t-test data: x - 17 t = 0.1549, df = 3, p-value = 0.8867 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: -9.771301 10.771301 sample estimates: mean of x 0.5 Regards Petr test1-c(20) test2-c(25) test3-c(15) test4-c(17) test4-c(10) control-c(17) tester-data.frame(test1,test2,test3,test4,control) tester test1 test2 test3 test4 control 120251510 17 anova(lm(tester)) Analysis of Variance Table Response: test1 Df Sum Sq Mean Sq F value Pr(F) Residuals 0 0 I think i did something wrong. I need to find the correct F statistic test. any help. thanks. -- View this message in context: http://www.nabble.com/Anova-Test-tf3758829.html#a10624007 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Anova Test
[EMAIL PROTECTED] napsal dne 15.05.2007 17:32:35: Thank you Guys. Let say that from Test1 to control i have multiple data Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 . . . . . . . . . . 40 20 1535 45 Is this the method i need to use? Better is to use stacked format. value testno 20 t1 ...t1 40 t1 25 t2 ...t2 20 t2 ... then anova(lm(value~testno, data=yourdata)) will give you anova table. However be carefull to keep testno as a factor. You could also consult some introductory literature which can be find on CRAN, especially about data manipulation and linear models. Maindonald, Verzani or Faraway is a good starting choice. Regards Petr anova(lm(..this is where i am not sure how to put them. is this something to do with anova(lm(dependent~independent*independent, data=name) if they are all independent, how do i put them together? thanks. Ben Bolker-2 wrote: CrazyJoe keizer_61 at hotmail.com writes: I am very new to R. I am trying to perform an Anova Test and see if it differs or not. Basically, i have 4 tests and 1 control. Tester Test1 Test2 Test3 Test4 Control 20 25 1510 17 You can't make any inferences with the data you have here. You need to have multiple observations per treatment! See the examples for ?lm . __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Anova-Test-tf3758829.html#a10625154 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] apply( )
Hi [EMAIL PROTECTED] napsal dne 10.05.2007 17:59:22: or with(foo, (x y) * (x z)) Should not it be with(foo, ((x y) | (x z))*1) Regards Petr On 5/10/07, jim holtman [EMAIL PROTECTED] wrote: You don't need apply. Just do foo$result - ifelse((foo$x foo$y) | (foo$x foo$z), 1, 0) On 5/10/07, Greg Tarpinian [EMAIL PROTECTED] wrote: I have a question that must have a simple answer (but eludes me). I need a row-by-row logical comparison across three numeric variables in a data frame: foo$x, foo$y, foo$z. The logic is if( x y || x z ) 1 else 0 for a particular row. It is simple and very inefficient to use for(i in 1:length(foo$x)){ } loops. How can I accomplish this using sappy( ) / lapply( ) / apply( ) or some other more efficient method? Thank you in advance, Greg __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: axis space
Hi [EMAIL PROTECTED] napsal dne 11.05.2007 11:30:28: Hello I have a problem. I have a plot, and have made the writing larger with cex.axis and cex.lab, and i is working great, BUT the writing is bigger than the window... for example, the y-axis writing misses the top of all letters. Does anyone know how to change the window or something so you actually can see what the y-axis says. the plot is attached if there is doubt of what i mean... Look at mar parameter. Before plotting you can adjust your margins to be narower or wider then default values by par(mar=c(your values)) e.g. par( mar= c(5, 5, 4, 2) + 0.1) Regards Petr plot: The y-axis is supposed to say 'Tilvækst i produktionsbesætning'. Thanks Rina __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: A simple question regarding plot of nls objects
Hi [EMAIL PROTECTED] napsal dne 11.05.2007 11:12:21: Hi, I was trying to run the example of Indomethacin kinetics from the book: ## From Pinheiro/Bates, Mixed-Effects-Models in S and S-Plus, ## Springer, Second Printing 2001, Section 6.2 library(nlme) plot(Indometh) fm1Indom.nls - nls(conc~SSbiexp(time,A1,lrc1,A2,lrc2), data=Indometh) summary(fm1Indom.nls) plot(fm1Indom.nls,Subject~resid(.),abline=0) ## the last plot command gives me the error message: Subject not found in data What point am I missing? Works for me in R 2.6.0devel. So check your versions of R and nlme. And look also to your objects and search path ls(), search() if there is not some naming conflict. Regards Petr Thanks in advance, Hans -- Dr. Hans Mielke Federal Institute for Risk Assessment Thielallee 88-92 14195 Berlin Germany Phone: +49 30 8412-3969 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: hi
Hi [EMAIL PROTECTED] napsal dne 10.05.2007 11:08:31: hi, I have this error tr - sample(1:50, 25) train - rbind(iris3[tr,,1], iris3[tr,,2], iris3[tr,,3]) test - rbind(iris3[-tr,,1], iris3[-tr,,2], iris3[-tr,,3]) cl - factor(c(rep(s,25), rep(c,25), rep(v,25))) z - lda(train, cl) Erreur : impossible de trouver la fonction lda I don't understand why R doesn't recognize the lda function, can you help me please? Did you call library(MASS) before trying to use lda? If yes you could have corrupted MASS package. If no, it is always advisable to load packages which you want to use into memory. Regards Petr ___ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: creating a new column
Hi without knowing your code, R version and error message it is hard to say what is wrong. I think I answered already this or similar question but nevertheless: If your data are in data frame ifelse(mm$censoringTimemm$survivalTime,mm$survivalTime, mm$censoringTime) gives you a vector of required values if you have matrix ifelse(m[,3]m[,4],m[,4], m[,3]) gives you the same. Sou you need to add it to your existing structure by cbind() or data.frame() Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 07.05.2007 16:27:37: hie l would like to create a 6th column actual surv time from the following data the condition being if censoringTimesurvivaltime then actual survtime =survival time else actual survtime =censoring time the code l used to create the data is s=2 while(s!=0){ n=20 m-matrix(nrow=n,ncol=4) colnames(m)=c(treatmentgrp,strata,censoringTime,survivalTime) for(i in 1:20) m[i,]-c(sample(c(1,2),1,replace=TRUE),sample(c(1,2), 1,replace=TRUE),rexp(1,.007),rexp(1,.002)) m-cbind(m,0) m[m[,3]m[,4],5]-1 colnames(m)[5]-censoring print(m) s=s-1 treatmentgrp strata censoringTime survivalTime censoring [1,] 1 1 1.0121591137.80922 0 [2,] 2 2 32.971439 247.21786 0 [3,] 2 1 85.758253 797.04949 0 [4,] 1 1 16.999171 78.92309 0 [5,] 2 1 272.909896 298.21483 0 [6,] 1 2 138.230629 935.96765 0 [7,] 2 2 91.529859 141.08405 0 l keep getting an error message when i try to create the 6th column - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] NAs introduced by coercion in dist()
[EMAIL PROTECTED] napsal dne 02.05.2007 16:47:55: It was suggested that the 'NAs introduced by coercion' message might be warning me that my data are not what they should be. I checked this using str(PeaksMatrix), as suggested, and the data seem to be what I thought they were: 'data.frame': 335 obs. of 127 variables: $ Code : Factor w/ 335 levels A1MR,A1MU,..: 1 2 3 4 5 6 7 8 9 10 ... $ P3.70 : num 0 0 0 0 0 0 0 0 0 0 ... $ P3.97 : num 0 0 0 0 0 0 0 0 0 0 ... $ P4.29 : num 0 0 0 0 0 0 0 0 0 0 ... $ P4.90 : num 0 0 0 0 0 0 0 0 0 0 ... $ P6.30 : num 0 0 0 0 0 0 0 0 0 0 ... $ P6.45 : num 7.73 0 0 0 0 0 4.03 0 0 0 ... $ P6.55 : num 0 0 0 0 0 0 0 0 0 0 ... ... I do have 335 observations, 127 variables that are named P3.70, 3.97, P4.29, etc.. This was a relief, but I still don't know whether the distance matrix is what it should be. I tried 'str(dist.PxMx)', which is the name of my distance matrix, but I get something that has not much meaning to me, an unexperienced R user: Class 'dist' atomic [1:55945] 329.6 194.9 130.1 70.7 116.9 ... ..- attr(*, Size)= int 335 ..- attr(*, Labels)= chr [1:335] 1 2 3 4 ... ..- attr(*, Diag)= logi FALSE ..- attr(*, Upper)= logi FALSE ..- attr(*, method)= chr euclidean ..- attr(*, call)= language dist(x = PeaksMatrix, method = euclidean, diag = FALSE, upper = FALSE, p = 2) Any more suggestions, please? Well, it seems that you have the data which you want but why you do not see them is not clear for me. I tried: x-sample(0:2, 100, replace=T) dim(x)-c(10,10) x [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]010011110 1 [2,]010210200 2 [3,]020001101 2 ... [10,]120012021 0 xx-data.frame(var=c(a, b),x) xx var X1 X2 X3 X4 X5 X6 X7 X8 X9 X10 1a 0 1 0 0 1 1 1 1 0 1 2b 0 1 0 2 1 0 2 0 0 2 9a 1 1 0 1 1 0 0 2 2 0 10 b 1 2 0 0 1 2 0 2 1 0 dist(xx, method='euclidean', diag=F,upper=F) 12345678 9 2 2.966479 3 2.345208 3.146427 4 3.633180 3.633180 4.571652 5 4.195235 5.549775 4.571652 4.195235 6 4.195235 4.195235 4.062019 3.924283 3.924283 7 1.816590 3.781534 3.316625 3.781534 3.781534 4.806246 8 2.774887 4.571652 3.633180 4.062019 4.062019 4.806246 3.316625 9 3.316625 4.449719 4.062019 4.449719 3.316625 4.449719 2.774887 3.146427 10 2.774887 5.029911 3.633180 4.324350 3.146427 4.324350 2.569047 2.966479 2.774887 xxx-dist(xx, method='euclidean', diag=F,upper=F) Warning message: NAs introduced by coercion str(xxx) Class 'dist' atomic [1:45] 2.97 2.35 3.63 4.20 4.20 ... ..- attr(*, Size)= int 10 ..- attr(*, Diag)= logi FALSE ..- attr(*, Upper)= logi FALSE ..- attr(*, method)= chr euclidean ..- attr(*, call)= language dist(x = xx, method = euclidean, diag = F, upper = F) seems to be similar to what you get. So I wonder why you do not see you matrix. Try dist.PxMx[1:50] or head(dist.PxMx) to see if you can get something from it. Regards Petr Silvia Lomascolo wrote: I work with Windows and use R version 2.4.1. I am JUST starting to learn this program... I get this warning message 'NAs introduced by coercion' while trying to build a distance matrix (to be analyzed with NMDS later) from a 336 x 100 data matrix. The original matrix has lots of zeros and no missing values, but I don't think this should matter. I searched this forum and people have suggested that the warning should be ignored but when I try to print the distance matrix I only get the row numbers (the matrix seems to be 'empty') and I'm not being able to judge whether the matrix worked or not. To get the distance matrix I wrote: dist.PxMx - dist (PeaksMatrix, method='euclidean', diag=FALSE, upper=FALSE) I tried including the p argument (included in the help for dist()) and leaving it out, but that didn't seem to change anything. I think that's required for one distance measure though, not for euclidean dist. Should I really ignore this warning? If so, why am I not being able to see the distance matrix? -- View this message in context: http://www.nabble.com/NAs-introduced-by- coercion-in-dist%28%29-tf3680727.html#a10286882 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the
[R] Odp: about using read.table
Hi Did you see FAQ 2.16? Try file.choose() Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 03.05.2007 02:26:27: Hi,Dear R users, I have a file text nommed chif which contains 16 lines and 4 columns in the disc dur. I have a difficulty to read this file in R console I have used the following command chif - read.table(c:/chif.txt, header=T, sep= ) I have obtained from R console:undefined file! Can you please help me.Thank you in advance. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: help with plot axis
Hi [EMAIL PROTECTED] napsal dne 03.05.2007 10:33:22: Hello i have a plot, and want the axis too be with larger writing, i found some functions but they didnt work this is my plot, and if the axis can be with bigger writing can the legend inside the plot be in same the size?? plot(femsplot, xlab='Indeks',ylab='Kødprocent', pch=22) abline(lm(femsplot), lwd=1) points(firsplot, col='green', pch=2) abline(lm(firsplot), lwd=1, col='green') points(fjersplot, col='red', pch=8) abline(lm(fjersplot), lwd=1, col='red') legend(locator(1),legend=c('90 kg','80 kg','70 kg'),pch=c(22,2,8),lwd=1, col=c('black','green','red')) i have attached the plot, so you can se it... I would recommend you to: read help pages ?plot ?axis ?par ?legend with special attention to cex and its companion parameters Regards Petr Thank you Rina __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: hi
Hi [EMAIL PROTECTED] napsal dne 03.05.2007 14:01:27: hi, I have a problem to use union function because one of the elements is a character and the others are numeric for(j in 1:length(I)) { + C1 - levels(factor(subset(donParEssai, Id_Essai == 1006961 Id_Cara == I[j], select = Date_O)[,1])) + C2 - as.numeric(levels(factor(subset(donParEssai, Id_Essai == 1006961 Id_Cara == I[j], select = Stade_O)[,1]))) + C3 - length(as.numeric(levels(factor(subset(donParEssai, Id_Essai == 1006961 Id_Cara == I[j], select = Id_Geno)[,1] + C4 - length(levels(factor(subset(donParEssai, Id_Essai == 1006961 Id_Cara == I[j], select = Id_Rep)[,1]))) + C5 - mean(as.numeric(as.character(subset(donParEssai, Id_Essai == 1006961 Id_Cara == I[j], select = Val_O)[,1]))) + C6 - range(as.numeric(as.character(subset(donParEssai, Id_Essai == 1006961 Id_Cara == I[j], select = Val_O)[,1]))) + C7 - sd(as.numeric(as.character(subset(donParEssai, Id_Essai == 1006961 Id_Cara == I[j], select = Val_O)[,1]))) + RecapCara[j,] - union(C1,union(C2,union(C3,union(C4,union(C5,union(C6,C7)) + } Erreur dans RecapCara[j, ] - union(C1, union(C2, union(C3, union(C4, union(C5, : le nombre d'objets ŕ remplacer n'est pas multiple de la taille du remplacement print(RecapCara) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [1,] NA 213 7.66129 5.2 17.1 2.318801 [2,] NA 213 50.56774 47.3 53.9 1.469222 C1 [1] 29/08/2005 I can't paste C1 with others values how could I do to paste C1 with others please? Change it to numeric? Regards Petr ___ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: I need help
Hi [EMAIL PROTECTED] napsal dne 02.05.2007 14:11:51: hello, I need help because I don't understand the syntaxe else how can I write it for example I writed a script to cut missings values and I have errors if(na==length(C)){ + pos=match(0,match(donGeno[[na-1]],donGeno[[na]],nomatch=0)) + for(k in 1:(na-1)) { + if(pos==1) {donGeno[[k]] - donGeno[[k]][2:C[k]]} +if(pos==C[k]){donGeno[[k]] - donGeno[[k]][1:(C[k]-1)]} +else{donGeno[[k]] - c(donGeno[[k]][1:(pos-1)],donGeno[[k]][(pos+1):C(k)])} + } +} if(na==1){ + pos=match(0,match(donGeno[[na+1]],donGeno[[na]],nomatch=0)) + for(k in 2:length(C)){ + if(pos==1) {donGeno[[k]] - donGeno[[k]][2:C[k]]} + if(pos==C[k]){donGeno[[k]] - donGeno[[k]][1:(C[k]-1)]} + else{donGeno[[k]] - c(donGeno[[k]][1:(pos-1)],donGeno[[k]][(pos+1):C(k)])} + } + } else{for(k in 1:(na-1)){ Erreur : erreur de syntaxe dans else if(pos==1) {donGeno[[k]] - donGeno[[k]][2:C[k]]} if(pos==C[k]){donGeno[[k]] - donGeno[[k]][1:(C[k]-1)]} else{donGeno[[k]] - c(donGeno[[k]][1:(pos-1)],donGeno[[k]][(pos+1):C(k)])} Erreur : erreur de syntaxe dans else } Erreur : erreur de syntaxe dans } for(k in 1:(na-1)){ +if(pos==1) {donGeno[[k]] - donGeno[[k]][2:C[k]]} + if(pos==C[k]){donGeno[[k]] - donGeno[[k]][1:(C[k]-1)]} + else{donGeno[[k]] - c(donGeno[[k]][1:(pos-1)],donGeno[[k]][(pos+1):C(k)])} + } Erreur dans C(k) : objet non interprétable comme un facteur } Erreur : erreur de syntaxe dans } Have you got some ideas? What about to try to provide some reproducible example as suggested in posting guide. I believe your messy code can be evaluated in much more neat and concise way without so many ifs and fors. Maybe you can uncover some by yourself what trying to write a simple reproducible example. I am reluctant to decipher what you want to achieve but maybe you want retain only common values of several sets. So e.g. from match help page ## The intersection of two sets : intersect - function(x, y) y[match(x, y, nomatch = 0)] x-sample(1:100, 50) y-1:50 x2-sample(1:100,50) intersect(x,x2) [1] 39 87 66 7 64 79 62 98 6 95 96 35 74 36 3 50 58 97 52 33 61 88 47 17 32 11 76 25 intersect(y,intersect(x,x2)) [1] 3 6 7 11 17 25 32 33 35 36 39 47 50 Regarding the error message if (1==1) print(25) else print(30) [1] 25 if (1==2) print(25) else print(30) [1] 30 if (1==1) print(25) [1] 25 else print(30) Error: syntax error, unexpected ELSE in else From help page In particular, you ***should not have a newline between } and else to avoid a syntax error*** in entering a if ... else construct at the keyboard or via source. For that reason, one (somewhat extreme) attitude of defensive programming is to always use braces, e.g., for if clauses Regards Petr ___ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: simulation
Hi [EMAIL PROTECTED] napsal dne 01.05.2007 09:03:46: Hello I would like to simulate datasets in the following way: x - rpois(999, 2000) y - sum(exp(rgamma(x, scale=2, shape=0.5))) You computed sum of your 999 values. Regardless of how many values are summed the result is always only one number. Did not you want cumsum? Regards Petr The problem is, that by calling y I just get 1 value back and not 999 values. Can anyone help me? Thanks! Brigitte [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: adding column to a matrix
Hi see ?ifelse ifelse(censoringsurvival, survival, censoring) Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 01.05.2007 13:25:18: l have the following dataset and would like to calculate the actual survival time by if censoring time survival time then actual survival time =survival time else its= censoring time. treatmentgrp strata censoringTimesurvivalTime censoring actualsurvivaltim [1,] 1 1 1.012159 1137.80922 0 [2,] 2 2 32.971439 247.217860 [3,] 2 1 85.758253 797.049490 [4,] 1 1 16.99917178.92309 0 l used matrix to genarate the data thanks in advance - [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: (no subject)
Hi you shall: use appropriate subject e.g. how to subset data use [ ] brackets initialize object donC before using it for assignment and maybe try to look to some docummentation how to manipulate R objects (Paul Johnsons R tips are easily found by Google and they help me a lot during my first steps) BTW split(don[, some.columns], don$Id_Cara) could maybe do what you want without using for cycle Regards Petr Pikal [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 24.04.2007 11:48:48: I wanna display some data which there are subsets of a dataframe called don but there are errors like this L=as.numeric(levels(factor(don$Id_Cara))) for(i in L){ + donC(i)=subset(don, Id_Cara == i, select = c( Id_TrT1, Id_Geno, Id_Rep, Val_O)) + donC(i) + } Erreur dans donC(i) = subset(don, Id_Cara == i, select = c(Id_TrT1, Id_Geno, : impossible de trouver la fonction donC- I understand that the problem comes from the third line it doesn't reconize donC(i) but it's very important to make one boucle (in french) on the L's elements. to tell more about L : L [1] 103 137 138 177 193 308 ___ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Calculating means in a new table
Hi look at aggregate something like mymean-aggregate(mydata[,4:5], list( location, Spezies), mean) mysd-aggregate(mydata[,4:5], list( location, Spezies), sd) and then cbind(appropriate columns of resulting data frames) Petr Pikal [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 24.04.2007 14:04:30: Dear all - I imported (on a Mac) a big table with 2000 lines: mydata - read.table(file(/Users/didiw/Desktop/R/all.txt), header = TRUE) mydata[1:15,] location Spezies Spec E.MPa. Phi No Trial 1LC PJ 13.27 7.51 1 1 2LC PJ 14.24 6.68 1 1 3LC PJ 14.28 7.01 2 1 4LC PJ 16.65 6.30 1 2 Now i want to crate a new table mymeans where all means and Stdev of E.MPa and Phi when location, Spezies, No, and Trial are the same, something like this: location Spezies Spec No Trial mean.E stddev.E mean.Phi std.Phi 1LC PJ 1 1 xx xx xx xx 2LC PJ 2 1 xx xx xx xx 3LC PJ 1 2 xx xx xx xx Because I we did ca 8 repetition of each measurement, the new table should have only 2000/8 lines. Thanks for any help! -didi __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] write
Hi had you consider to look at help page? How do you expect your written file to be named? From help page write is a wrapper for cat, which gives further details on the format used cat is useful for producing output in user-defined functions. It converts its arguments to character strings, concatenates them, separating them by the given sep= string, and then outputs them save for writing any R objects, write.table for data frames, and scan for reading data ^^ write.table(F, some.file.name, sep= \t) can maybe do what you want. Help provided with your installation is probably the quickiest way how to evaluate things about commands without waiting for usually delayed and sometimes ironical answer. Regards Petr BTW, F can state for FALSE so if you stick with such names you can be somtimes quite confused however smart is R in evaluating functions and objects. [EMAIL PROTECTED] napsal dne 24.04.2007 15:21:05: ok, I have problems with write function F Id_TrT1 Id_Geno Id_Rep Val_O 30 55094 185 90 55096 187 15 0 55098 192 21 0 55079 176 27 0 55095 192 33 0 55099 198 39 0 55092 192 45 0 55090 172 51 0 55101 193 57 0 55106 190 and to write F I obtain like this: write(F, , sep= ) Erreur dans cat(list(...), file, sep, fill, labels, append) : argument 1 (type 'list') pas encore traité par cat I know that the problem it's that f is a list but when I change it in matrix or something else the consol display it but badly I obtain just one column ___ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] regular expression help
Dear all as usual I am again lost in virtues of regular expressions. I have such character vector named vzor: [365] 61A 62C/27 65A/27 66C/29 69A/29 70C/31 73A/31 74C/33 77A/33 81A/35 82C/37 85A/37 86C/39 [378] 89A/39 90C/41 93A/41 94C/43 97A/43 98C/45 101A/45 102C/47 105A/47 106C/49 109A/49 110C/51 113A/51 and I want only letters from it. I tried gsub([[:alpha:]], \\1,vzor) Error in gsub([[:alpha:]], \\1, vzor) : invalid backreference 1 in regular expression gsub([:alpha:], \\1,vzor) gives me the same vector There is probably very simple solution to it which I overlooked and examples in help page did not help me to find it. Thank you Best regards Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] regular expression help
Thank you all for your working solutions Petr Pikal [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 18.04.2007 13:26:36: A backreference is contained in parentheses and there are no parentheses in your regular expression, hence the error message. Its probably easiest just to remove all non-letters: x - 45x53yy66 gsub([^[:alpha:]], , x) # xyy On 4/18/07, Petr PIKAL [EMAIL PROTECTED] wrote: Dear all as usual I am again lost in virtues of regular expressions. I have such character vector named vzor: [365] 61A 62C/27 65A/27 66C/29 69A/29 70C/31 73A/31 74C/33 77A/33 81A/35 82C/37 85A/37 86C/39 [378] 89A/39 90C/41 93A/41 94C/43 97A/43 98C/45 101A/45 102C/47 105A/47 106C/49 109A/49 110C/51 113A/51 and I want only letters from it. I tried gsub([[:alpha:]], \\1,vzor) Error in gsub([[:alpha:]], \\1, vzor) : invalid backreference 1 in regular expression gsub([:alpha:], \\1,vzor) gives me the same vector There is probably very simple solution to it which I overlooked and examples in help page did not help me to find it. Thank you Best regards Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Matrix manipulation
[EMAIL PROTECTED] napsal dne 16.04.2007 14:52:55: Hi, This is a very basic question, but apparently I am too stupid for it. I have a large matrix A, and I need to avoid for loops. How could I apply a function f(a,r,c) on each element of A, using the subscript (row and column) of a as the other arguments? Hi fff-function(a,b,c) a*b+c x-1:12 dim(x)-c(3,4) x [,1] [,2] [,3] [,4] [1,]147 10 [2,]258 11 [3,]369 12 fff(x, col(x), row(x)) [,1] [,2] [,3] [,4] [1,]29 22 41 [2,]4 12 26 46 [3,]6 15 30 51 works. However from your function description is really tough to understand what the function really does so maybe this is not what you expected. Regards Petr Thanks in advance, Markku Karhunen National Public Health Institute, Finland __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Looping through series of names
Hallo [EMAIL PROTECTED] napsal dne 11.04.2007 22:45:19: Hi I am very new to R and have not able to find the answer to my question in the manual or any other post. I have a dataset that has various different sites names with data relating to each site. The data is in one dataset. I want to loop through the different site names and perform my test on each site. The sites are named not numbers for example YYC. How do I do this. I hope I was clear enough. Thanks for the help Instead of looping try to look at aggregate, tapply or by. And give a quick look to posting guide where you can find some general rules and hints what to do before posting and how to formulate your question to get helpful answer. Regards Petr [[alternative HTML version deleted]] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Tweaking my plot of matrix as image
Hi Did you by chance look at the help page of image? If you did, you could read x,y locations of grid lines at which the values in z are measured. These must be finite, non-missing and in (strictly) ascending order. By default, equally spaced values from 0 to 1 are used. If x is a list, its components x$x and x$y are used for x and y, respectively. If the list has component z this is used for z. z a matrix containing the values to be plotted (NAs are allowed). Note that x can be used instead of z for convenience. and therefore image(1:20, 1:20, your.matrix) shall do what you probably want. And if you have different matrix size then 1:dim(your.matrix)[1] can give you suitable sequence. Regards Petr Pikal [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 12.04.2007 10:55:21: Greetings list, I have a rectangular 20 x 20 matrix with values in the range of [0 , 1]. I'd like to plot it as an image. To that end, I have used the image() function that seems to do what I want. Now, I just want to tweak it to look perfect. So here is my question: At the moment, the values of the axis range from [0, 1]. I want it to show the row and column of the matrix. How do I do that? Thanks in advance. Wee-Jin __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot log scale, axis original scale
Hi Dean Sonneborn [EMAIL PROTECTED] napsal dne 10.04.2007 18:28:43: Petr, This is great! Thank you so much for responding. Could I get one more point clarified. My A values range from 1 to 35. I would really like to use something like AT=1 to 35 by 5 instead of AT=log(a). at=log(a) plots all the messy values. I'm hoping to get values like 1,5 10, 15...35. Is it possible to do it like this? You need not use your original vector for labeling. You can use any other sequence of numbers, e.g. a.lab - c(1,seq(5,35,5)) and use it for labeling. And beware of letters format AT is not at. Regards Petr Petr PIKAL wrote: Hi [EMAIL PROTECTED] napsal dne 09.04.2007 22:10:22: I want to produce some boxplots and plot the logged values but have the axis scale in the original, not-logged scale. It seeming like I have the first few steps but I'm having trouble with the last. Here's what I'm doing (which I got for the documentation for boxplot and axis). How do I get the ticks to be labeled 2,5, and 9 of the original scale? a-c(1,2,3,4,5,6,7,8,9,10) bcat-c(1,1,1,2,2,2,2,3,3,3) boxplot(log(a)~bcat, yaxt=n) axis(2, tick=a) Is axis(2, at=log(a), labels=a) what you want? Regards Petr -- Dean Sonneborn, MS Programmer Analyst Department of Public Health Sciences University of California, Davis (530) 754-9516 (voice) (530) 752-3118 (fax) [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dean Sonneborn, MS Programmer Analyst Department of Public Health Sciences University of California, Davis (530) 754-9516 (voice) (530) 752-3118 (fax) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tapply
Hallo Seems to me that you can make a summary table using aggregate(RESPONSE, list(TREATMENT, MEASUREMENT, BLOCK, STUDY), mean) and then if you want you can use reshape function or melt/cast function from reshape package to get wide form of your table. Regards Petr Pikal [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 10.04.2007 00:14:15: Hi, I have a summary table for an experiment that looks like this STUDY BLOCK TREATMENT MEASURMENT RESPONSE A 1 T-0 1 12 A 1 T-1 1 52 A 1 T-0 2 12 A 1 T-1 2 65 and so on... there are 10 studies, 4 blocks, 10 treatemnts, 5 measurments for the response value. I want to produce a table that looks like this: STUDY BLOCK TREATMENT MEAS.1 MEAS.2 MEAS.3 A 1 T-1 15 54 65 A 1 T-2 54 65 45 A 2 T-1 12 12 23 A 2 T-2 65 54 65 and so on... with tapply(RESPONSE, list(TREATMENT, MEASUREMENT, BLOCK, STUDY), mean) I get very close, however, I get the results as a list! if instead I use ftable(tapply(RESPONSE, list(TREATMENT, MEASUREMENT, BLOCK, STUDY), mean)) I get REALLY close, but the I get only one value for each class, however I need to whole table, because at the end, what I really need is the increment between MEASUREMENT (n) - Measurement (n-1) for each TREATMENT, BLOCK, STUDY, to perform a ANOVA analysis over increment data. Esentialy, I want to move away from running a pivot-table in ACCESS Any thoughts? Cristian Montes North Carolina State University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot log scale, axis original scale
Hi [EMAIL PROTECTED] napsal dne 09.04.2007 22:10:22: I want to produce some boxplots and plot the logged values but have the axis scale in the original, not-logged scale. It seeming like I have the first few steps but I'm having trouble with the last. Here's what I'm doing (which I got for the documentation for boxplot and axis). How do I get the ticks to be labeled 2,5, and 9 of the original scale? a-c(1,2,3,4,5,6,7,8,9,10) bcat-c(1,1,1,2,2,2,2,3,3,3) boxplot(log(a)~bcat, yaxt=n) axis(2, tick=a) Is axis(2, at=log(a), labels=a) what you want? Regards Petr -- Dean Sonneborn, MS Programmer Analyst Department of Public Health Sciences University of California, Davis (530) 754-9516 (voice) (530) 752-3118 (fax) [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: Question about R
Hi isnt it a homework? FYI see ?list ?vector ?data.frame ?sample ?lapply and some basic stuff like Introduction manual provided with your R instalation to see how some simple data manipulations can be done. Regards Petr Pikal [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 05.04.2007 05:58:48: Hi, I would like to ask how can I do the problem as follows by R. Thank you very much. Q: Create a list of twenty distinct first names, ten male and ten female, and store them into an array. Write a routine for selecting a simple random sample of five names and counts the number of male and female names in the sample when the sample is drawn : (a) with replacement (b) without replacement - Finding fabulous fares is fun. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: problem for use R
Hi It is difficult from your question to derive what you exactly want. For reading Excel files there are several ways - see archives. I personally select some data in Excel press Ctrl-C and then in R read.delim(clipboard), however sometimes can be prefered a way through saving txt or csv files. Other posibility is to use RODBC - see Data Export/Import manual. If you want to write some data and use it in Excel they shall be in matrix or data.frame form and use write.table(, sep=\t, row names= FALSE). The file can be directly used by Excel. Regards Petr Pikal [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 05.04.2007 08:55:09: hello, we are french student, we have problem for export the test on Excel. we didn't succed for save and name the test so we can't export it... can you help us please thanks _ mobile comme sur PC ! http://mobile.live.fr/messenger/bouygues/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] reading of a matrix
Hi [EMAIL PROTECTED] napsal dne 05.04.2007 12:50:09: Dear R-experts, I still have problems with the reading of a matrix. Input: matrixData6.txt A-Paar B-Paar C-Paar D-Paar E-Paar A 1 3 5 7 9 B 2 4 6 8 10 R-commands: y=read.table(file=Z:/Software/R-Programme/matrixData6.txt) y Result: A.Paar B.Paar C.Paar D.Paar E.Paar A 1 3 5 7 9 B 2 4 6 8 10 If you look into the txt-file you can recognize that the column names are not the same. Why? If I add in the txt-file the line MyData: infront of all followed by a newline. The R-command as above response an error. How can I read the modified input and get the following result: MyData: A.Paar B.Paar C.Paar D.Paar E.Paar A 1 3 5 7 9 B 2 4 6 8 10 The only difference I can see is centering columns and Mydata: row. This does not have anything with reading your data. You shall instead consult how your data is printed on console by looking at ?print help page. However I think that R itself is not the best tool for text formating. Another stupid question might be hows can I change the column and row names after I made read.table? I want to have the following result, for example: MyData: G H I J K M 1 3 5 7 9 N 2 4 6 8 10 I studied all manuals I could find and the help but could not understand the examples or interpret it right for my case. Did you by chance try ?names or ?rownames Regards Petr Thanks for help, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] package for Matlab
[EMAIL PROTECTED] napsal dne 05.04.2007 15:24:57: Hallo, does a package for Matlab exist in R? You probably could get quicker answer trying to use some search posibilities provided by CRAN. In first few hits from Rseek there is a package R.matlab. I hope it can be installed by a standard instalation procedures. Regards Petr If yes, where can I find it and how can I install it under R? Thanks, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Odp: converting a list to a data.frame
Hi do.call(cbind, your.list) # or rbind gives you rectangular matrix, however shorter items in list are recycled as necessary. Problem is that you need to specify how shall be shorter items handeled as it is not obvious. One possibility could be add NAs to positions where you want them, what is not so simple. But maybe somebody can give more elegant solution. Regards Petr [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 03.04.2007 11:28:27: Hello, I have a list with n numerical components of different length (3, 4 or 5 values in each component of the list); I need to export this as a text file where each component of the list will be a row and where missing values should fill in the blanks due to the different lengths of the components of the list. I think that as a first step I should convert my list to a data frame, but this is not such a simple task to accomplish: I was thinking of the following for loop: X-data.frame(1,1,1,1,1); for (i in 1:length(list)) { X[i,]-unlist(list[[i]]); } Unfortunately, when the number of elements in the components of the list are lower than 5 (maximum), I get errors or undesired results. I also tried with rbind(), but again I couldn't manage to make it accept rows of different length. Does anybody have any suggestions? Working with lists is very nice, but I still have to learn how to transfer them to text files for external use. Thnak you, Filippo Biscarini Wageningen University [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Inquiry
Petr Pikal [EMAIL PROTECTED] - Postoupil do Petr PIKAL/CTCAP dne 30.03.2007 15:47 - Petr PIKAL/CTCAP napsal dne 30.03.2007 15:01:58: Hi Do you mean rounding. If yes you can consult ?round, ?floor, ?ceiling. If you want just to print different amount of digits you can look at options(digits=n) or ?sprintf or ?format Regards Petr Pikal [EMAIL PROTECTED] [EMAIL PROTECTED] napsal dne 30.03.2007 13:12:23: Good morning, I have a question about R, I would like to know how it is possible not to chop the result of an operation. How many decimals it is possible to obtain? Thank you in advance, I. López - Inmaculada López García Dpto. Estadística y Matemática Aplicada Universidad de Almería La Cañada de San Urbano, s/n 04120 Almería (SPAIN) Tfno.:+34 950 01 57 75 Fax:+34 950 01 51 67 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Import of a workspace into R
Hi Do you know what is the program from which you have stored workspace? If you mean that you have some stored R data you shall probably consult save/load help page and/or other possible means of data loading like dput/dget, write/read and maybe some other. Regards Petr On 27 Mar 2007 at 15:36, Schmitt, Corinna wrote: Date sent: Tue, 27 Mar 2007 15:36:16 +0200 From: Schmitt, Corinna [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Import of a workspace into R Hallo, can anyone tell me how I can import a stored workspace of another program into R. I want to use the variables together with their values in new R programmed functions. I could not really find a solution in the paper R Data Export/Import Thanks, Corinna __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Prefered date and date/time classes
Hi On 27 Mar 2007 at 9:09, Charles Dupont wrote: Date sent: Tue, 27 Mar 2007 09:09:27 -0500 From: Charles Dupont [EMAIL PROTECTED] Organization: Vanderbilt University; Department of Biostatistics To: r-help@stat.math.ethz.ch Subject:[R] Prefered date and date/time classes Send reply to: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] What are the preferred date, and data/time classes for R? It is probably a personal choice. You can use POSIX, chron or other options. They are nicely described in RNEWS 4-1 in section Help Desk. Regards Petr Thanks Charles Dupont -- Charles DupontComputer System Analyst School of Medicine Department of Biostatistics Vanderbilt University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subtotal for same row data
Hi Or perhaps aggregate aggregate(x$F, list(C1=x$C1, C2=x$C2), sum) C1 C2 x 1 1 2 0.5 2 2 2 0.5 Regards Petr On 23 Mar 2007 at 16:13, jim holtman wrote: Date sent: Fri, 23 Mar 2007 16:13:30 -0400 From: jim holtman [EMAIL PROTECTED] To: Yuan, Qiaoping (NIH/NIAAA) [E] [EMAIL PROTECTED] Copies to: r-help@stat.math.ethz.ch Subject:Re: [R] subtotal for same row data try this: x - as.data.frame(x) x C1 C2 C3 F R1 1 2 2 0.3 R2 2 2 2 0.5 R3 1 2 1 0.2 do.call('rbind',by(x, list(x$C1, x$C2), function(z){z$F - sum(z$F); z[1,]})) C1 C2 C3 F R1 1 2 2 0.5 R2 2 2 2 0.5 On 3/23/07, Yuan, Qiaoping (NIH/NIAAA) [E] [EMAIL PROTECTED] wrote: Hi, There, I would like to subtotal the number in a specified column for all rows having the same data for specified columns. The following is the simple example: x=matrix(c(1,2,2,0.3,2,2,2,0.5,1,2,1,0.2),3,4,byrow=T) rownames(x)=c(R1,R2,R3) colnames(x)=c(C1,C2,C3,F) x C1 C2 C3 F R1 1 2 2 0.3 R2 2 2 2 0.5 R3 1 2 1 0.2 I would like to get the subtotal in column F based on same row data in column C1 and C2. The result should be like C1 C2 SumF 1 2 0.5 # This is 0.3 + 0.2 from R1 and R3 2 2 0.5 Is there a simple way to do this? Any help will be greatly appreciated. Qiaoping Yuan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Detailed legend in mathplot ...
Hi you can put quite sophisticated legend using legend command e.g. legend(locator(1), legend=c(first, second), pch=c(21,22), lty = c(2,1)) Regards Petr On 21 Mar 2007 at 8:38, Petar Milin wrote: From: Petar Milin [EMAIL PROTECTED] To: r-help r-help@stat.math.ethz.ch Organization: Department of Psychology, University of Novi Sad, Serbia Date sent: Wed, 21 Mar 2007 08:38:25 +0100 Subject:[R] Detailed legend in mathplot ... Hello, Recently, I have asked for a help with building graphs, and I got few great advices. Now, my appetite is growing :) and I wander how to add legend for two (or more) lines in following example: matplot(DAT[, c(3,4)], type=b, ylim=c(0,8), xaxt=n, yaxt=n, + pch=c(21,22), col=black, lty=c(dashed,solid), xlab=, ylab=) title(ylab=% correct, xlab=Trial, cex.lab=1.5) axis(1, at=1:4, labels=as.character(DAT$Trial), cex.axis=1.5) axis(2, cex.axis=1.5) Sincerely, Petar __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bad points in regression
Hi you can check ?influence or ?influence.measures to evaluate some regression diagnostics Regards Petr On 16 Mar 2007 at 9:56, Alberto Monteiro wrote: From: Alberto Monteiro [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date sent: Fri, 16 Mar 2007 09:56:56 -0200 Subject:[R] Bad points in regression I have a question, maybe it's better to explain by example: alpha - 0.3 beta - 0.4 sigma - 0.5 err - rnorm(100) err[15] - 5; err[25] - -4; err[50] - 10 x - 1:100 y - alpha + beta * x + sigma * err ll - lm(y ~ x) plot(ll) Now, the graphs clearly show that 15, 25 and 50 are the indexes of the bad points. How can I retrieve this information from ll? Alberto Monteiro __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to...
Hi I suppose you will not get usefull response for such poorly specified question. For automating procedures on data frames you can either do looping or use lapply or maybe do.call can also provide some functionality. If you elaborate what you did and in what respect it was unsatisfactory maybe you will get better answer. Anyway, before your next post you shall look to posting guide. Regards Petr On 15 Mar 2007 at 17:20, [EMAIL PROTECTED] wrote: Date sent: Thu, 15 Mar 2007 17:20:57 +0100 From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: R Help R-help@stat.math.ethz.ch Subject:[R] how to... I have to perform ANOVA's on many different data organized in a dataframe. I can run an ANOVA for each sample, but I've got hundreds of data and I would like to avoid manually carrying out each test. in addition, I would like to have the results organized in a simple way, for example in a table, wich could be easy to export. thank you for assistance simone -- Leggi GRATIS le tue mail con il telefonino i-mode di Wind http://i-mode.wind.it __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] autoload libraries at startup
Hi see .First or .Rprofile Regards Petr BTW, did you try ?Startup or help.search(startup) before your posting? On 8 Mar 2007 at 12:45, [EMAIL PROTECTED] wrote: To: r-help@stat.math.ethz.ch From: [EMAIL PROTECTED] Date sent: Thu, 08 Mar 2007 12:45:39 -0800 Subject:[R] autoload libraries at startup Hi All I was wondering if there is a way I can specify in R that it should load libraries automatically at startup, so that I do not have to manually issue the command. Thanks Toby __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Removing duplicated rows within a matrix, with missing data as wildcards
Hi its a bit tricky but dup-apply(x, 2, duplicated) #which are dupplucated isna-apply(x, 2, is.na) #which are na check-dup|isna # which are both and here is your result x[rowSums(check)!=3,] [,1] [,2] [,3] [1,]132 [2,]213 [3,]32 NA Regards Petr On 8 Mar 2007 at 10:14, stacey thompson wrote: Date sent: Thu, 8 Mar 2007 10:14:37 -0500 From: stacey thompson [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Removing duplicated rows within a matrix, with missing data as wildcards I'd like to remove duplicated rows within a matrix, with missing data being treated as wildcards. For example x - matrix((1:3), 5, 3) x[4,2] = NA x[3,3] = NA x [,1] [,2] [,3] [1,]132 [2,]213 [3,]32 NA [4,]1 NA2 [5,]213 I would like to obtain [,1] [,2] [,3] [1,]132 [2,]213 [3,]32 NA From the R-help archives, I learned about unique(x) and duplicated(x). However, unique(x) returns unique(x) [,1] [,2] [,3] [1,]132 [2,]213 [3,]32 NA [4,]1 NA2 and duplicated(x) gives duplicated(x) [1] FALSE FALSE FALSE FALSE TRUE I have tried various na.action 's but with unique(x) I get errors at best. e.g. unique(x, na.omit(x)) Error: argument 'incomparables != FALSE' is not used (yet) How I might tackle this? Thanks, -stacey -- -stacey lee thompson- Stagiaire post-doctorale Institut de recherche en biologie végétale Université de Montréal 4101 Sherbrooke Est Montréal, Québec H1X 2B2 Canada [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Multi-line plots with matrices in R
Hi see matplot, matlines. or use forbidden for cycle. for (i in 1:n) lines(x,y[,i], col=i) or if you want to use more colours use built in rainbow, topo.colors or generate your own set. Regards Petr On 7 Mar 2007 at 12:30, Joseph Wakeling wrote: Date sent: Wed, 07 Mar 2007 12:30:46 + From: Joseph Wakeling [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Multi-line plots with matrices in R Hello all, I'm a new user of R, experienced with Octave/MATLAB and therefore struggling a bit with the new syntax. One of the easy things in Octave or MATLAB is to plot multiple lines or sets of points by using a matrix where either the columns or the rows contain the y-values to be plotted. Both packages automatically give each line/points their own unique colour, character etc. I'm wondering how I get the same functionality in R. For example, if X is a vector of x-values and Y is a matrix whose rows contain the y-values, I can do, apply(Y,1,lines,x=X) ... but of course everything is all in black, with the same type of line or points. I'd like each line to have its own unique colour and/or style. Another thing I'd like clarification on is the ability to update an existing plot. For example if I do, plot.window(xlim=c(0,100),ylim=c(0,1)) and then after plotting data decide I want ylim=c(0,0.5), how do I update the graphic? A new plot.window() command does nothing. Many thanks, -- Joe __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Plotting a broken line?
Hi you shall probably cooperate with segments, so you need to extract start and end points for your lines e.g. x-c(1:6, 10:15,20:25) y-rep(c(1,2,3), each=6) plot(x,y, type=l) plot(x,y) segments(sapply(split(x,y), min),1:3, sapply(split(x,y),max),1:3) Regards Petr On 7 Mar 2007 at 10:21, Aldi Kraja wrote: Date sent: Wed, 07 Mar 2007 10:21:06 -0600 From: Aldi Kraja [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Plotting a broken line? Send reply to: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Hi, Is there a smart way in the R graphs to create a line that is broken in intervals based on the indicator given below. following is a small test graph Location,indicator,otherinfo 1.2,1,2.2 2.5,1,2.5 3.7,1,2.3 20.1,2,4.3 22.5,2,5.2 25.0,2,3.4 27.3,2,2.2 35.1,3,3.4 37.0,3,7.2 38.0,3,6.1 40.1,3,5.4 52.9,3,3.3 Right now in the plot the line is continuous, but I would like to have it broken based on the indicator. If the line of the plot reaches the last observation of indicator=1 then the line needs to stop; the next line will start at location 22.5 and continue up top 27.3; the next line goes from 35.1 up to 52.9. x-read.table(file='c:\\aldi\\testgraph.csv',sep=',',header=T) x Location indicator otherinfo 1 1.2 1 2.2 2 2.5 1 2.5 3 3.7 1 2.3 4 20.1 2 4.3 5 22.5 2 5.2 6 25.0 2 3.4 7 27.3 2 2.2 8 35.1 3 3.4 9 37.0 3 7.2 10 38.0 3 6.1 11 40.1 3 5.4 12 52.9 3 3.3 plot(x$Location,x$indicator,type='l',xlim=c(0,max(x$Location)),ylim=c( 0,max(x$indicator,x$otherinfo))) points(x$Location,x$otherinfo) TIA, Aldi -- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to apply functions to unbalanced data in long format by factors......cant get by or aggregate to work
, 20.9473294479256, 20.5087271424267, 16.0871520250047, 16.3816612332698, 16.998645516939, 15.7912392142223, 14.5058735666446, 13.6035104425928, 14.4369066987207, 14.6998435295626, 14.6818972267862, 14.1086877961546, 14.3539049235617, 15.40862828087, 15.0657947671893, 14.8615716011254, 14.5538692431961, 14.2397476835569, 13.4381420777437, 13.4499224158638, 13.6887966810545, 14.6550275257018, 13.500966330283, 14.9271297886953, 14.7405186421119, 15.0047910398043, 14.7051463678038, 14.8325933769599, 12.9854861991046, 13.4203550220891, 15.399010832952, 15.4064707685293, 15.0953970227926, 15.0712109416537, 15.7587957644032, 15.0013202225009, 15.7608498673217, 14.7604080920677, 14.2478533598602, 14.4140245098782, 14.7936541075062, 14.7684428120549, 14.595607155062, 16.1507389488284, 16.4915712924337, 14.490161446684, 14.721633263063, 14.4341721012904, 15.8747652729112, 14.54961671, 14.8633635585377, 14.6696601802386, 13.3020676725265, 14.0190694293311, 15.2168973938334, 12.6304946615056, 12.1972166931101, 12.7960396088298, 14.4285564621952, 14.5308330346953, 14.1496677436943, 14.0823985634278, 12.8407779235951, 14.6543003749437, 14.3202364452416, 15.1723493709662, 14.0744760007345, 14.8132801684508, 12.9183042336999, 14.5225202325766, 13.742309436084)), .Names = c(cpdID, time, treatment, expREP, techREP, Y))) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot(): I want to display dates on X-axis.
Hi you probably know that the second column are dates but your poor PC does not, so you should to tell him. You have several options: Change the column to suitable date format - see chron package or help pages related to date functions e.g. strptime, as.Date, ... and perform your plot. Change your dat column to character vector and using it as a labels to x axis - see help pages to plot, axes, titles On 5 Mar 2007 at 13:26, d. sarthi maheshwari wrote: Date sent: Mon, 5 Mar 2007 13:26:28 +0530 From: d. sarthi maheshwari [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] plot(): I want to display dates on X-axis. Hi, I want to display dates on my x-axis of the plot. I was trying to use plot() command for the same and passing the values in following manner: The variable dat is a data frame. The first column has numeric values and second column has date. e.g. dat [,1]dat[,2] [1,]300 20060101 [2,]257 20060102 [3,]320 20060103 [4,]311 20060104 [5,]297 20060105 [6,]454 20060106 [7,]360 20060107 [8,]307 20060108 However what did you suppose this command will do? Did you even try to read plot help page? the command I am performing is:: plot(x=dat[1], y=as.character(dat[2])) If you want to plot date on x axis and values on y axis why you did it in opposite way? plot(dat[,2], dat[,1]) after transformation to date format shall do what you want. Regards Petr Kindly suggest some method by which I can perform my task of displaying the first column values on y-axis against dates on x-axis. -- Thanks Regards Sarthi M. [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] number of levels for a factor
On 1 Mar 2007 at 12:17, Aimin Yan wrote: Date sent: Thu, 01 Mar 2007 12:17:09 -0600 To: r-help@stat.math.ethz.ch From: Aimin Yan [EMAIL PROTECTED] Subject:[R] number of levels for a factor I have temp list which have 19 data.frame I want to get number of levels for pr in the first dat.frame I do this like this: temp[[1]]$pr just has 1A24 after I do nlevels(temp[[1]]$pr) I expect to get 1, but I get 19 anyone know why? Hi help page for [.factor tells you that using subsetting results in A factor with the same set of levels as x unless drop=TRUE. I presume your list resulted from some splitting operation and that original set of levels was preserved. HTH Petr tail(temp[[1]]$pr) [1] 1A24 1A24 1A24 1A24 1A24 1A24 19 Levels: 1A24 1A57 1A5J 1A6X 1AB7 1AF8 1AFI 1AGG 1AH9 1AHL 1AJ3 1AJW ... 1AZK nlevels(temp[[1]]$pr) [1] 19 Aimin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] label histogram question
Hi in your case I would use for loop (although common practice i to distract from their use :-), maybe together with main and axes options. Or probably lattice histogram could be used too. HTH Petr On 1 Mar 2007 at 22:17, Aimin Yan wrote: Date sent: Thu, 01 Mar 2007 22:17:26 -0600 To: r-help@stat.math.ethz.ch From: Aimin Yan [EMAIL PROTECTED] Subject:[R] label histogram question Dear R list: I have a data like this head(data.19.pr.2) prAveSd M#Re Aa 1 1A24 57.66 33.50 20 ALA_1 ALA 2 1A24 72.16 19.75 20 GLN_2 GLN 3 1A24 103.52 8.64 20 TYR_3 TYR 4 1A24 38.67 15.51 20 GLU_4 GLU 5 1A24 54.56 16.43 20 ASP_5 ASP 6 1A24 999.00 0.00 20 GLY_6 GLY levels(data.19.pr.2$Aa) [1] ALA ARG ASN ASP CYS GLN GLU GLY HIS ILE LEU LYS MET PHE PRO SER THR TRP TYR VAL I want to do histogram for Sd grouped by 20 levels of Aa, and put 20 histograms in one page. I use this code to do job par(mfrow=c(4,5)) tapply(data.19.pr.2$Sd,data.19.pr.2$Aa,hist) I get all 20 histogram in one page,but main label of each histogram is labeled by Histogram of X[[1]] and xlab is labeled by X[[1]]. I want to change these labels using 20 levels of Aa . it look like this: Histogram of ALA Does anyone know how to code these? Aimin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reformulated matrices dimensions limitation problem
Hi creating a biggest possible matrix does not automaticaly mean you can do some computation with it. So the size will depend partly on what you want to do with it. I presume that you do not want only to create a matrix just for pleasure to be able to. Cheers Petr On 2 Mar 2007 at 10:15, Bruno C. wrote: Date sent: Fri, 2 Mar 2007 10:15:33 +0100 From: Bruno C. [EMAIL PROTECTED] To: r-help [EMAIL PROTECTED] Subject:[R] Reformulated matrices dimensions limitation problem First I wanted to thank both Marc Schwartz Greg Snow and for their reply. Then I needed to add a level of complexity to the problem. I would be able to create the biggest possible matrix. In other way does it exist a method to ask smthing like the following : max number of rows for a matrix if column=x? Thank you -- Passa a Infostrada. ADSL e Telefono senza limiti e senza canone Telecom http://click.libero.it/infostrada2marz07 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plot of 2 time series with very different values
Hi I use a function plot.yy which i designed for convenieant plotting on 2 y axes for myself (see code below). You can modify its internals to suit your needs easily but this will give you something quite close. plot.yy(1996:2000, c(80, 100, 95, 35, 28), c(7,8,6, 2, 3), xlim=c(1996, 2000), yylab=c(Resistence,Use), xlab=Date, pch=c(NA,NA), linky=T) HTH Petr On 2 Mar 2007 at 11:54, Berta wrote: From: Berta [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date sent: Fri, 2 Mar 2007 11:54:57 +0100 Organization: bioef Subject:[R] plot of 2 time series with very different values Hi R-Users, I am trying to plot two time series in the same plot, but they measure different things and hence one has values around 1-9 (Use=c(7,8, 6, 2, 3)), and the other one around 20-100 (Resitance=c(80, 100, 95, 35, 28)). I have thought of plotting both in the same graph but with two axes, one from 1 to 9 and the other from 20 to 100. To do so, I needed to do a regression for corrsepondence (1 goes to 20 and 9 goes to 100); the code to produce the graph would be: plot(1996:2000, xlim=c(1996, 2000),ylab=Resistence, ylim=c(20,100), type=n, xlab=Date) lines(1996:2000, c(80, 100, 95, 35, 28), col=1) axis(side=4, at=c(20,30,40,50,60,70,80,90,100), labels=c(1:9)) lines(1996:2000, lsfit(c(1,9),c(20,100))$coef[1]+ lsfit(c(1,9),c(20,100))$coef[2]*c(7,8,6, 2, 3), col=2) legend(1998.5, 90, legend=c(Resistence, Use), fill=c(1,2)) However, I suspect there are better ways to do so, and I would like to know one because I have to do that many times. Thanks a lot in advance, Berta __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Here is the code, all parameters are easily understood except of rect, which will was designed for a plotting a rectangle and you can ignore it completely. plot.yy-function(x,yright,yleft, yleftlim=NULL, yrightlim = NULL, xlab = NULL ,yylab=c(,), pch=c(1,2),col=c(1,2), linky=F, smooth=0, lwds=1, length=10, format=%d/%m, rect=NULL, type=p,...) { par(mar=c(5,4,4,2),oma=c(0,0,0,3)) plot(x, yright, ylim=yrightlim, axes=F,ylab=, xlab=xlab, pch=pch[1],col=col[1], type=type, ...) if (!is.null(rect)) rect(x[rect[1]],rect[2],cas.osa[rect[3]],rect[4], col=grey) points(x, yright, ylim=yrightlim, ylab=, xlab=xlab, pch=pch[1],col=col[1], ...) axis(4,pretty(range(yright,na.rm=T),10),col=col[1]) if (linky) lines(x,yright,col=col[1], ...) if (smooth!=0) lines(supsmu(x,yright,span=smooth),col=col[1], lwd=lwds, ...) if(yylab[1]==) mtext(deparse(substitute(yright)),side=4,outer=T,line=1, col=col[1], ...) else mtext(yylab[1],side=4,outer=T,line=1, col=col[1], ...) par(new=T) plot(x,yleft, ylim=yleftlim, ylab=, axes=F ,xlab=xlab, pch=pch[2],col=col[2], ...) box() axis(2,pretty(range(yleft,na.rm=T),10),col=col[2], col.axis=col[2]) if (!inherits(x,c(Date,POSIXt))) axis(1,pretty(range(x,na.rm=T),10)) else { l-length(x) axis(1,at=x[seq(1,l,length=length)],labels=format(as.POSIXct(x[seq(1,l ,length=length)]),format=format)) } if(yylab[2]==) mtext(deparse(substitute(yleft)),side=2,line=2, col=col[2], ...) else mtext(yylab[2],side=2,line=2, col=col[2], ...) if (linky) lines(x,yleft,col=col[2], lty=2, ...) if (smooth!=0) lines(supsmu(x,yleft,span=smooth),col=col[2], lty=2, lwd=lwds, ...) } Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.