Re: [R] Adding elements of matrices of different dimensions
try the following: matrix(1:50, ncol = 10) + 1:5 # or b + drop(a) I hope it helps. Best, Dimitris Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm - Original Message - From: michael papenfus [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Sent: Tuesday, June 27, 2006 7:28 AM Subject: [R] Adding elements of matrices of different dimensions If I have two matrices: a-matrix(1:5,ncol=1) [,1] [1,]1 [2,]2 [3,]3 [4,]4 [5,]5 b-matrix(1:50,ncol=10) [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,]16 11 16 21 26 31 36 4146 [2,]27 12 17 22 27 32 37 4247 [3,]38 13 18 23 28 33 38 4348 [4,]49 14 19 24 29 34 39 4449 [5,]5 10 15 20 25 30 35 40 4550 How can I add a[1,1] to each column in the first row of b. and the then add a[2,1] to each column in second row of b and so on. I know there must be a way to use the apply function or nested for loops but I can't seem to get it working in R. thanks, michael [[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 Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm __ 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
Re: [R] Robustness of linear mixed models
On Mon, 26 Jun 2006, Bruno L. Giordano wrote: Hello, with 4 different linear mixed models (continuous dependent) I find that my residuals do not follow the normality assumption (significant Shapiro-Wilk with values equal/higher than 0.976; sample sizes 750 or 1200). I find, instead, that my residuals are really well fitted by a t distribution with dofs' ranging, in the different datasets, from 5 to 12. Should this be considered such a severe violation of the normality assumption as to make model-based inferences invalid? For some aspects, yes. Given that R provides you with the means to fit robust linear models, why not use them and find out if they make a difference to the aspects you are interested in? -- 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
Re: [R] Puzzled with contour()
Gabor == Gabor Grothendieck [EMAIL PROTECTED] on Mon, 26 Jun 2006 11:28:48 -0400 writes: Gabor I think its often the case that one has 3 tuples and does not know Gabor how to use contour with that; so, it would be nice if the contour Gabor help page gave advice and an example and a pointer to the relevant Gabor functions if it cannot be done by contour. Yes, but even more importantly, what help(contour) should really have is a \code{\link[lattice]{contourplot}} since contourplot() from package 'lattice' can deal well excellently with the situation Ajay has: After reading his data into matrix 'm3' d3 - data.frame(m3) summary(d3) x y z Min. :0.00 Min. : 20 Min. :0. 1st Qu.:0.25 1st Qu.: 60 1st Qu.:0. Median :0.50 Median :110 Median :0.0040 Mean :0.50 Mean :110 Mean :0.1583 3rd Qu.:0.75 3rd Qu.:160 3rd Qu.:0.1410 Max. :1.00 Max. :200 Max. :1. contourplot(z ~ x+y, data=d3) ## or nicer contourplot(z ~ x+y, data=d3, cuts=20, region = TRUE) ## or rather use logit - transformed z values: contourplot(qlogis(z) ~ x+y, data=d3, cuts=20, region = TRUE) Gabor On 6/26/06, Duncan Murdoch [EMAIL PROTECTED] wrote: On 6/26/2006 10:39 AM, Gabor Grothendieck wrote: I think it would be helpful if this were added to the contour help file. You mean an example of building up the z matrix from points, or just a general discussion of the issue? Duncan Murdoch On 6/26/06, Duncan Murdoch [EMAIL PROTECTED] wrote: On 6/25/2006 9:33 AM, Ajay Narottam Shah wrote: Folks, The contour() function wants x and y to be in increasing order. I have a situation where I have a grid in x and y, and associated z values, which looks like this: contour() wants vectors of x and y values, and a matrix of z values, where the x values correspond to the rows of z, and the y values to the columns. You have a collection of points which need to be turned into such a grid. There's an interp function in the akima package that can do this in general. In your case, it's probably sufficient to do something like this: zmat - matrix(NA, 3, 19) zmat[cbind(20*x + 1, y/10 - 1)] - z x - (0:2)/20 y - (2:20)*10 contour(x,y,zmat) Duncan Murdoch x y z [1,] 0.00 20 1.000 [2,] 0.00 30 1.000 [3,] 0.00 40 1.000 [4,] 0.00 50 1.000 [5,] 0.00 60 1.000 [6,] 0.00 70 1.000 [7,] 0.00 80 0.000 [8,] 0.00 90 0.000 [9,] 0.00 100 0.000 [10,] 0.00 110 0.000 [11,] 0.00 120 0.000 [12,] 0.00 130 0.000 [13,] 0.00 140 0.000 [14,] 0.00 150 0.000 [15,] 0.00 160 0.000 [16,] 0.00 170 0.000 [17,] 0.00 180 0.000 [18,] 0.00 190 0.000 [19,] 0.00 200 0.000 [20,] 0.05 20 1.000 [21,] 0.05 30 1.000 [22,] 0.05 40 1.000 [23,] 0.05 50 1.000 [24,] 0.05 60 0.998 [25,] 0.05 70 0.124 [26,] 0.05 80 0.000 [27,] 0.05 90 0.000 [28,] 0.05 100 0.000 [29,] 0.05 110 0.000 [30,] 0.05 120 0.000 [31,] 0.05 130 0.000 [32,] 0.05 140 0.000 [33,] 0.05 150 0.000 [34,] 0.05 160 0.000 [35,] 0.05 170 0.000 [36,] 0.05 180 0.000 [37,] 0.05 190 0.000 [38,] 0.05 200 0.000 [39,] 0.10 20 1.000 [40,] 0.10 30 1.000 This looks like a nice case where both x and y are in increasing order. But contour() gets unhappy saying that he wants x and y in increasing order. Gnuplot generates pretty 3d pictures from such data, where you are standing above a surface and looking down at it. How does one do that in R? Any help will be most appreciated. A dput() of my data object is : structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3, 0.3,
[R] RMySQL...Can't initialize driver???
Dear R users, I would like to query a MySQL database through R. I have installed the latest required packages (RMySQL and DBI) in R (v2.3.1). A MySQL server (v5.0.22) is running on my local machine but I can't initialize MYSQL driver: library(RMySQL) Loading required package: DBI MySQL(max.con = 10, fetch.default.rec = 500, force.reload = F) Error in new(MySQLDriver, Id = drvId) : unused argument(s) (Id ...) - Could somebody tell me what I have missed? Thx Stéphane. -- == Stephane CRUVEILLER Ph. D. Genoscope - Centre National de Sequencage Atelier de Genomique Comparative 2, Rue Gaston Cremieux CP 5706 91057 Evry Cedex - France Phone: +33 (0)1 60 87 84 58 Fax: +33 (0)1 60 87 25 14 EMails: [EMAIL PROTECTED] ,[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
Re: [R] GARCH message 75
All, You might check out the @ operator on Classes and objects. I can find no documentation on this but if you look at code in fseries or fbasic in the method fARMA.summary. You will find where the object fit in the returned object is access using the @ operator. object - [EMAIL PROTECTED] ans$coefmat - cbind(format(object$coef,digits=digits), format(object$se.coef,digits=digits), format(tval,digits=digits), prob=format.pval(prob,digits=digits)) where x is the from x-armaFit(). This I believe would be the same for the GARCH results. Note the format.pval on the prob. This is important because if you do not do this you will get 0 for small pvalues. I learned this by looking at the code of the pretty printing functions so I can save only results that I want from multiple models runs. You also can then to wald test and LL ratio tests on the models. Good luck 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
[R] R on MAC OS X
Dear all, I have been usig R for some time, but now I have a MAC instead of a PC, am I am having problems in reading files... I have tried: Data-read.table(Users/SaraMM/PhD/Analises-LitterBags/Dados- Litter.txt,head=T) but it said: Error in file(file, r) : unable to open connection In addition: Warning message: cannot open file 'Users/SaraMM/PhD/Analises-LitterBags/Dados- Litter.txt', reason 'No such file or directory' I guess that might be simple... ... related to the fact that in PCs we do C:/ but in iMAC, the only path I found was that one: Users/ SaraMM(...)... Can someone please help me on this? Wishes, Sara __ 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
[R] R on MAC OS X
Looks like you forgot the leading / as in Data-read.table(/Users/SaraMM/PhD/Analises-LitterBags/Dados- Litter.txt,head=T) Dear all, I have been usig R for some time, but now I have a MAC instead of a PC, am I am having problems in reading files... I have tried: Data-read.table(Users/SaraMM/PhD/Analises-LitterBags/Dados- Litter.txt,head=T) but it said: Error in file(file, r) : unable to open connection In addition: Warning message: cannot open file 'Users/SaraMM/PhD/Analises-LitterBags/Dados- Litter.txt', reason 'No such file or directory' I guess that might be simple... ... related to the fact that in PCs we do C:/ but in iMAC, the only path I found was that one: Users/ SaraMM(...)... Can someone please help me on this? Wishes, Sara [[alternative text/enriched 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
[R] Mauchly and Levene
Hallo! I just started working with R to do the statistical analyses for my diploma thesis. I got two sets of data. Both contain repeated measures. One has only one within-subject factor with four levels. The other has one within-subject factor with two levels and one between-factor with two levels. I want to compute a Mauchly test for both sets and a Levene test for the second set. I couldn't find the LEvene test in R. Is it there? I found the mauchly.test but I wasn't able to find out how to compute the error of covariance matrix I need as an argument for mauchly.test. could anybody help me with the correct input I have to give to Mauchly.test so R will give me a test of sphericity out of my data? Thanks in advance! Greetings, Tanja __ Mit WEB.DE iNews werden Sie über die Ergebnisse der wichtigsten WM-Begegnungen __ 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
Re: [R] R on MAC OS X
Sara Mouro wrote: Dear all, I have been usig R for some time, but now I have a MAC instead of a PC, am I am having problems in reading files... I have tried: Data-read.table(Users/SaraMM/PhD/Analises-LitterBags/Dados- Litter.txt,head=T) but it said: Error in file(file, r) : unable to open connection In addition: Warning message: cannot open file 'Users/SaraMM/PhD/Analises-LitterBags/Dados- Litter.txt', reason 'No such file or directory' I guess that might be simple... ... related to the fact that in PCs we do C:/ but in iMAC, the only path I found was that one: Users/ SaraMM(...)... Can someone please help me on this? Wishes, Sara __ 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 the (absolute) path to your file has to start with `/', i.e. your file should be /Users/SaraMM/PhD/Analises-LitterBags/Dados-Litter.txt ^ | the leading slash was missing in your read.table call (in the original way it is a relative path name and would only work, if your current directory within R were `/' itself) joerg __ 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
[R] weights in multinom
Best R Help, I like to estimate a Multinomial Logit Model with 10 Classes. The problem is that the number of observations differs a lot over the 10 classes: Class | num. Observations A | 373 B | 631 C | 171 D | 700 E | 87 F | 249 G | 138 H | 133 I | 162 J | 407 Total: 3051 Where my data looks like: x1 x2 x3 x4 Class 1 1,022 1 A 2 7,2 1 5 B 3 4,2 1 4 H 1 4,1 1 8 F 2 2,4 3 7 D 1 1,2 0 4 J 2 0,9 1 2 G 4 4 3 0 C . . . . . My model looks like: estmodel - multinom(choice ~ x1 + x2 + x3 + x4, data = trainset) When I estimate the model and use the resulting model for prediction of 'new' observations the model has a bias towards the Classes with a large number of observations (A,B,D,J), the other classes are never predicted by the model. I thougth that the option weights of the multinom function could be usefull but I am not sure how to use this in the above case. Is there someone with experience regarding such a weigthing approach in multinom? If someone could help me with suggestions it would be great! Nice day, Arne __ 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
Re: [R] Mauchly and Levene
Tanja Seifried [EMAIL PROTECTED] writes: Hallo! I just started working with R to do the statistical analyses for my diploma thesis. I got two sets of data. Both contain repeated measures. One has only one within-subject factor with four levels. The other has one within-subject factor with two levels and one between-factor with two levels. I want to compute a Mauchly test for both sets and a Levene test for the second set. I couldn't find the LEvene test in R. Is it there? There's one in the car package. I found the mauchly.test but I wasn't able to find out how to compute the error of covariance matrix I need as an argument for mauchly.test. could anybody help me with the correct input I have to give to Mauchly.test so R will give me a test of sphericity out of my data? Someone already did. This is the first example on the help page for mauchly.test. And generating SSD/Variance matrices is on the help page for SSD. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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
Re: [R] write.table csv help
Sachin J wrote: Hi, How can I produce the following output in .csv format using write.table function. for(i in seq(1:2)) df - rnorm(4, mean=0, sd=1) write.table(df,C:/output.csv, append = TRUE, quote = FALSE, sep = ,, row.names = FALSE, col.names = TRUE) } You cannot append columns with write.table(). Uwe Ligges Current O/p: x0.287816-0.81803-0.15231-0.25849x 2.268310.8631740.2699140.181486 Desired output x1 x20.287816 2.26831-0.81803 0.863174-0.15231 0.269914-0.25849 0.181486 Thanx in advance Sachin - [[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 __ 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
Re: [R] analyze summary data
Ben Bolker wrote: Thierry Girard thierry.girard at unibas.ch writes: I do have summary data (mean, standard deviation and sample size n) and want to analyze this data. The summary data is supposed to be from a normal distribution. I need the following calculations on this summary data (no, I do not have the original data): - one sample t-test against a known mu - two sample t-test - analysis of variance between 4 groups. I would appreciate any help available. One possible solution could be to simulate the data using rnorm with the appropriate n, mu and sd, but I don't know if there would be a more accurate solution. this is the kind of situation where you need to go back to the basics -- knowing what computations these statistical tests are _actually doing_ -- which you should be able to find in any basic stats book, or by digging into the guts of the R functions. The only other thing you need to know is the R functions for cumulative distribution functions, pt (for the t distribution) and pf (for the F dist.) For example: stats:::t.test.default has lots of complicated stuff inside but the key lines are (for a one sample test) nx - length(x) df - nx - 1 stderr - sqrt(vx/nx) # if you already have the standard deviation then you want # sqrt(sd^2/nx) tstat - (mx - mu)/stderr ## mu is the known mean you're testing against pval - 2 * pt(-abs(tstat), df) (assuming 2-tailed) you will find similar stuff for the two-sample t-test, depending on your particular choices. The 1-way ANOVA might be harder to dig out of the R code; there you're better off going back and (re)learning from a basic stats treatment how to compute the between-group and (pooled) within-group variances. Bottom line is that, except for knowing about pt and pf, this is really a basic statistics question rather than an R question. good luck Ben Bolker PS: it is too bad, but the increasing sophistication of R is making it harder for beginners to explore the guts --- e.g. knowing to look for stats:::t.test.default in order to find the code ... Thanks for the hint, I already had in mind writing an R Help Desk about Finding the code meaning both, R source code as described above as well as C code corresponding to the .Primitive, .C, .Call and friends' entry points. Maybe for the next R News issue, if nobody is willing to contribute to the Help Desk column (hint, hint!!!). Uwe Ligges __ 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 __ 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
Re: [R] write.table csv help
Hi I am not sure about what you want to achieve by sequential writing to a file so maybe you could fill an object in a loop and write it only once. df-data.frame(matrix(nrow=4,ncol=2)) for(i in seq(1:2)) { df[,i] - rnorm(4, mean=0, sd=1) } write.table(df,output.csv, quote = FALSE, sep = ,, row.names = FALSE, col.names = TRUE) HTH Petr From: Sachin J sachinj.2006_at_yahoo.com Date: Tue 27 Jun 2006 - 04:34:36 EST Hi, How can I produce the following output in .csv format using write.table function. for(i in seq(1:2)) { df - rnorm(4, mean=0, sd=1) write.table(df,C:/output.csv, append = TRUE, quote = FALSE, sep = ,, row.names = FALSE, col.names = TRUE) } Current O/p: x 0.287816 -0.81803 -0.15231 -0.25849 x 2.26831 0.863174 0.269914 0.181486 Desired output x1 x2 0.287816 2.26831 -0.81803 0.863174 -0.15231 0.269914 -0.25849 0.181486 Thanx in advance Sachin -- -- [[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 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
[R] change the class of an object within with()
Hello, Can anyone explain me what is wrong in the following code? and in particular why it is not possible to change the class of an object thanks to the function with(). Does an alternative exist? xxx - data.frame(x = c(a,b,c,d,e), y = c(1,2,3,4,5)) str(xxx) with(xxx, { x - as.character(x) y - as.numeric(y) }) str(xxx) #no effect on the class of x and y xxx$x - as.character(xxx$x) xxx$y - as.numeric(xxx$y) str(xxx) Thanks François Michonnneau __ 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
Re: [R] Griddy-Gibbs sampler
OpenBUGS has a Griddy Gibbs sampler, written in Component Pascal http://www.mathstat.helsinki.fi/openbugs/ The source code is not in plain text format. You will need to install the Black Box Component Builder to read it. I hope this helps. Martyn On Mon, 2006-06-26 at 14:52 -0700, Elizabeth Lawson wrote: Hey everyone, I have read the paper by Ritter and Tanner(1992) on Griddy-Gibbs sampler and I am trying to implement it in R without much luck. I was wondering if anyone had used this or could point me to any example code. Thanks, Liz --- This message and its attachments are strictly confidential. ...{{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
[R] compositional time series
Dear R users, i am wondering if anyone has some hints for this problem (i have not found a clear answer after searching the R-mailing list archive, 'help.search' in R, and R-Wiki, and the like...): let's assume that i have 4 periods compositional time series data: t=1, A=0.1; B=0.5; C=0.4 t=2, A=0.2; B=0.4; C=0.4 t=3, A=0.5; B=0.3; C=0.2 t=4, A=0.4; B=0.3; C=0.3 t=5, ??? By using R, could anyone suggest how to obtain the forecasted value of the fifth period (t=5) as well as the forecast error? (it seems that 'mixeR' [M.Bren] and 'compositions' [v.d.Boogart] have not provided a 'direct' solution to this problem...) really appreciate your time/help for this, Thank you very much, Sincerely, hendry raharjo - [[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
Re: [R] change the class of an object within with()
François MICHONNEAU [EMAIL PROTECTED] writes: Hello, Can anyone explain me what is wrong in the following code? and in particular why it is not possible to change the class of an object thanks to the function with(). Does an alternative exist? xxx - data.frame(x = c(a,b,c,d,e), y = c(1,2,3,4,5)) str(xxx) with(xxx, { x - as.character(x) y - as.numeric(y) }) str(xxx) #no effect on the class of x and y xxx$x - as.character(xxx$x) xxx$y - as.numeric(xxx$y) str(xxx) This is due to the way with() (and eval() friends) deals with data frames. The problem is that they are converted internally to environments before the expressions are evaluated. This means effectively that any assignments or modifications go into a temporary copy of the data frame and are then lost. This is a bit unfortunate, in that it would be really nice for people to be able to say with(foo, bmi - weight/height^2) and have foo extended with a new bmi column. However, there are snags. In particular, how would you deal with a computation that yielded a result that was incompatible with the data frame, like a function, an lm object, or just a vector of the wrong length? Some of us tend to think that this should be sorted out eventually, but for now it just doesn't work. You've already shown one alternative, another one is to use transform(). -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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
Re: [R] change the class of an object within with()
On 27 Jun 2006 12:31:10 +0200, Peter Dalgaard [EMAIL PROTECTED] wrote: François MICHONNEAU [EMAIL PROTECTED] writes: Hello, Can anyone explain me what is wrong in the following code? and in particular why it is not possible to change the class of an object thanks to the function with(). Does an alternative exist? xxx - data.frame(x = c(a,b,c,d,e), y = c(1,2,3,4,5)) str(xxx) with(xxx, { x - as.character(x) y - as.numeric(y) }) str(xxx) #no effect on the class of x and y xxx$x - as.character(xxx$x) xxx$y - as.numeric(xxx$y) str(xxx) This is due to the way with() (and eval() friends) deals with data frames. The problem is that they are converted internally to environments before the expressions are evaluated. This means effectively that any assignments or modifications go into a temporary copy of the data frame and are then lost. This is a bit unfortunate, in that it would be really nice for people to be able to say with(foo, bmi - weight/height^2) and have foo extended with a new bmi column. However, there are snags. In particular, how would you deal with a computation that yielded a result that was incompatible with the data frame, like a function, an lm object, or just a vector of the wrong length? Some of us tend to think that this should be sorted out eventually, but for now it just doesn't work. You've already shown one alternative, another one is to use transform(). transform is probably the best but if you reallly want to use 'with' : xxx[c(x, y)] - with(xxx, list(as.character(x), as.numeric(y))) or the following two if there are no additional columns in xxx: xxx[] - with(xxx, list(as.character(x), as.numeric(y))) xxx - with(xxx, data.frame(x = as.character(x), y = as.numeric(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
[R] horizontal yaxis label
Dear all, I wonder how to get an horizontal label for the y axis in the plot function. I have looked at par and many function but didn't find it. more specifically , let: df - data.frame(cbind(1:10, 11:20)) names(df) - c(y,x) plot(y ~ x, data = df, ylab = dependent) how to ask R to have the label independent in an horizontal form? I have another question concerning the xyplot: Suppose that I have made an xyplot with 4 panels defined by one factor variable. How may I have a blank space between the four panels? Thank you, Bernard, - [[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
Re: [R] weights in multinom
See the references for ?multinom and ?nnet: this is covered in my 1996 book. On Tue, 27 Jun 2006, Jol, Arne wrote: Best R Help, I like to estimate a Multinomial Logit Model with 10 Classes. The problem is that the number of observations differs a lot over the 10 classes: Class | num. Observations A | 373 B | 631 C | 171 D | 700 E | 87 F | 249 G | 138 H | 133 I | 162 J | 407 Total: 3051 Where my data looks like: x1x2 x3 x4 Class 1 1,022 1 A 2 7,2 1 5 B 3 4,2 1 4 H 1 4,1 1 8 F 2 2,4 3 7 D 1 1,2 0 4 J 2 0,9 1 2 G 4 4 3 0 C . . . . . My model looks like: estmodel - multinom(choice ~ x1 + x2 + x3 + x4, data = trainset) When I estimate the model and use the resulting model for prediction of 'new' observations the model has a bias towards the Classes with a large number of observations (A,B,D,J), the other classes are never predicted by the model. I thougth that the option weights of the multinom function could be usefull but I am not sure how to use this in the above case. Is there someone with experience regarding such a weigthing approach in multinom? If someone could help me with suggestions it would be great! Nice day, Arne __ 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 -- 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
Re: [R] horizontal yaxis label
Marc Bernard wrote: Dear all, I wonder how to get an horizontal label for the y axis in the plot function. I have looked at par and many function but didn't find it. more specifically , let: df - data.frame(cbind(1:10, 11:20)) names(df) - c(y,x) plot(y ~ x, data = df, ylab = dependent) how to ask R to have the label independent in an horizontal form? I think you want something like this: df - data.frame(cbind(1:10, 11:20)) names(df) - c(y,x) par(mar = c(7, 10, 7, 7)) plot(y ~ x, data = df, ylab = , xlab = independent) text(par(usr)[1] - 1, 5.5, adj = 1, labels = dependent, xpd = TRUE) Adapted from the example in section 7.27 of http://cran.r-project.org/doc/FAQ/R-FAQ.html I have another question concerning the xyplot: Suppose that I have made an xyplot with 4 panels defined by one factor variable. How may I have a blank space between the four panels? See the between argument. For example: library(lattice) df2 - data.frame(Y = runif(20), X = rnorm(20), G = rep(c(A,B,C,D), each=5)) xyplot(Y ~ X | G, data = df2, layout=c(2,2), between=list(x=1,y=1)) Thank you, Bernard, - [[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 -- 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 __ 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
[R] Boxplot questions.
Dear all, I am having a data for 2 different treatments with different time points. So, I used the following code to plot the boxplot and also to do anova. T11 - c(280, 336, 249, 277, 429) T12 - c(400, 397, 285, 407, 313) T13 - c(725, 373, 364, 706, 249) T21 - c(589, 257, 466, 248, 913) T22 - c(519, 424, 512, 298, 907) T23 - c(529, 479, 634, 354, 1015) obs - c(T11, T12, T13, T21, T22, T23) treat - c(rep(T1,15), rep(T2,15)) time - c(rep(one,5), rep(two,5), rep(thr,5), rep(one,5), rep(two,5), rep(thr,5) ) table - data.frame(obs, treat, time) boxplot(obs ~ treat*time, data=table) I am able to produce a boxplot for the above data. (1) If I want to add a color to T1 and different color to T2, what are the options I should use? (2) my prof. asked me to add '*' above the boxplot, if the comparison is significant. How do I add this '*' in the boxplot? I used: anova(lm(obs ~ treat*time, data=table)) for finding significance. Any help is greatly appreciated. Thanks in advance. Regards, Ezhil __ 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
[R] Survival
Dear all, I write to know if it possible to know the number of censor subject in function of time. I run: os-survfit(Surv(datios$time,datios$status)) summary(os) but it give me only the nomber of events. Can you help me? Thanke you Michela ** Dr.ssa Michela Ballardini Unità di Biostatistica e Sperimentazioni Cliniche c/o Osp. Morgagni-Pierantoni - Pad. Valsalva Via Forlanini, 34 47100 Forlì Tel 0543-731836 Tel/Fax 0543-731612 ** [[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
Re: [R] Mauchly and Levene
Hallo thanks a lot for the answer, I found the Levene test in the car package. I already tried to compute my Mauchly.test the same way as in the example(SSD) matrix - lm(data) mauchly.test(matrix,X=~1) I was just unsure about it because with that I get a different result than when I do the Mauchly test with SPSS... hm thanks again, Tanja Tanja Seifried [EMAIL PROTECTED] writes: Hallo! I just started working with R to do the statistical analyses for my diploma thesis. I got two sets of data. Both contain repeated measures. One has only one within-subject factor with four levels. The other has one within-subject factor with two levels and one between-factor with two levels. I want to compute a Mauchly test for both sets and a Levene test for the second set. I couldn't find the LEvene test in R. Is it there? There's one in the car package. I found the mauchly.test but I wasn't able to find out how to compute the error of covariance matrix I need as an argument for mauchly.test. could anybody help me with the correct input I have to give to Mauchly.test so R will give me a test of sphericity out of my data? Someone already did. This is the first example on the help page for mauchly.test. And generating SSD/Variance matrices is on the help page for SSD. -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ 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
Re: [R] questions on local customized R distribution CD
From: Duncan Murdoch On 6/26/2006 3:14 PM, Dongseok Choi wrote: Hello all! I hope this is the right place to post this question. The Oregon Chapter of ASA is working with local high school teachers as one of its outreaching program. We hope to use and test R as teaching tools. So, we think that a menu system (like R commander) with a few packages and a bit simplified installation instruction need to be developed. The main question is: 1) Is it OK to develop a customized CD-ROM distribution of R with pre-selected packages for high school? It will be distributed free, of course. Also, we plan to make it available from the chap web or deposit it to R-project, if requested. Generally the answer is yes, but read the GPL for the conditions. You do need to make the source code available. I was under the impression that telling the user how to get the source code would satisfy the GPL, instead of distributing the source along with the binary. Is that right? 2) If the customized distribution CD is OK, I also hope to get some technical help/advice from the core group members if any one is interested. See the R Installation and Administration manual first. It tells how to build R installers with non-standard included packages. Hopefully for 2.4.0 more customizations will be possible. Yes, it's not all that hard. Follow the directions carefully and literally and there shouldn't be problem. Andy Duncan Murdoch __ 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 __ 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
Re: [R] Survival
try using summary(os, censored=T) Stef On Tue, Jun 27, 2006 at 01:57:38PM +0200, Michela Ballardini wrote: MichelaDear all, MichelaI write to know if it possible to know the number of censor subject in function of time. I run: Michelaos-survfit(Surv(datios$time,datios$status)) Michela Michelasummary(os) Michela Michelabut it give me only the nomber of events. MichelaCan you help me? MichelaThanke you MichelaMichela Michela Michela Michela** MichelaDr.ssa Michela Ballardini MichelaUnit? di Biostatistica e Sperimentazioni Cliniche Michelac/o Osp. Morgagni-Pierantoni - Pad. Valsalva MichelaVia Forlanini, 34 Michela47100 Forl? MichelaTel 0543-731836 MichelaTel/Fax 0543-731612 Michela** Michela Michela Michela [[alternative HTML version deleted]] Michela Michela__ MichelaR-help@stat.math.ethz.ch mailing list Michelahttps://stat.ethz.ch/mailman/listinfo/r-help MichelaPLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ 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
[R] Memory available to 32-bit R app on 64-bit machine
I want to get a 64-bit machine/OS system so I can put 16Gb of RAM in it. As first I assumed that I would have to use the 64-bit version of R to make use of the 16Gb of RAM, which would mean that I would use the Linux version of R. But I have heard many posters say they run the 32-bit version of R on a 64-bit machine/OS. So my questions, in Windows 64-bit, how much memory would be available to the 32-bit R binary? Is it 4Gb (because its a 32-bit application) or 16Gb (because its being run on a 64-bit OS)? I know most people will suggest to me to ditch windoze and goto Linux, but my company IT department has a big problem with that (and no, they don't want to compile the 64-bit version in Windows, thanks for asking). TIA for any help. Roger [[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
Re: [R] reshaping data.frame question
You might want to try the Oarray package on CRAN. Andy From: Matthias Braeunig Thanks, this is not what what I meant. I need to reshape the original dataframe that I can access p_f[X] for numerical X. Maybe I was not clear enough. The problem really is that X starts at 0. Note that in my example changing the row names to 0:2 does not have the desired effect. jim holtman wrote: You need to specify the row/column name as character: y X1 X2 X3 X4 0 0.1 0.1 0.1 0.1 1 0.2 0.2 0.2 0.2 2 0.3 0.3 0.3 0.3 y[,'X3'] [1] 0.1 0.2 0.3 y['0','X3'] [1] 0.1 On 6/26/06, Matthias Braeunig [EMAIL PROTECTED] wrote: Dear R-helpers, my data.frame is of the form x - data.frame( f=gl(4,3), X=rep(0:2,4), p=c(.1,.2,.3)) x f X p 1 1 0 0.1 2 1 1 0.2 3 1 2 0.3 4 2 0 0.1 5 2 1 0.2 6 2 2 0.3 7 3 0 0.1 8 3 1 0.2 9 3 2 0.3 10 4 0 0.1 11 4 1 0.2 12 4 2 0.3 which tabulates some values p(X) for several factors f. Now I want to put it in wide format, so that factor levels appear as column heads. Note also that X starts from zero. It would be nice if I could simply access p_f[X==0] as f[0]. How can I possibly do that? (The resilting object does not have to be a data.frame. As there are only numeric values, also a matrix would do.) I tried the following y-unstack(x,form=p~f) row.names(y) - 0:2 y X1 X2 X3 X4 0 0.1 0.1 0.1 0.1 1 0.2 0.2 0.2 0.2 2 0.3 0.3 0.3 0.3 Now, how to access X3[0], say? Maybe reshape would be the right tool, but I could not figure it out. I appreciate your help. Thanks! __ 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 __ 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
Re: [R] Boxplot questions.
Hi HTH Petr On 27 Jun 2006 at 4:45, A Ezhil wrote: Date sent: Tue, 27 Jun 2006 04:45:01 -0700 (PDT) From: A Ezhil [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject:[R] Boxplot questions. Dear all, I am having a data for 2 different treatments with different time points. So, I used the following code to plot the boxplot and also to do anova. T11 - c(280, 336, 249, 277, 429) T12 - c(400, 397, 285, 407, 313) T13 - c(725, 373, 364, 706, 249) T21 - c(589, 257, 466, 248, 913) T22 - c(519, 424, 512, 298, 907) T23 - c(529, 479, 634, 354, 1015) obs - c(T11, T12, T13, T21, T22, T23) treat - c(rep(T1,15), rep(T2,15)) time - c(rep(one,5), rep(two,5), rep(thr,5), rep(one,5), rep(two,5), rep(thr,5) ) table - data.frame(obs, treat, time) boxplot(obs ~ treat*time, data=table) I am able to produce a boxplot for the above data. (1) If I want to add a color to T1 and different color to T2, what are the options I should use? from help page border an optional vector of colors for the outlines of the boxplots. The values in border are recycled if the length of border is less than the number of plots. col if col is non-null it is assumed to contain colors to be used to colour the bodies of the box plots. By default they are in the background colour. boxplot(obs ~ treat*time, data=table, border=rep(1:3,each=2)) (2) my prof. asked me to add '*' above the boxplot, if the comparison is significant. How do I add this '*' in the boxplot? see bxp and try bbb- boxplot(.) and look at bbb. You can derive positions of boxes from it and put any text e.g. asterix according to these positions. HTH Petr I used: anova(lm(obs ~ treat*time, data=table)) for finding significance. Any help is greatly appreciated. Thanks in advance. Regards, Ezhil __ 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 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
Re: [R] questions on local customized R distribution CD
On Tue, 27 Jun 2006, Liaw, Andy wrote: From: Duncan Murdoch On 6/26/2006 3:14 PM, Dongseok Choi wrote: Hello all! I hope this is the right place to post this question. The Oregon Chapter of ASA is working with local high school teachers as one of its outreaching program. We hope to use and test R as teaching tools. So, we think that a menu system (like R commander) with a few packages and a bit simplified installation instruction need to be developed. The main question is: 1) Is it OK to develop a customized CD-ROM distribution of R with pre-selected packages for high school? It will be distributed free, of course. Also, we plan to make it available from the chap web or deposit it to R-project, if requested. Generally the answer is yes, but read the GPL for the conditions. You do need to make the source code available. I was under the impression that telling the user how to get the source code would satisfy the GPL, instead of distributing the source along with the binary. Is that right? No, the first part is definitely wrong. (However, you don't have to distribute 'the source along with the binary', unless it is on the Internet.) The obligation is on the distributor to make the exact sources available, not to rely on anyone else (e.g. CRAN, who might just lose them or not be available 2.99 years from now). The relevant clauses are b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, [The following clause c) does not apply if you repackage the distribution.] If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. See e.g. http://www.gnu.org/licenses/gpl-faq.html#DistributeWithSourceOnInternet http://www.gnu.org/licenses/gpl-faq.html#SourceAndBinaryOnDifferentSites The easiest way to meet the obligations is to put the sources on the CD, especially as the sources concerned are only around 5% of the capacity of the CD. -- 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
Re: [R] princomp and prcomp confusion
From: Patrick Connolly When I look through archives at https://stat.ethz.ch/pipermail/r-help/2003-October/040525.html I see this: Liaw, Andy wrote: In the `Detail' section of ?princomp: princomp only handles so-called Q-mode PCA, that is feature extraction of variables. If a data matrix is supplied (possibly via a formula) it is required that there are at least as many units as variables. For R-mode PCA use prcomp. It doesn't appear that anyone disputed the accuracy of it. My current installation (version.string Version 2.3.1 (2006-06-01)) says in the detail of princomp 'princomp' only handles so-called R-mode PCA, that is feature extraction of variables. If a data matrix is supplied (possibly via a formula) it is required that there are at least as many units as variables. For Q-mode PCA use 'prcomp'. I've not been following principal components and have only recently had a use for that methodology. Am I to assume that the later version is the correct one? I thought I'd worked out what the distinction between R-mode and Q-mode was, but now I'm as confused as ever. From what I can gather by googling around about R-mode and Q-mode PCA, the current description should be the correct one. Andy best -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Middle minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Anon ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ~.~.~.~.~. __ 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 __ 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
Re: [R] questions on local customized R distribution CD
On 6/27/2006 8:05 AM, Liaw, Andy wrote: From: Duncan Murdoch On 6/26/2006 3:14 PM, Dongseok Choi wrote: Hello all! I hope this is the right place to post this question. The Oregon Chapter of ASA is working with local high school teachers as one of its outreaching program. We hope to use and test R as teaching tools. So, we think that a menu system (like R commander) with a few packages and a bit simplified installation instruction need to be developed. The main question is: 1) Is it OK to develop a customized CD-ROM distribution of R with pre-selected packages for high school? It will be distributed free, of course. Also, we plan to make it available from the chap web or deposit it to R-project, if requested. Generally the answer is yes, but read the GPL for the conditions. You do need to make the source code available. I was under the impression that telling the user how to get the source code would satisfy the GPL, instead of distributing the source along with the binary. Is that right? Possibly, but not necessarily. See section 3 of the GPL, distributed in the COPYING file with R. Duncan Murdoch __ 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
Re: [R] Puzzled with contour()
On 6/27/06, Martin Maechler [EMAIL PROTECTED] wrote: Gabor == Gabor Grothendieck [EMAIL PROTECTED] on Mon, 26 Jun 2006 11:28:48 -0400 writes: Gabor I think its often the case that one has 3 tuples and does not know Gabor how to use contour with that; so, it would be nice if the contour Gabor help page gave advice and an example and a pointer to the relevant Gabor functions if it cannot be done by contour. Yes, but even more importantly, what help(contour) should really have is a \code{\link[lattice]{contourplot}} since contourplot() from package 'lattice' can deal well excellently with the situation Ajay has: After reading his data into matrix 'm3' d3 - data.frame(m3) summary(d3) x y z Min. :0.00 Min. : 20 Min. :0. 1st Qu.:0.25 1st Qu.: 60 1st Qu.:0. Median :0.50 Median :110 Median :0.0040 Mean :0.50 Mean :110 Mean :0.1583 3rd Qu.:0.75 3rd Qu.:160 3rd Qu.:0.1410 Max. :1.00 Max. :200 Max. :1. contourplot(z ~ x+y, data=d3) ## or nicer contourplot(z ~ x+y, data=d3, cuts=20, region = TRUE) ## or rather use logit - transformed z values: contourplot(qlogis(z) ~ x+y, data=d3, cuts=20, region = TRUE) Gabor On 6/26/06, Duncan Murdoch [EMAIL PROTECTED] wrote: On 6/26/2006 10:39 AM, Gabor Grothendieck wrote: I think it would be helpful if this were added to the contour help file. You mean an example of building up the z matrix from points, or just a general discussion of the issue? Duncan Murdoch On 6/26/06, Duncan Murdoch [EMAIL PROTECTED] wrote: On 6/25/2006 9:33 AM, Ajay Narottam Shah wrote: Folks, The contour() function wants x and y to be in increasing order. I have a situation where I have a grid in x and y, and associated z values, which looks like this: contour() wants vectors of x and y values, and a matrix of z values, where the x values correspond to the rows of z, and the y values to the columns. You have a collection of points which need to be turned into such a grid. There's an interp function in the akima package that can do this in general. In your case, it's probably sufficient to do something like this: zmat - matrix(NA, 3, 19) zmat[cbind(20*x + 1, y/10 - 1)] - z x - (0:2)/20 y - (2:20)*10 contour(x,y,zmat) Duncan Murdoch x y z [1,] 0.00 20 1.000 [2,] 0.00 30 1.000 [3,] 0.00 40 1.000 [4,] 0.00 50 1.000 [5,] 0.00 60 1.000 [6,] 0.00 70 1.000 [7,] 0.00 80 0.000 [8,] 0.00 90 0.000 [9,] 0.00 100 0.000 [10,] 0.00 110 0.000 [11,] 0.00 120 0.000 [12,] 0.00 130 0.000 [13,] 0.00 140 0.000 [14,] 0.00 150 0.000 [15,] 0.00 160 0.000 [16,] 0.00 170 0.000 [17,] 0.00 180 0.000 [18,] 0.00 190 0.000 [19,] 0.00 200 0.000 [20,] 0.05 20 1.000 [21,] 0.05 30 1.000 [22,] 0.05 40 1.000 [23,] 0.05 50 1.000 [24,] 0.05 60 0.998 [25,] 0.05 70 0.124 [26,] 0.05 80 0.000 [27,] 0.05 90 0.000 [28,] 0.05 100 0.000 [29,] 0.05 110 0.000 [30,] 0.05 120 0.000 [31,] 0.05 130 0.000 [32,] 0.05 140 0.000 [33,] 0.05 150 0.000 [34,] 0.05 160 0.000 [35,] 0.05 170 0.000 [36,] 0.05 180 0.000 [37,] 0.05 190 0.000 [38,] 0.05 200 0.000 [39,] 0.10 20 1.000 [40,] 0.10 30 1.000 This looks like a nice case where both x and y are in increasing order. But contour() gets unhappy saying that he wants x and y in increasing order. Gnuplot generates pretty 3d pictures from such data, where you are standing above a surface and looking down at it. How does one do that in R? Any help will be most appreciated. A dput() of my data object is : structure(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.15, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0.3,
[R] RMySQL...Can't initialize driver???
Dear R users, I would like to query a MySQL database through R. I have installed the latest required packages (RMySQL and DBI) in R (v2.3.1). A MySQL server (v5.0.22) is running on my local machine but I can't initialize MYSQL driver: library(RMySQL) Loading required package: DBI MySQL(max.con = 10, fetch.default.rec = 500, force.reload = F) Error in new(MySQLDriver, Id = drvId) : unused argument(s) (Id ...) - Could somebody tell me what I have missed? Thx Stéphane. __ 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
Re: [R] Puzzled with contour()
On 6/27/2006 8:40 AM, Gabor Grothendieck wrote: On 6/27/06, Martin Maechler [EMAIL PROTECTED] wrote: Gabor == Gabor Grothendieck [EMAIL PROTECTED] on Mon, 26 Jun 2006 11:28:48 -0400 writes: Gabor I think its often the case that one has 3 tuples and does not know Gabor how to use contour with that; so, it would be nice if the contour Gabor help page gave advice and an example and a pointer to the relevant Gabor functions if it cannot be done by contour. Yes, but even more importantly, what help(contour) should really have is a \code{\link[lattice]{contourplot}} since contourplot() from package 'lattice' can deal well excellently with the situation Ajay has: [ deletions ] Or perhaps contour should be extended so that it can handle triples giving the capability directly in base graphics. I think that that is what many people really expect. The problem here is that most users are happy enough with the akima or contourplot implementations, so there isn't much motivation to spend several hours doing the necessary work. But if you want to contribute this, please do. Be careful about where you get the code: the interp implementation in akima is not licensed freely enough to be included in R (no commercial use). The one in lattice is GPL'd, so it should be fine. Duncan Murdoch __ 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
Re: [R] Memory available to 32-bit R app on 64-bit machine
On Tue, 27 Jun 2006, roger bos wrote: I want to get a 64-bit machine/OS system so I can put 16Gb of RAM in it. As first I assumed that I would have to use the 64-bit version of R to make use of the 16Gb of RAM, which would mean that I would use the Linux version of R. But I have heard many posters say they run the 32-bit version of R on a 64-bit machine/OS. Yes, and the address-space limits on 32-bit applications still apply: it is done for speed. So my questions, in Windows 64-bit, how much memory would be available to the 32-bit R binary? Is it 4Gb (because its a 32-bit application) or 16Gb (because its being run on a 64-bit OS)? 2Gb, as it is a rather limited 32-bit subsystem of a 64-bit OS. See the reference in the rw-FAQ Q2.9 or ?Memory-limits. No 32-bit OS gives 4Gb address space to an application: most manage about 3Gb. See ?Memory-limits (which is tailored to the OS you are running). [[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 Oh, PLEASE do and turn off HTML mail as we ask. -- 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
Re: [R] RMySQL...Can't initialize driver???
Duncan Murdoch wrote: On 6/27/2006 8:51 AM, Stephane Cruveiller wrote: Dear R users, I would like to query a MySQL database through R. I have installed the latest required packages (RMySQL and DBI) in R (v2.3.1). A MySQL server (v5.0.22) is running on my local machine but I can't initialize MYSQL driver: library(RMySQL) Loading required package: DBI MySQL(max.con = 10, fetch.default.rec = 500, force.reload = F) Error in new(MySQLDriver, Id = drvId) : unused argument(s) (Id ...) - Could somebody tell me what I have missed? I have never used RMySQL, but from the error message, this looks like an incompatibility between it and DBI, presumably because one is newer than the other. I have always found it easier to use RODBC. Because it uses the more general ODBC interface, it may be slower than a package that is tuned to a particular database, but it works, which is a substantial advantage. thanks for the hint... I will give it a try very soon. Duncan Murdoch Stephane. __ 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
Re: [R] RMySQL...Can't initialize driver???
On 6/27/2006 8:51 AM, Stephane Cruveiller wrote: Dear R users, I would like to query a MySQL database through R. I have installed the latest required packages (RMySQL and DBI) in R (v2.3.1). A MySQL server (v5.0.22) is running on my local machine but I can't initialize MYSQL driver: library(RMySQL) Loading required package: DBI MySQL(max.con = 10, fetch.default.rec = 500, force.reload = F) Error in new(MySQLDriver, Id = drvId) : unused argument(s) (Id ...) - Could somebody tell me what I have missed? I have never used RMySQL, but from the error message, this looks like an incompatibility between it and DBI, presumably because one is newer than the other. I have always found it easier to use RODBC. Because it uses the more general ODBC interface, it may be slower than a package that is tuned to a particular database, but it works, which is a substantial advantage. Duncan Murdoch __ 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
Re: [R] RMySQL...Can't initialize driver???
Stephane Cruveiller wrote: Duncan Murdoch wrote: On 6/27/2006 8:51 AM, Stephane Cruveiller wrote: Dear R users, I would like to query a MySQL database through R. I have installed the latest required packages (RMySQL and DBI) in R (v2.3.1). A MySQL server (v5.0.22) is running on my local machine but I can't initialize MYSQL driver: library(RMySQL) Loading required package: DBI MySQL(max.con = 10, fetch.default.rec = 500, force.reload = F) Error in new(MySQLDriver, Id = drvId) : unused argument(s) (Id ...) - Could somebody tell me what I have missed? I am running R 2.3.0 under Linux and connect to a MySQl 4.1 server. You have to create a file in your home directory which has the connection infos. It should look like that: [renpatch] user = UserName password = PassWord database = ... host = ... [renpatch_renosterbos] user = UserName password = PassWord database = ... host = .. and be called .my.conf Then you do: library(RMySQL) m - dbDriver(MySQL) con - dbConnect(m, group = renpatch) q - TheSQLQuery rs - dbSendQuery(con, q) TheResults - fetch(rs, n = -1) dbDisconnect(con) rm(con) and it should work - at least that is what it is doing for me. Rainer -- Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT) Department of Conservation Ecology and Entomology University of Stellenbosch Matieland 7602 South Africa Tel:+27 - (0)72 808 2975 (w) Fax:+27 - (0)21 808 3304 Cell: +27 - (0)83 9479 042 email: [EMAIL PROTECTED] [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
Re: [R] Puzzled with contour()
Duncan == Duncan Murdoch [EMAIL PROTECTED] on Tue, 27 Jun 2006 08:58:59 -0400 writes: Duncan On 6/27/2006 8:40 AM, Gabor Grothendieck wrote: On 6/27/06, Martin Maechler [EMAIL PROTECTED] wrote: Gabor == Gabor Grothendieck [EMAIL PROTECTED] on Mon, 26 Jun 2006 11:28:48 -0400 writes: Gabor I think its often the case that one has 3 tuples and does not know Gabor how to use contour with that; so, it would be nice if the contour Gabor help page gave advice and an example and a pointer to the relevant Gabor functions if it cannot be done by contour. Yes, but even more importantly, what help(contour) should really have is a \code{\link[lattice]{contourplot}} since contourplot() from package 'lattice' can deal well excellently with the situation Ajay has: Duncan [ deletions ] Or perhaps contour should be extended so that it can handle triples giving the capability directly in base graphics. I think that that is what many people really expect. Duncan The problem here is that most users are happy enough Duncan with the akima or contourplot implementations, so Duncan there isn't much motivation to spend several hours Duncan doing the necessary work. But if you want to Duncan contribute this, please do. But also consider that --- since the beginning of time or so --- the triad of contour(), image(), and persp() have had an (almost?) identical way of dealing with (x,y,z) {and related arguments}. So we would want a change using a helper function that can be used in all three cases {and BTW, that helper function would use xyz.coords() - similarly to what happens in scatterplot3d() {in the pkg of the same name}. Duncan Be careful about where you get the code: the interp Duncan implementation in akima is not licensed freely Duncan enough to be included in R (no commercial Duncan use). The one in lattice is GPL'd, so it should be Duncan fine. and I agree that making that functionality part of ``base R'' (would be package 'grDevices') is something quite desirable. Reiterating Duncan: Contributions are welcome, particularly if they are patches against R-devel (and contain updated help files). Duncan Duncan Murdoch Martin Maechler __ 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
Re: [R] RMySQL...Can't initialize driver???
Stephane CRUVEILLER wrote: Dear R users, I would like to query a MySQL database through R. I have installed the latest required packages (RMySQL and DBI) in R (v2.3.1). A MySQL server (v5.0.22) is running on my local machine but I can't initialize MYSQL driver: library(RMySQL) Loading required package: DBI MySQL(max.con = 10, fetch.default.rec = 500, force.reload = F) Error in new(MySQLDriver, Id = drvId) : unused argument(s) (Id ...) - Could somebody tell me what I have missed? Hmm, I can't reproduce the problem: m2 - MySQL(max.con = 16, fetch.default.rec = 500, force.reload = F) summary(m2, verbose=TRUE) MySQLDriver:(31672) Driver name: MySQL Max connections: 16 Conn. processed: 0 Default records per fetch: 500 DBI API version: 0.1-10 MySQL client version: 4.1.7 Open connections: 0 version _ platform i686-pc-linux-gnu arch i686 os linux-gnu system i686, linux-gnu status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) -- David Thx St?phane. -- == Stephane CRUVEILLER Ph. D. Genoscope - Centre National de Sequencage Atelier de Genomique Comparative 2, Rue Gaston Cremieux CP 5706 91057 Evry Cedex - France Phone: +33 (0)1 60 87 84 58 Fax: +33 (0)1 60 87 25 14 EMails: [EMAIL PROTECTED] ,[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 __ 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
Re: [R] compositional time series
Hendry, you have to be very very carefull 'cause of the compositional nature of your data and because of your short time series. 1.You have to be carefull about compositional data (see Aitchinson's book: Compositional Data Analysis). 2. You have a very short time series and it's difficult to model that (see Chattfield's book: Statistical Problem Solving - I think!) Considering 1 and 2, you can analyze your data using R or any other statistical software since you have a model. Do you have one? Tell the group wich one it is and maybe we can help you more. Rogerio Porto. -- Cabeçalho original --- De: [EMAIL PROTECTED] Para: R-help@stat.math.ethz.ch Cópia: Data: Tue, 27 Jun 2006 18:21:32 +0800 (CST) Assunto: [R] compositional time series Dear R users, i am wondering if anyone has some hints for this problem (i have not found a clear answer after searching the R-mailing list archive, 'help.search' in R, and R-Wiki, and the like...): let's assume that i have 4 periods compositional time series data: t=1, A=0.1; B=0.5; C=0.4 t=2, A=0.2; B=0.4; C=0.4 t=3, A=0.5; B=0.3; C=0.2 t=4, A=0.4; B=0.3; C=0.3 t=5, ??? By using R, could anyone suggest how to obtain the forecasted value of the fifth period (t=5) as well as the forecast error? (it seems that 'mixeR' [M.Bren] and 'compositions' [v.d.Boogart] have not provided a 'direct' solution to this problem...) really appreciate your time/help for this, Thank you very much, Sincerely, hendry raharjo - [[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 __ 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
Re: [R] RMySQL...Can't initialize driver???
Rainer M Krug wrote: Stephane Cruveiller wrote: Duncan Murdoch wrote: On 6/27/2006 8:51 AM, Stephane Cruveiller wrote: Dear R users, I would like to query a MySQL database through R. I have installed the latest required packages (RMySQL and DBI) in R (v2.3.1). A MySQL server (v5.0.22) is running on my local machine but I can't initialize MYSQL driver: library(RMySQL) Loading required package: DBI MySQL(max.con = 10, fetch.default.rec = 500, force.reload = F) Error in new(MySQLDriver, Id = drvId) : unused argument(s) (Id ...) - Could somebody tell me what I have missed? I am running R 2.3.0 under Linux and connect to a MySQl 4.1 server. You have to create a file in your home directory which has the connection infos. It should look like that: [renpatch] user = UserName password = PassWord database = ... host = ... [renpatch_renosterbos] user = UserName password = PassWord database = ... host = .. and be called .my.conf I followed your instruction. Here is my .my.cnf: --- [client] user=steff password=XX database=justforfun --- with it, I can connect to my MYSQL server without problem and then I try to connect through R: --- library(RMySQL) Loading required package: DBI m - dbDriver(MySQL) Error in new(MySQLDriver, Id = drvId) : unused argument(s) (Id ...) --- It still produces the error. I really do not know what is going on here... Then you do: library(RMySQL) m - dbDriver(MySQL) con - dbConnect(m, group = renpatch) q - TheSQLQuery rs - dbSendQuery(con, q) TheResults - fetch(rs, n = -1) dbDisconnect(con) rm(con) and it should work - at least that is what it is doing for me. Rainer Stephane. __ 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
[R] Monte carlo simulations
Dear professor, I want to have some examples of programm (programming under R), not the command only, but the code source, for the monte carlo simulations and MCMC method. with king regards. -- Dr. P. NGOM, Faculté des Sciences et Techniques Département de Mathématiques et Informatique Université Cheikh Anta Diop Dakar - Sénégal Universite Cheikh Anta DIOP - DAKAR __ 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
[R] reading a matrix from a file
Hello everyone, I'm writting a little script that will read a matrix from a file i.e. 0,.11,.22,.4 .11,0,.5,.3 .22,.5,0,.7 anb so on and will then calculate some standard stats for nets (i.e. centralization, degree, etc). So far I have opened the file and read the contents, however I' m using readLines(filename) to read the file and it returns it as one big String with no divitions. I tried using strsplit(String) to split it but eventhough is working I'm not able to put the output of the above into a matrix. Below is an example of what I have done INfile-file(mTest.txt, r) readLines(INfile)-matrix matrix [1] 1, 2, 3 strsplit(matrix, ,)-splitLine splitLine [[1]] [1] 1 2 3 netMatrix -matrix(c(splitLine), nrow=1,ncol=3) netMatrix [,1] [,2] [,3] [1,] Character,3 Character,3 Character,3 Does anyone have an idea how can I read a matrix and store it in the form of a matrix. thks -Cuau Vital - [[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
[R] significant test of Cross correlation coeficent
__ 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
Re: [R] Robustness of linear mixed models
Below... Hello, with 4 different linear mixed models (continuous dependent) I find that my residuals do not follow the normality assumption (significant Shapiro-Wilk with values equal/higher than 0.976; sample sizes 750 or 1200). I find, instead, that my residuals are really well fitted by a t distribution with dofs' ranging, in the different datasets, from 5 to 12. Should this be considered such a severe violation of the normality assumption as to make model-based inferences invalid? For some aspects, yes. Given that R provides you with the means to fit robust linear models, why not use them and find out if they make a difference to the aspects you are interested in? -- 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 Or do your inferences in a way that does not depend on normality, perhaps via (careful to honor the multilevel sampling assumptions) bootstrapping? Cautions apply. First, linear mixed models is actually a nonlinear modeling technique, as is robust linear fitting. So the process may be sensitive to initial values I believe this was pointed out to me by Professior Ripley, though in a different context. I would appreciate any more informed comments and qualifications about this. Second, both the normal theory inference and bootstrapping are asymptotic and therefore approximate. I believe this was the point Prof. Ripley was making when he said For **some** aspects... Comparing results under various assumptions is always a good idea to check sensitivity to those sets of assumptions, though it may emphasize the fact that choice of the right analysis may be a complex and application and data specific issue. Cheers, -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA __ 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
Re: [R] reading a matrix from a file
Dear Cuau More details on your posting would have helped. From your example it seems that the matrix you are trying to import is just a comma Separated text file. If that's the case, you can use read.csv and matrix to import those numbers and then make a matrix in R. Assuming the matrix has 3 rows and 4 columns you can do the following: x=read.csv(mymatrix.txt, header=FALSE) #Reads your file dim(x) #Tells you the dimensions of object x in rows and columns [1] 3 4 newMat= as.matrix(x) #Creates matrix from imported data is.matrix(newMat) #Tests whether the object newMat is of class matrix [1] TRUE I hope this helps Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Cuau [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] reading a matrix from a file Date: Tue, 27 Jun 2006 08:06:36 -0700 (PDT) Hello everyone, I'm writting a little script that will read a matrix from a file i.e. 0,.11,.22,.4 .11,0,.5,.3 .22,.5,0,.7 anb so on and will then calculate some standard stats for nets (i.e. centralization, degree, etc). So far I have opened the file and read the contents, however I' m using readLines(filename) to read the file and it returns it as one big String with no divitions. I tried using strsplit(String) to split it but eventhough is working I'm not able to put the output of the above into a matrix. Below is an example of what I have done INfile-file(mTest.txt, r) readLines(INfile)-matrix matrix [1] 1, 2, 3 strsplit(matrix, ,)-splitLine splitLine [[1]] [1] 1 2 3 netMatrix -matrix(c(splitLine), nrow=1,ncol=3) netMatrix [,1] [,2] [,3] [1,] Character,3 Character,3 Character,3 Does anyone have an idea how can I read a matrix and store it in the form of a matrix. thks -Cuau Vital - [[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 __ 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
Re: [R] reading a matrix from a file
Maybe this link is useful http://www.bic.mni.mcgill.ca/users/jason/cortex/stats-manuals/mni.read.glim.file.html Also, section 2.3 through http://cran.r-project.org/doc/manuals/R-data.html 2.3 Using scan directly Both read.table and read.fwf use scan to read the file, and then process the results of scan. They are very convenient, but sometimes it is better to use scan directly. Function scan has many arguments, most of which we have already covered under read.table. The most crucial argument is what, which specifies a list of modes of variables to be read from the file. If the list is named, the names are used for the components of the returned list. Modes can be numeric, character or complex, and are usually specified by an example, e.g. 0, or 0i. For example cat(2 3 5 7, 11 13 17 19, file=ex.dat, sep=\n) scan(file=ex.dat, what=list(x=0, y=, z=0), flush=TRUE) returns a list with three components and discards the fourth column in the file. There is a function readLines which will be more convenient if all you want is to read whole lines into R for further processing. One common use of scan is to read in a large matrix. Suppose file matrix.dat just contains the numbers for a 200 x 2000 matrix. Then we can use A - matrix(scan(matrix.dat, n = 200*2000), 200, 2000, byrow = TRUE) On one test this took 1 second (under Linux, 3 seconds under Windows on the same machine) whereas A - as.matrix(read.table(matrix.dat)) took 10 seconds (and more memory), and A - as.matrix(read.table(matrix.dat, header = FALSE, nrows = 200, comment.char = , colClasses = numeric)) took 7 seconds. The difference is almost entirely due to the overhead of reading 2000 separate short columns: were they of length 2000, scan took 9 seconds whereas read.table took 18 if used efficiently (in particular, specifying colClasses) and 125 if used naively. Note that timings can depend on the type read and the data. Consider reading a million distinct integers: writeLines(as.character((1+1e6):2e6), ints.dat) xi - scan(ints.dat, what=integer(0), n=1e6) # 0.77s xn - scan(ints.dat, what=numeric(0), n=1e6) # 0.93s xc - scan(ints.dat, what=character(0), n=1e6) # 0.85s xf - as.factor(xc) # 2.2s DF - read.table(ints.dat) # 4.5s and a million examples of a small set of codes: code - c(LMH, SJC, CHCH, SPC, SOM) writeLines(sample(code, 1e6, replace=TRUE), code.dat) y - scan(code.dat, what=character(0), n=1e6) # 0.44s yf - as.factor(y) # 0.21s DF - read.table(code.dat) # 4.9s DF - read.table(code.dat, nrows=1e6) # 3.6s Note that these timings depend heavily on the operating system (the basic reads in Windows take at least as twice as long as these Linux times) and on the precise state of the garbage collector. Hope this works. Z. He On 6/28/06, Cuau [EMAIL PROTECTED] wrote: Hello everyone, I'm writting a little script that will read a matrix from a file i.e. 0,.11,.22,.4 .11,0,.5,.3 .22,.5,0,.7 anb so on and will then calculate some standard stats for nets (i.e. centralization, degree, etc). So far I have opened the file and read the contents, however I' m using readLines(filename) to read the file and it returns it as one big String with no divitions. I tried using strsplit(String) to split it but eventhough is working I'm not able to put the output of the above into a matrix. Below is an example of what I have done INfile-file(mTest.txt, r) readLines(INfile)-matrix matrix [1] 1, 2, 3 strsplit(matrix, ,)-splitLine splitLine [[1]] [1] 1 2 3 netMatrix -matrix(c(splitLine), nrow=1,ncol=3) netMatrix [,1] [,2] [,3] [1,] Character,3 Character,3 Character,3 Does anyone have an idea how can I read a matrix and store it in the form of a matrix. thks -Cuau Vital - [[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 -- Zhuanshi He / Z. He (PhD) ADvanced Environmental Monitoring Research Center (ADEMRC) Gwangju Institute of Science and Technology 1 Oryong-dong, Buk-gu, Gwangju 500-712, Republic of Korea. Tel. +82-62-970-3406 Fax. +82-62-970-3404 Email: [EMAIL PROTECTED] Web: http://atm1.gist.ac.kr/~hzs/ __ 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
Re: [R] reading a matrix from a file
Maybe this link is useful http://www.bic.mni.mcgill.ca/users/jason/cortex/stats-manuals/mni.read.glim.file.html Also, section 2.3 through http://cran.r-project.org/doc/manuals/R-data.html 2.3 Using scan directly Both read.table and read.fwf use scan to read the file, and then process the results of scan. They are very convenient, but sometimes it is better to use scan directly. Function scan has many arguments, most of which we have already covered under read.table. The most crucial argument is what, which specifies a list of modes of variables to be read from the file. If the list is named, the names are used for the components of the returned list. Modes can be numeric, character or complex, and are usually specified by an example, e.g. 0, or 0i. For example cat(2 3 5 7, 11 13 17 19, file=ex.dat, sep=\n) scan(file=ex.dat, what=list(x=0, y=, z=0), flush=TRUE) returns a list with three components and discards the fourth column in the file. There is a function readLines which will be more convenient if all you want is to read whole lines into R for further processing. One common use of scan is to read in a large matrix. Suppose file matrix.dat just contains the numbers for a 200 x 2000 matrix. Then we can use A - matrix(scan(matrix.dat, n = 200*2000), 200, 2000, byrow = TRUE) On one test this took 1 second (under Linux, 3 seconds under Windows on the same machine) whereas A - as.matrix(read.table(matrix.dat)) took 10 seconds (and more memory), and A - as.matrix(read.table(matrix.dat, header = FALSE, nrows = 200, comment.char = , colClasses = numeric)) took 7 seconds. The difference is almost entirely due to the overhead of reading 2000 separate short columns: were they of length 2000, scan took 9 seconds whereas read.table took 18 if used efficiently (in particular, specifying colClasses) and 125 if used naively. Note that timings can depend on the type read and the data. Consider reading a million distinct integers: writeLines(as.character((1+1e6):2e6), ints.dat) xi - scan(ints.dat, what=integer(0), n=1e6) # 0.77s xn - scan(ints.dat, what=numeric(0), n=1e6) # 0.93s xc - scan(ints.dat, what=character(0), n=1e6) # 0.85s xf - as.factor(xc) # 2.2s DF - read.table(ints.dat) # 4.5s and a million examples of a small set of codes: code - c(LMH, SJC, CHCH, SPC, SOM) writeLines(sample(code, 1e6, replace=TRUE), code.dat) y - scan(code.dat, what=character(0), n=1e6) # 0.44s yf - as.factor(y) # 0.21s DF - read.table(code.dat) # 4.9s DF - read.table(code.dat, nrows=1e6) # 3.6s Note that these timings depend heavily on the operating system (the basic reads in Windows take at least as twice as long as these Linux times) and on the precise state of the garbage collector. Hope this works. Z. He On 6/28/06, Cuau [EMAIL PROTECTED] wrote: Hello everyone, I'm writting a little script that will read a matrix from a file i.e. 0,.11,.22,.4 .11,0,.5,.3 .22,.5,0,.7 anb so on and will then calculate some standard stats for nets (i.e. centralization, degree, etc). So far I have opened the file and read the contents, however I' m using readLines(filename) to read the file and it returns it as one big String with no divitions. I tried using strsplit(String) to split it but eventhough is working I'm not able to put the output of the above into a matrix. Below is an example of what I have done INfile-file(mTest.txt, r) readLines(INfile)-matrix matrix [1] 1, 2, 3 strsplit(matrix, ,)-splitLine splitLine [[1]] [1] 1 2 3 netMatrix -matrix(c(splitLine), nrow=1,ncol=3) netMatrix [,1] [,2] [,3] [1,] Character,3 Character,3 Character,3 Does anyone have an idea how can I read a matrix and store it in the form of a matrix. thks -Cuau Vital - [[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 -- Zhuanshi He / Z. He (PhD) ADvanced Environmental Monitoring Research Center (ADEMRC) Gwangju Institute of Science and Technology 1 Oryong-dong, Buk-gu, Gwangju 500-712, Republic of Korea. Tel. +82-62-970-3406 Fax. +82-62-970-3404 Email: [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] Web: http://atm1.gist.ac.kr/~hzs/ BBS: http://atm1.gist.ac.kr/~hzs/phpBB2/ __ 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
Re: [R] Survival
On 6/27/06, Michela Ballardini [EMAIL PROTECTED] wrote: Dear all, I write to know if it possible to know the number of censor subject in function of time. I run: os-survfit(Surv(datios$time,datios$status)) summary(os) but it give me only the nomber of events. Can you help me? Well, if you know the number of events, you can find the number of censored observations by subtracting the number of events from the number of observations. If you want complete statistics from all risksets (at event times), consider the function 'risksets' in the package 'eha'. Göran Thanke you Michela ** Dr.ssa Michela Ballardini Unità di Biostatistica e Sperimentazioni Cliniche c/o Osp. Morgagni-Pierantoni - Pad. Valsalva Via Forlanini, 34 47100 Forlì Tel 0543-731836 Tel/Fax 0543-731612 ** [[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 -- Göran Broström __ 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
[R] how to rotate a triangle image(ZMAT) ?
Hello R users... how to align this Zmat (triangle image) in X axis? I would like that the triangle's base become in the X axis and the triangle's height become in the Y axis Is there some trick for make this? Thanks. Cleber my test and try f - function(x,y){ z=1-x-y z[ z (-1e-15) ] - NA return( -100*x+0*y+100*z ) } x = seq( 1, 0, by = -0.01 ) y = seq( 1, 0, by = -0.01 ) zmat = outer(x,y,f) image(zmat, col=terrain.colors(10)) contour(zmat, add=T) __ 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
[R] Random numbers negatively correlated?
Dear list, I did simulations in which I generated 1 independent Bernoulli(0.5)-sequences of length 100. I estimated p for each sequence and I also estimated the conditional probability that a one is followed by another one (which should be p as well). However, the second probability is significantly smaller than 0.5 (namely about 0.494, see below) and of course smaller than the direct estimates of p as well, indicating negative correlation between the random numbers. See below the code and the results. Did I do something wrong or are the numbers in fact negatively correlated? (A type I error is quite unlikely with a p-value below 2.2e-16.) Best, Christian set.seed(123456) n - 100 p - 0.5 simruns - 1 est - est11 - numeric(0) for (i in 1:simruns){ #if (i/100==round(i/100)) print(i) x - rbinom(n,1,p) est[i] - mean(x) x11 - 3*x[2:n]-x[1:(n-1)] est11[i] - sum(x11==2)/sum(x11==2 | x11==(-1)) # x11==(-1): 0 follows 1, x11==2: 1 follows 1. } print(mean(est)) [1] 0.499554 print(sd(est)/sqrt(simruns)) [1] 0.0004958232 # OK print(mean(est11)) [1] 0.4935211 print(sd(est11)/sqrt(simruns)) [1] 0.0007136213 # mean(est11)+2*sd(mean) 0.495 print(sum(estest11)) [1] 5575 binom.test(5575,1) Exact binomial test data: 5575 and 1 number of successes = 5575, number of trials = 1, p-value 2.2e-16 *** --- *** Christian Hennig University College London, Department of Statistical Science Gower St., London WC1E 6BT, phone +44 207 679 1698 [EMAIL PROTECTED], www.homepages.ucl.ac.uk/~ucakche __ 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
Re: [R] Random numbers negatively correlated?
On Tue, 27 Jun 2006, Christian Hennig wrote: Dear list, I did simulations in which I generated 1 independent Bernoulli(0.5)-sequences of length 100. I estimated p for each sequence and I also estimated the conditional probability that a one is followed by another one (which should be p as well). However, the second probability is significantly smaller than 0.5 (namely about 0.494, see below) and of course smaller than the direct estimates of p as well, indicating negative correlation between the random numbers. See below the code and the results. Did I do something wrong or are the numbers in fact negatively correlated? (A type I error is quite unlikely with a p-value below 2.2e-16.) I think you did something wrong, and that there is a problem with overlapping blocks of two. If you do x-matrix(rbinom(1e6,1,p),ncol=2) tt-table(x[,1],x[,2]) you get much better looking results. In this case you have 500,000 independent pairs of numbers that can be 01, 10, 11, 00. A test for independence seems fine. tt 0 1 0 125246 124814 1 125140 124800 fisher.test(tt) Fisher's Exact Test for Count Data data: tt p-value = 0.8987 alternative hypothesis: true odds ratio is not equal to 1 95 percent confidence interval: 0.9896745 1.0119211 sample estimates: odds ratio 1.000735 In your case the deficit in est11 is suspiciously close to 0.5/n. Changing n to 1000 and using the same seed I get mean(est11)-0.5 [1] -0.0005534743 10 times smaller, and still close to 0.5/n. Now, consider what happens in a case where we can see all the possibilities, n=3 x1/0 1/1 000 - - 001 - - 010 1 0 011 0 1 100 1 0 101 1 0 110 1 1 111 2 0 So that if each of these three triplets has the same probability your est11 would be 2/8 rather than 4/8, and est11 is not an unbiased estimate of the long-run conditional probability. The bias is of order 1/n, so you need n to be of larger order than sqrt(simruns). -thomas __ 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
Re: [R] Random numbers negatively correlated?
On Tue, 27 Jun 2006, Thomas Lumley wrote: I got the table wrong, it should read x1/0 1/1 est11 000 - - - 001 - - - 010 1 0 0 011 0 1 1 100 1 0 0 101 1 0 0 110 1 1 0.5 111 0 2 1 So the explanation is slightly more complicated. The problem is that although sum(x11==2)/n and sum(x11==2 | x11==(-1))/n are unbiased estimators their ratio is not an unbiased estimator, but has mean 5/12 (which is 0.5-0.5/n). -thomas __ 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
Re: [R] compare odds ratios
Hi dear all, I haven't heard any suggestions on how to tackle the problem in my previous email yet. I searched on google and was not getting any useful information yet. I did get someone from google groups suggesting Cockran Mantel Haenszel test with each subject as the stratum. But as far as I understand, CMH test is to test whether the common odds ratio (assuming odds ratios across stratum are equal) is equal to 1, not really the question I was asking which was whether the 2 odds ratios were equal (doesn't matter if they are equal to 1). Also, someone suggested loglinear regression, but I am not sure either how to set things up for my problem. One clarification to my original email: the 2 diagnostic tests were performed on the set set of patients, the issue here how to test whether the 2 odds ratios for the 2 diagnostic tests are equal. Here is a hypothetical dataset, for example: dat-cbind(disease=sample(c(rep(1,15),rep(0,20))),test1=sample(c(rep(1,11),rep(0,24))),test2=sample(c(rep(1,14),rep(0,21 Hope some statistical experts would guide me some directions. Many thanks --- array chip [EMAIL PROTECTED] wrote: Hi there, is there any way to compare 2 odds ratios? I have two tests that are supposed to detect a disease presence. So for each test, I can compute an odds ratio. My problem is how can I compare the 2 tests by testing whether the 2 odds ratios are the same? Appreciate __ 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 __ 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
[R] rotate text using mtext
Hello, I wish to write a label to the right-hand side of a plot (side=4) using mtext, with the text facing inwards - that is, rotated 180 degrees from the default orientation. How might I do this? (I've tried experimenting with las but no luck.) Thanks, Rashmi Rashmi Mathur Master's Candidate Fisheries Science and Management Research Group School of Resource and Environmental Management (REM) Simon Fraser University Burnaby, BC [EMAIL PROTECTED] http://www.rem.sfu.ca/fishgrp __ 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
[R] distribution of daily rainfall values in binned categories
Hi, I'm a newbie in using R and I would like to have a few clues as to how I could compute and plot a distribution of daily rainfall intensity in different categories. I have daily values (mm/day) for several years and I need to show the frequency of 0-1, 1-2.5, 2.5-5, 5-10, 10-20, 20+ mm/day. Can this be done easily? Thanks, Etienne __ 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
[R] Reading a set of values from a numeric matrix
Dear group, I have a matrix with (190,2) dimensions. The values range from : -973.8149 to 807.4688 I want to select the values less than -200 and want to know what are the names of row and columns. m1 m2 m3 m4 .. mn k1 k2 k3 k4 . . . kj mymat[1:4,1:4] 1-Dec 1-Mar 1-Sep 10-Sep m1 -0.4220701 -0.94359666 -421.06729 -1.8525286 m2 0.4408303 -250.706960 0.6422206 0.6344322 m3 0.4005077 -430.076784 1.3653584 0.4677905 m4 5.0358915 6.40544709 -430.67964 3.2017410 I want to select the pairs: m2 1-Mar -250.706960 m3 1-Mar -430.076784 m1 1-Sep -421.06729 m4 1-Sep -430.67964 How can I do it. Could any one help me out. Please. Thanks sri __ 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
[R] Possible to get a definition of a function from a package to use without invoking the package?
Hi, I often use the mod() and instring() functions that are available in the clim.pact package. This package has a lot of dependencies, including installation of netCDF, and I haven't yet been able to get library(clim.pact) to work on a Mac OS 10.4.6. A previous request for help with the Mac problem yielded no results, so now I wonder if I could just extract the definitions for the couple of functions that I need and save them in my own file of R functions. I'm pretty sure that mod() and instring() are very basic and don't have any exotic dependencies. I did find an alternative mod() in the new matlab package, and that's fine. Now I just need another way to get the instring() functionality. Thanks, Scott Waichler Pacific Northwest National Laboratory scott.waichler _at_ pnl.gov __ 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
[R] Outliers and robust methods
Hi folks! I need to build a binary dependent variable model, but my independent variables have some serious outliers (they are not data errors.) I was thinking of using the robustbase package because I noticed one of the functions accepts a binary depvar. Can I evaluate this model like any other? Could anyone recommend a primer on robust methods? I really, really, hate to adjust my raw data for outliers first and then estimate my model! Thanks. Best, john [[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
Re: [R] Reading a set of values from a numeric matrix
See: http://thread.gmane.org/gmane.comp.lang.r.general/64473/focus=64487 On 6/27/06, Srinivas Iyyer [EMAIL PROTECTED] wrote: Dear group, I have a matrix with (190,2) dimensions. The values range from : -973.8149 to 807.4688 I want to select the values less than -200 and want to know what are the names of row and columns. m1 m2 m3 m4 .. mn k1 k2 k3 k4 . . . kj mymat[1:4,1:4] 1-Dec 1-Mar 1-Sep 10-Sep m1 -0.4220701 -0.94359666 -421.06729 -1.8525286 m2 0.4408303 -250.706960 0.6422206 0.6344322 m3 0.4005077 -430.076784 1.3653584 0.4677905 m4 5.0358915 6.40544709 -430.67964 3.2017410 I want to select the pairs: m2 1-Mar -250.706960 m3 1-Mar -430.076784 m1 1-Sep -421.06729 m4 1-Sep -430.67964 How can I do it. Could any one help me out. Please. Thanks sri __ 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 __ 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
Re: [R] Possible to get a definition of a function from a package to use without invoking the package?
You should be able to download the source package from CRAN and copy the code for the 'instring()' function into your own source file. -roger Waichler, Scott R wrote: Hi, I often use the mod() and instring() functions that are available in the clim.pact package. This package has a lot of dependencies, including installation of netCDF, and I haven't yet been able to get library(clim.pact) to work on a Mac OS 10.4.6. A previous request for help with the Mac problem yielded no results, so now I wonder if I could just extract the definitions for the couple of functions that I need and save them in my own file of R functions. I'm pretty sure that mod() and instring() are very basic and don't have any exotic dependencies. I did find an alternative mod() in the new matlab package, and that's fine. Now I just need another way to get the instring() functionality. Thanks, Scott Waichler Pacific Northwest National Laboratory scott.waichler _at_ pnl.gov __ 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 -- Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/ __ 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
Re: [R] Possible to get a definition of a function from a package to use without invoking the package?
On 6/27/2006 2:55 PM, Waichler, Scott R wrote: Hi, I often use the mod() and instring() functions that are available in the clim.pact package. This package has a lot of dependencies, including installation of netCDF, and I haven't yet been able to get library(clim.pact) to work on a Mac OS 10.4.6. A previous request for help with the Mac problem yielded no results, so now I wonder if I could just extract the definitions for the couple of functions that I need and save them in my own file of R functions. I'm not sure what you mean by this question. Technically you can do that. Legally you can do it because clim.pact is GPL'd. It's a slightly rude thing to do if you end up redistributing the functions, so I'd check with the author first. It may cause you weird problems in the future if you decide to use both your functions and clim.pact at the same time, especially if one of them has mutated in the meantime. I'd suggest the best approach is to work with the clim.pact author to get that package working on your platform. By the way, mod() is available as a basic R operator, namely %%. It provides different results in some cases, e.g. -5 %% 2 [1] 1 mod(-5, 2) [1] -1 so be careful about your definitions. I don't know a simple substitute for instring(). Duncan Murdoch I'm pretty sure that mod() and instring() are very basic and don't have any exotic dependencies. I did find an alternative mod() in the new matlab package, and that's fine. Now I just need another way to get the instring() functionality. Thanks, Scott Waichler Pacific Northwest National Laboratory scott.waichler _at_ pnl.gov __ 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 __ 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
Re: [R] Possible to get a definition of a function from a package to use without invoking the package?
You can use %% instead of mod, e.g. 12 %% 5 see ?%% You can use unlist(gregexpr(pat, string, fixed = TRUE)) instead of instring(pat, string). If you just want the first occurrence use regexpr instead of gregexpr. On 6/27/06, Waichler, Scott R [EMAIL PROTECTED] wrote: Hi, I often use the mod() and instring() functions that are available in the clim.pact package. This package has a lot of dependencies, including installation of netCDF, and I haven't yet been able to get library(clim.pact) to work on a Mac OS 10.4.6. A previous request for help with the Mac problem yielded no results, so now I wonder if I could just extract the definitions for the couple of functions that I need and save them in my own file of R functions. I'm pretty sure that mod() and instring() are very basic and don't have any exotic dependencies. I did find an alternative mod() in the new matlab package, and that's fine. Now I just need another way to get the instring() functionality. Thanks, Scott Waichler Pacific Northwest National Laboratory scott.waichler _at_ pnl.gov __ 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 __ 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
Re: [R] rotate text using mtext
Rashmi Mathur wrote: Hello, I wish to write a label to the right-hand side of a plot (side=4) using mtext, with the text facing inwards - that is, rotated 180 degrees from the default orientation. How might I do this? (I've tried experimenting with las but no luck.) Use text() instead. I'm not sure how you want the label oriented, but this should get you started: df - data.frame(cbind(1:10, 11:20)) names(df) - c(y,x) par(mar = c(7, 7, 7, 10)) plot(y ~ x, data = df, ylab = , xlab = independent) text(par(usr)[2] + 0.25, 5.5, srt=-45, adj = 0, labels = dependent, xpd = TRUE) Thanks, Rashmi Rashmi Mathur Master's Candidate Fisheries Science and Management Research Group School of Resource and Environmental Management (REM) Simon Fraser University Burnaby, BC [EMAIL PROTECTED] http://www.rem.sfu.ca/fishgrp __ 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 -- 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 __ 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
Re: [R] distribution of daily rainfall values in binned categories
?hist read about breaks On 6/27/06, etienne [EMAIL PROTECTED] wrote: Hi, I'm a newbie in using R and I would like to have a few clues as to how I could compute and plot a distribution of daily rainfall intensity in different categories. I have daily values (mm/day) for several years and I need to show the frequency of 0-1, 1-2.5, 2.5-5, 5-10, 10-20, 20+ mm/day. Can this be done easily? Thanks, Etienne __ 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 -- HTH, Jim Porzak Loyalty Matrix Inc. San Francisco, 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
[R] supplying dynamic main argument to plot?
All, Simple question but I don't seem to be able to find the answer in the documentation: When using plot within a loop, is there any way to supply the argument to main dynamically, i.e., so that the title is Patient k below as the loop cycles through each value of k? plot(x,y, xlim=c(0,250), ylim=c(0,1000), xlab=gamma, ylab=r1, main=Patient k) thanks dave ps - I'm running windows. [[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
[R] Mixing grid and base graphics--need help understanding this quirk
My setup: Windows 2000, R 2.3.1 When I start a brand new session of R and paste the code below into R, the graphic device shows Some text in the lower left corner. If I paste the code into the command window again, then Some text does not appear in the lower left corner. Why is this? require(grid) par(mfrow=c(1,2)) plot(1:10) plot(-10:1) par(mfrow=c(1,1)) pushViewport(viewport(.04, .04, width=stringWidth(Some text), height=unit(2,lines), name=pagenum, gp=gpar(fontsize=10))) grid.text(Some text, gp=gpar(col=gray30), just=c(left,bottom)) popViewport() Kevin Wright __ 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
[R] Passing argument to a function called within another function
#Test at command line getQuery(name='John') This should give the result- select * from table_name where name='John' Instead, it gives- select * from table_name where = ' name = 'John' The reason is because in function call queryGenerator$generateQuery(passed) from within getQuery(), passed is a character vector so the function generateQuery() treats the whole thing as one argument value i.e. as args[[1]]. What can I do solve this problem? Thanks. I appreciate any help. File QueryGenerator.R --- #Constructor for QueryGenerator setConstructorS3(QueryGenerator, function() { extend(Object(), QueryGenerator) }) # Called when print(object) or object$print is called setMethodS3(as.character, QueryGenerator, function(this) { paste(This is a QueryGenerator object.) }) # getData function generates the SQL query setMethodS3(generateQuery, QueryGenerator, function(this,...) { args - list(...) sql - select * from table_name where for(i in 1:length(args)) { if(is.numeric(args[[i]])) { sql = paste(sql, names(args[i]), =, args[[i]], collapse = ) } else if(is.character(args[[i]])) { sql = paste(sql, names(args[i]), =, sQuote(args[[i]]), collapse = ) } # If in the current iteration args is not the last argument # add and keyword if(!identical(i, length(args))) { if(identical(names(args[i]),names(args[i + 1]))) sql = paste(sql, or, collapse = ) else sql = paste(sql, and, collapse = ) } cat(\nIntermediate Queries\n) cat(sql) } cat(\n\nFinal query\n) cat(sql) cat(\n) return(sql) }) File getQuery.R -- getQuery - function(...) { args - list(...) #Create the argument to be passed to generateQuery passed - sub(,, , paste(rbind(,, names(args), =, sQuote(args)), collapse = )) #Create the QueryGenerator Object queryGenerator - QueryGenerator() #Call getData() of DataRetriever class. results - queryGenerator$generateQuery(passed) } __ 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
Re: [R] supplying dynamic main argument to plot?
It is easy to control the main title with plot, but you will get much better looking plots if you use xyplot. library(lattice) tmp - data.frame(x=rnorm(100), y=rnorm(100,4,2), ID=paste(Patient, rep(1:5, rep(20,5 xyplot(y ~ x | ID, data=tmp) Rich __ 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
Re: [R] RMySQL...Can't initialize driver???
This looks very suspicious. The function mysqlInitDriver is pretty straight forward (see below), but the error you're reporting apparently has something to do with S4 dispatching: mysqlInitDriver function (max.con = 16, fetch.default.rec = 500, force.reload = FALSE) { if (fetch.default.rec = 0) stop(default num of records per fetch must be positive) config.params - as.integer(c(max.con, fetch.default.rec)) force - as.logical(force.reload) drvId - .Call(RS_MySQL_init, config.params, force, PACKAGE = .MySQLPkgName) new(MySQLDriver, Id = drvId) } Could you send me the output of R --vanilla library(RMySQL) search() ## ask R to put you in a browser in case of errors options(error = recover) con - MySQL(max.con = 10, fetch.default.rec=500, force.reload = F) when you encounter the error, you'll be prompted with Enter a frame number, or 0 to exit type 2 (or the number for the call to mysqlInitDriver(max.con = ...)) and then find out what class of object is drvId (it should be integer). Browser[1] class(drvId) Regards, -- David Stephane Cruveiller wrote: Rainer M Krug wrote: Stephane Cruveiller wrote: Duncan Murdoch wrote: On 6/27/2006 8:51 AM, Stephane Cruveiller wrote: Dear R users, I would like to query a MySQL database through R. I have installed the latest required packages (RMySQL and DBI) in R (v2.3.1). A MySQL server (v5.0.22) is running on my local machine but I can't initialize MYSQL driver: library(RMySQL) Loading required package: DBI MySQL(max.con = 10, fetch.default.rec = 500, force.reload = F) Error in new(MySQLDriver, Id = drvId) : unused argument(s) (Id ...) - Could somebody tell me what I have missed? I am running R 2.3.0 under Linux and connect to a MySQl 4.1 server. You have to create a file in your home directory which has the connection infos. It should look like that: [renpatch] user = UserName password = PassWord database = ... host = ... [renpatch_renosterbos] user = UserName password = PassWord database = ... host = .. and be called .my.conf I followed your instruction. Here is my .my.cnf: --- [client] user=steff password=XX database=justforfun --- with it, I can connect to my MYSQL server without problem and then I try to connect through R: --- library(RMySQL) Loading required package: DBI m - dbDriver(MySQL) Error in new(MySQLDriver, Id = drvId) : unused argument(s) (Id ...) --- It still produces the error. I really do not know what is going on here... Then you do: library(RMySQL) m - dbDriver(MySQL) con - dbConnect(m, group = renpatch) q - TheSQLQuery rs - dbSendQuery(con, q) TheResults - fetch(rs, n = -1) dbDisconnect(con) rm(con) and it should work - at least that is what it is doing for me. Rainer Stephane. __ 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 __ 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
Re: [R] supplying dynamic main argument to plot?
Hi Dave, Try using paste within main i.e. x=rnorm(100) y=runif(100) k=sample(1:10,10, replace=T) for(i in k){ plot(x,y, xlab=gamma, ylab=r1, main=paste(Patient, i, sep= )) Sys.sleep(1) } In this eaxmple I am just plotting the same x,y values on each figure but you can easily plot the observations for each patient by subetting your data by the K variable. See ?[ for more details on subsetting. I hope this helps Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: Afshartous, David [EMAIL PROTECTED] To: Afshartous, David [EMAIL PROTECTED], r-help@stat.math.ethz.ch Subject: [R] supplying dynamic main argument to plot? Date: Tue, 27 Jun 2006 16:19:12 -0400 All, Simple question but I don't seem to be able to find the answer in the documentation: When using plot within a loop, is there any way to supply the argument to main dynamically, i.e., so that the title is Patient k below as the loop cycles through each value of k? plot(x,y, xlim=c(0,250), ylim=c(0,1000), xlab=gamma, ylab=r1, main=Patient k) thanks dave ps - I'm running windows. [[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 __ 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
[R] comparing 2 odds ratios
Hi, you can have a look at fourfold() and oddratio() in package vcd. Best, David Hi there, is there any way to compare 2 odds ratios? I have two tests that are supposed to detect a disease presence. So for each test, I can compute an odds ratio. My problem is how can I compare the 2 tests by testing whether the 2 odds ratios are the same? -- Dr. David Meyer Department of Information Systems and Operations Vienna University of Economics and Business Administration Augasse 2-6, A-1090 Wien, Austria, Europe Tel: +43-1-313 36 4393 Fax: +43-1-313 36 90 4393 HP: http://wi.wu-wien.ac.at/~meyer/ __ 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
[R] Robustness of linear mixed models
I'd use mcmcsamp() to examine the posterior distribution, under a relatively uninformative prior, of of the parameter estimates. For estimates that are based on four or five or more degrees of freedom, I'd surmise that the prior will not matter too much. With estimates where the number of degrees of freedom is one or two or three, the posterior distribution may vary greatly from one run of mcmcsamp() to another. Of course, the definition of degrees of freedom becomes quite fraught if there is severe imbalance; e.g., some of the items that contribute to the estimate based on much more data than others. Subject to such caveats as just noted, I'd expect that credible intervals derived from the posterior distributions would be close to the usual frequentist confidence intervals. The main effect of the non-normality may be that the estimates are inefficient, i.e., the variance may be larger, or the distributions more dispersed, than for true maximum likelihood estimates, were you able to obtain them! John Maindonald John Maindonald email: [EMAIL PROTECTED] phone : +61 2 (6125)3473fax : +61 2(6125)5549 Mathematical Sciences Institute, Room 1194, John Dedman Mathematical Sciences Building (Building 27) Australian National University, Canberra ACT 0200. On 27 Jun 2006, at 8:00 PM, [EMAIL PROTECTED] wrote: From: Bruno L. Giordano [EMAIL PROTECTED] Date: 27 June 2006 11:21:25 AM To: r-help@stat.math.ethz.ch Subject: [R] Robustness of linear mixed models Hello, with 4 different linear mixed models (continuous dependent) I find that my residuals do not follow the normality assumption (significant Shapiro-Wilk with values equal/higher than 0.976; sample sizes 750 or 1200). I find, instead, that my residuals are really well fitted by a t distribution with dofs' ranging, in the different datasets, from 5 to 12. Should this be considered such a severe violation of the normality assumption as to make model-based inferences invalid? Thanks a lot, Bruno [[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
Re: [R] how to rotate a triangle image(ZMAT) ?
[Cleber N.Borges] how to align this Zmat (triangle image) in X axis? I would like that the triangle's base become in the X axis and the triangle's height become in the Y axis. Is there some trick for make this? I'm not fully sure of what is the base and the height of the triangle, but if I guess correctly, you may peek at ?image, the last paragraph of the Details: section, and also in the Examples: section, where it says Need to transpose and flip matrix horizontally.. Maybe you'll find some explanations or ideas in there. f - function(x, y) { z = 1-x-y z[z (-1e-15)] - NA return(-100*x+0*y+100*z) } x = seq(1, 0, by = -0.01) y = seq(1, 0, by = -0.01) zmat = outer(x, y, f) image(zmat, col=terrain.colors(10)) contour(zmat, add=T) Another idea is to exchange x, y in the outer call, and maybe also use rev() on one of them. -- François Pinard http://pinard.progiciels-bpi.ca __ 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
Re: [R] how to rotate a triangle image(ZMAT) ?
I thank François Pinard for your attention one solution, but very dirty very ugly and ~ 30% of calculations cut loose! if somebody can give a tip, I thank... Cleber f - function(x,y){ z=1-x-y z[ z (-1e-15) ] - NA return( -100*x + 0*y + 100*z ) } x = y = seq( 1, 0, by = -0.01 ) z = outer(x,y,f) t1 = length(x) aux = numeric(0) im = numeric(0) for( i in seq( 1, t1, by = 2 ) ){ idx = seq( i*t1, t1**2, by = t1 ) - (0:(t1 - i)) im = c(im, aux, z[idx], aux ) aux = c(aux, NA) } im = matrix(im,nr=t1) image(im, col=terrain.colors(256)) contour(im, add=T) __ 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
[R] the plot of parametric model curve
Hi All, I use survreg to fit the parametric survival model, but I hope to get the plot of the parametric fitting. Could you please help me which command in R can get that? Thank you! [[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
[R] hopefully my last question on lapply
Marc and many other people ( whose names escape me ) have been very helpful in explaining the use of lapply to me. In his last response, Marc explained that if tradevectors is a list of vectors of different lengths ( excuse my terminology ) then lapply(tradevectors,function(x) G[x]*B[x] ) will go through each component of the list as if it was a vector and apply the element by element multiplication of G and B, ( G and B are vectors ) Then, it again returns a list of vectors. This is fine and I understand it. What I find confusing is that sometimes I want to take the two vectors G abd B and send them totally into some function with the respective indices from tradevectors not just the element by element index. For example, suppose I have a function called myfunction that takes two vectors as its inputs. Then, here are my ideas for what could be done. Attempt 1 : lapply(tradevectors,function(i) myfunction(G[i],B[i]) Attempt 2 : lapply(along=tradevectors),function(i) myfunction(G[[i]],B[[i]] In attempt1, I am just putting tradevectors and indexing using the [] which I think won't work. In attemp t2, I am using along=tradevectors and using [[]]. I think # 2 is correct but could someone confirm this because I have quite large vectors and it's not easy at all for me to check what's going on and I'm not so clear with lapply usage. There's seem tobe many different ways of setting up the first parameter in the call to lapply. Thanks __ 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
[R] installing R on RedHat
Dear R People: Yet again, I am attempting to install R on RedHat Linux. Here is my sorry attempt to date: [EMAIL PROTECTED] hodgess]$ rpm -vi R.rpm warning: R.rpm: V3 DSA signature: NOKEY, key ID 97d3544e error: cannot write to %sourcedir /usr/src/redhat/SOURCES I only want to write it to my own userid, since I am the only one who uses it. Any suggestions would be much appreciated. Thanks, Sincerely, Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [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
Re: [R] hopefully my last question on lapply
On Tue, 2006-06-27 at 21:12 -0500, [EMAIL PROTECTED] wrote: Marc and many other people ( whose names escape me ) have been very helpful in explaining the use of lapply to me. In his last response, Marc explained that if tradevectors is a list of vectors of different lengths ( excuse my terminology ) then lapply(tradevectors,function(x) G[x]*B[x] ) will go through each component of the list as if it was a vector and apply the element by element multiplication of G and B, ( G and B are vectors ) Then, it again returns a list of vectors. This is fine and I understand it. What I find confusing is that sometimes I want to take the two vectors G abd B and send them totally into some function with the respective indices from tradevectors not just the element by element index. For example, suppose I have a function called myfunction that takes two vectors as its inputs. Then, here are my ideas for what could be done. Attempt 1 : lapply(tradevectors,function(i) myfunction(G[i],B[i]) Attempt 2 : lapply(along=tradevectors),function(i) myfunction(G[[i]],B[[i]] In attempt1, I am just putting tradevectors and indexing using the [] which I think won't work. In attemp t2, I am using along=tradevectors and using [[]]. I think # 2 is correct but could someone confirm this because I have quite large vectors and it's not easy at all for me to check what's going on and I'm not so clear with lapply usage. There's seem tobe many different ways of setting up the first parameter in the call to lapply. Mark, My presumption is that you want to pass the subsetted vectors G and B to myfunction() during each iteration along the list 'tradevectors' and then perform some more complex operation on them. Is that correct? If so, then I think that you are misunderstanding what is happening in lapply(), when you use: lapply(tradevectors,function(i) myfunction(G[i], B[i])) In this case, it is not the individual elements of G and B that are passed to myfunction() one pair at a time, but the entire subsetted G[i] and B[i] that are passed. The vector subsetting takes place BEFORE the vectors are passed to myfunction(). Thus, for example, let's use the original data that we have been working with here: tempa - c(4, 6, 10) tempb - c(11, 23, 39) tradevectors - mapply(seq, from = tempa, to = tempb) X - seq(2, 80, 2) Y - 1:40 # myfunction() will take x and y, cbind() them, # print the result and then return a NULL to lapply # So for each iteration in lapply, the cbind/print will be # executed once. myfunction - function(x, y) { print(cbind(x, y)) NULL } lapply(tradevectors,function(i) myfunction(X[i], Y[i])) x y [1,] 8 4 [2,] 10 5 [3,] 12 6 [4,] 14 7 [5,] 16 8 [6,] 18 9 [7,] 20 10 [8,] 22 11 x y [1,] 12 6 [2,] 14 7 [3,] 16 8 [4,] 18 9 [5,] 20 10 [6,] 22 11 [7,] 24 12 [8,] 26 13 [9,] 28 14 [10,] 30 15 [11,] 32 16 [12,] 34 17 [13,] 36 18 [14,] 38 19 [15,] 40 20 [16,] 42 21 [17,] 44 22 [18,] 46 23 x y [1,] 20 10 [2,] 22 11 [3,] 24 12 [4,] 26 13 [5,] 28 14 [6,] 30 15 [7,] 32 16 [8,] 34 17 [9,] 36 18 [10,] 38 19 [11,] 40 20 [12,] 42 21 [13,] 44 22 [14,] 46 23 [15,] 48 24 [16,] 50 25 [17,] 52 26 [18,] 54 27 [19,] 56 28 [20,] 58 29 [21,] 60 30 [22,] 62 31 [23,] 64 32 [24,] 66 33 [25,] 68 34 [26,] 70 35 [27,] 72 36 [28,] 74 37 [29,] 76 38 [30,] 78 39 [[1]] NULL [[2]] NULL [[3]] NULL Note that for each of the three iterations through tradevectors in lapply(), myfunction() prints out a multi-row matrix consisting of the subsetted vectors X and Y, using the indices provided in tradevectors. The three final NULLs are then returned once lapply() has finished. In addition, note that this behavior is different than mapply(), where each argument in mapply() is passed in an element-by-element fashion to the function indicated as the first argument. That is the behavior that we are using above to create the sequences that become tradevectors. In that case, each element of tempa and tempb, in sequence, are passed one at a time as a single pair to seq(). That occurs three times. HTH, Marc Schwartz __ 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
Re: [R] distribution of daily rainfall values in binned categories
Hi Etienne, Somebody asked a somehow related question recently. http://tolstoy.newcastle.edu.au/R/help/06/06/29485.html Take a look at cut? table? and barplot? i.e. #Creates fake data from uniform(0,30) x=runif(50, 0,30) #Creates categories rain=cut(x,breaks=c( 0, 1,2.5,5, 10, 20, Inf)) #Creates contingency table of categories tab=table(rain) #Plots frequencies of rainfall barplot(tab) I hope this helps! Francisco Dr. Francisco J. Zagmutt College of Veterinary Medicine and Biomedical Sciences Colorado State University From: etienne [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] distribution of daily rainfall values in binned categories Date: Tue, 27 Jun 2006 11:28:59 -0700 (PDT) Hi, I'm a newbie in using R and I would like to have a few clues as to how I could compute and plot a distribution of daily rainfall intensity in different categories. I have daily values (mm/day) for several years and I need to show the frequency of 0-1, 1-2.5, 2.5-5, 5-10, 10-20, 20+ mm/day. Can this be done easily? Thanks, Etienne __ 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 __ 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
Re: [R] installing R on RedHat
On Tue, 2006-06-27 at 22:18 -0500, Erin Hodgess wrote: Dear R People: Yet again, I am attempting to install R on RedHat Linux. Here is my sorry attempt to date: [EMAIL PROTECTED] hodgess]$ rpm -vi R.rpm warning: R.rpm: V3 DSA signature: NOKEY, key ID 97d3544e error: cannot write to %sourcedir /usr/src/redhat/SOURCES I only want to write it to my own userid, since I am the only one who uses it. Any suggestions would be much appreciated. Erin, As far as I know, the R RPMS provide either by Martyn Plummer et al on CRAN, or more recently via Fedora Extras, are generally not relocatable. In other words, they must be installed as root into a pre-defined location. I checked the list archive and this had come up last year: http://finzi.psych.upenn.edu/R/tmp/Rhelp02a/archive/53976.html and I don't know that this has changed. If you need to install only as a local user, you will likely need to do so from source as I referenced in the above thread. See the R-admin manual for more information on how to configure for this. More generally, if you have root access on your system, the default on Linux is to install using system-wide configurations, not per user, even if you are the only user. User specific installation is generally only used if you need to install something and do not have root access. HTH, Marc Schwartz __ 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
Re: [R] compositional time series
Rogerio, Thank you for your warm response. yes, the 2 issues you mentioned have been taken into consideration, the previous one was written for the sake of simplicity as to give the idea... to my knowledge, the most common approach to deal with the compositional time series is to use some transformations of the series (following Aitchison's idea)... i am wondering if someone has developed an R specific 'tool' / package to deal with compositional time series? (for example, perhaps there is a suggestion for users on which transformation or which model (varma) that is likely to be the best) Thank you, Sincerely, hendry rdporto1 [EMAIL PROTECTED] wrote: Hendry, you have to be very very carefull 'cause of the compositional nature of your data and because of your short time series. 1.You have to be carefull about compositional data (see Aitchinson's book: Compositional Data Analysis). 2. You have a very short time series and it's difficult to model that (see Chattfield's book: Statistical Problem Solving - I think!) Considering 1 and 2, you can analyze your data using R or any other statistical software since you have a model. Do you have one? Tell the group wich one it is and maybe we can help you more. Rogerio Porto. -- Cabeçalho original --- De: [EMAIL PROTECTED] Para: R-help@stat.math.ethz.ch Cópia: Data: Tue, 27 Jun 2006 18:21:32 +0800 (CST) Assunto: [R] compositional time series Dear R users, i am wondering if anyone has some hints for this problem (i have not found a clear answer after searching the R-mailing list archive, 'help.search' in R, and R-Wiki, and the like...): let's assume that i have 4 periods compositional time series data: t=1, A=0.1; B=0.5; C=0.4 t=2, A=0.2; B=0.4; C=0.4 t=3, A=0.5; B=0.3; C=0.2 t=4, A=0.4; B=0.3; C=0.3 t=5, ??? By using R, could anyone suggest how to obtain the forecasted value of the fifth period (t=5) as well as the forecast error? (it seems that 'mixeR' [M.Bren] and 'compositions' [v.d.Boogart] have not provided a 'direct' solution to this problem...) really appreciate your time/help for this, Thank you very much, Sincerely, hendry raharjo - [[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 - The World Cup Is Now On Your Favorite Front Page - check out www.yahoo.com.sg [[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
[R] Question regarding topTable function in limma
Hello, I have just completed my analysis of microarray data using limma. But, when I ask for a list of topTable genes, I am getting the following error: topTable(fit2,coef=5,adjust=fdr) Error in array(x, c(length(x), 1), if (!is.null(names(x))) list(names(x), : attempt to set an attribute on NULL Here, fit2 is got after ebayes fit to 'fit'. The fit2 object is not empty, because the attribute p.value is of size 2x11. Can someone please tell me what am I doing wrong, and how to get the top ranked genes in this case? Thanks, Shireesh Srivastava - [[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
[R] Reporting ppr fits and using them externally.
The pursuit projection packages ppr is an excellent contribution to R. It is great for one-to-three ridge fits, often somewhat intuitive, and for multi-ridge fits, where it at least describes a lot of variance. Like many folk, I need to report the fits obtained from ppr to the greater, outside, non-R world. It is fairly obvious how to use the terms alpha and beta to report on directionality and importance. It has proven difficult to report on the spline fits generated. We are moving into some cryptanalysis of the uncommented predict code with the ppr method in order to locate the information, and can report, if warranted. The question: How can one simply recover the spline knots and the spline parameters associated with a particular fit? Are we missing something obvious, or has there been contributed code that we could make use of? We have considered making spline fits of the spline fit variables, but this seems a bit obtuse. In our case, there are usually several thousand rows of the predictor variables, so the exact description of the knots is necessary but not very problem-dependent. A second (rhetorical) question: Can more information be associated with the differing projection directions chosen for the fit? We have made a second analysis with sphered data, and run arbitrary subsets to assess contributions of spline fits along the various directions, and computed correlations with fitted and (fitted+residual) data. Maybe there's a more standard approach we're missing. Thanks for your advice! Bob Chatfield / NASA Ames Research Center __ 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