[R] How to request AIC information from lm object?
Can lm return AIC information? Thanks a lot! [[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 request AIC information from lm object?
Hi Michael, use: extractAIC to get AIC from an lm object: y - rnorm(10) extractAIC(lm(y~1)) Christian __ R-help@stat.math.ethz.ch 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 request AIC information from lm object?
You can use AIC to get what you want. #example from lm help page ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) group - gl(2,10,20, labels=c(Ctl,Trt)) weight - c(ctl, trt) anova(lm.D9 - lm(weight ~ group)) Analysis of Variance Table Response: weight Df Sum Sq Mean Sq F value Pr(F) group 1 0.6882 0.6882 1.4191 0.249 Residuals 18 8.7293 0.4850 #get the AIC of lm model. AIC(lm.D9) [1] 46.17648 2006/6/9, Michael [EMAIL PROTECTED]: Can lm return AIC information? Thanks a lot! [[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 -- 黄荣贵 Deparment of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] [Fwd: R 2.20 Windows XP anaolgue of Splus unix() command ?]
In my windows XP there is no read command as well,so the _ unix(read stuff)_ will not wor as what _system_ function does is to pass the 'read stuff' command argument to the system command. I guess the read command to specific to some Unix OS. Hope this helps. 2006/6/9, [EMAIL PROTECTED] [EMAIL PROTECTED]: Hi Everyone : As I mentioned earlier, I am taking a lot of Splus code and turning into R and I've run into another stumbling block that I have not been able to figure out. I did plotting in a loop when I was using Splus on unix and the way I made the plots stop so I could lookat them as they got plotted ( there are hundreds if not thousands getting plotted sequentially ) on the screen was by using the unix() command. Basically, I wrote a function called wait() wait-function() { cat(press return to continue) unix(read stuff) } and this worked nicely because I then did source(program name) at the Splus prompt and a plot was created on the screen and then the wait() function was right under the plotting code in the program so that you had to hit the return key to go to the next plot. I am trying to do the equivalent on R 2.20/windows XP I did a ?unix in R and it came back with system() and said unix was deprecated so I replaced unix(read stuff) with system(read stuff) but all i get is a warning read not found and it flies through the successive plots and i can't see them. Thanks for any help on this. It's much appreciated. Mark __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 黄荣贵 Deparment of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] X'W in Matrix
On 6/9/06, Rafael A. Irizarry [EMAIL PROTECTED] wrote: Hi! I have used the Matrix package (Version: 0.995-10) successfully to obtain the OLS solution for a problem where the design matrix X is 44000x6000. X is very sparse (about 8 non-zeros elements). Now I want to do WLS: (X'WX)^-1X'Wy I tried W=Diagonal(length(w),w) and wX=solve(X,W) but after various minutes R gives a not enough memory error (Im using a 64bit machine with 16Gigs of RAM). That's an interesting question, Rafael, and very timely. I happen to be visiting Martin Maechler this week and he mentioned to me just a few minutes ago that we should add the capability for sparse least squares calculations to the Matrix package. Just for clarification, did you really mean wX = solve(X, W) above or were you thinking of wX = crossprod(X, W)? I would suggest storing the square root of the diagonal matrix W as a sparse matrix w - abs(rnorm(88000)) ind - seq(along = w) - 1:1 W - as(new(dgTMatrix, i = ind, j = ind, x = sqrt(w), Dim = c(length(w), length(w))), dgCMatrix) str(W) Formal class 'dgCMatrix' [package Matrix] with 6 slots ..@ i : int [1:88000] 0 1 2 3 4 5 6 7 8 9 ... ..@ p : int [1:88001] 0 1 2 3 4 5 6 7 8 9 ... ..@ Dim : int [1:2] 88000 88000 ..@ Dimnames:List of 2 .. ..$ : NULL .. ..$ : NULL ..@ x : num [1:88000] 0.712 0.989 1.032 0.348 0.573 ... ..@ factors : list() (The 1:1 expression in the calculation of ind is a cheap trick to get an integer value of 1 so that ind stays integer). Now you should be able to create wX - W %*% X and wy - W %*% y very quickly. I ended up doing this: wX=Matrix(as.matrix(X)*sqrt(w),sparse=TRUE) coefs1=as.vector(solve(crossprod(wX),crossprod(X,w*y))) which takes about 1-2 minutes, but it seems a better way, using the diagonal matrix, should exist. If there is I'd appreciate hearing it. If not, Im happy waiting 1-2 minute x #of iters. Thanks, Rafael __ R-help@stat.math.ethz.ch 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] script for multi linear regression
Hi, I am trying to write a function in R that receives one array (y) and one list of arrays (mylist.of.array) with one or more arrays I need get y in function of the arrays in mylist.of.array . I am a newbie in R so I tryed the line bellow, that obviosly does not work g-lm(y~ mylist.of.array) May anybody help me? -- Thank you for your time and help, Wagner Costa [[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] Re-binning histogram data
François Pinard sent the following at 09/06/2006 00:53: [Berton Gunter] I would argue that histograms are outdated relics and that density plots (whatever your favorite flavor is) should **always** be used instead these days. When a now retired researcher paid us a visit, I showed him a density plot produced by R over some data he did work a lot, before he left. I, too, find them rather sexy, and I wanted to impress him with some of the pleasures of R, especially knowing he has been a dedicated user of SAS in his times. Yet, this old and wise man _immediately_ caught that the density curve was leaking a tiny bit through the extrema. Not a big deal of course -- and he did like what he saw. Nevertheless, ... rest snipped ... I did like Francois's post very much and confess I'm not very familiar with density plots and use histograms a lot still. However, I'm not a statistician, though like to think I'm not a complete Luddite. Rather naive question: doesn't this depend a bit on whether you see yourself as describing the sample or describing the (inferred) population. It's intrigued me, much though I think the developing graphical methods of data exploration are wonderful, that I think that distinction between sample and population is not made as clearly for graphical methods as perhaps it would be if the presentation were textual. Perhaps that's because it's often implicitly pretty clear, for example, boxplots and histograms, with inevitable problems, describing samples, some density plots at least, implicitly describing populations. I know there's an argument that only the inferences (and their CIs) about the population are statistics and the rest is accountancy but I am not happy with that idea! I'd be interested to hear others' views even if we are rather OTT (Off The Topic, not Over The Top) here. Perhaps I'm completely wrong? Thanks to all for their posts, as ever, I'm learning much. Chris -- Chris Evans [EMAIL PROTECTED] Hon. Professor of Psychotherapy, Nottingham University; Consultant Psychiatrist in Psychotherapy, Rampton Hospital; Research Programmes Director, Nottinghamshire NHS Trust; Hon. SL Institute of Psychiatry, Hon. Con., Tavistock Portman Trust **If I am writing from one of those roles, it will be clear. Otherwise** **my views are my own and not representative of those institutions** __ R-help@stat.math.ethz.ch 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] make check errors for R-2.3.1
On Thu, 8 Jun 2006, Luo Weijun wrote: I tried to build R-2.3.1 from source under Mac OS X 10.4.6. (I am doing so because only this way I can get the 64-bit version of R) The configure and make steps look fine. But I got errors when I did make check-all, here is the message: running code in 'base-Ex.R' ...make[4]: *** [base-Ex.Rout] Error 1 make[3]: *** [test-Examples-Base] Error 2 make[2]: *** [test-Examples] Error 2 make[1]: *** [test-all-basics] Error 1 make: *** [check-all] Error 2 I am not sure what does this mean. One potentially related issue is that, I downloaded and installed a gfortran compiler: GNU Fortran 95 (GCC) 4.2.0 20060512 (experimental), because we don¡¯t have one originally. But I didn¡¯t use the latest cctools, and our version is: Apple Computer, Inc. version cctools-590.23.2.obj~17. Not sure whether this matters. Our gcc compiler is: powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5250). See Tools section of http://r.research.att.com/ for GCC. R-GUI installer contains needed Fortran compiler. See also http://wiki.urbanek.info/ for additional Mac OS X build/compilation issues. This should properly be discussed on R SIG Mac rather than R Help. -- SIGSIG -- signature too long (core dumped) __ R-help@stat.math.ethz.ch 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] script for multi linear regression
g - lapply(x, function(z) lm(y ~ z)) On 6/9/06, Wagner Costa [EMAIL PROTECTED] wrote: Hi, I am trying to write a function in R that receives one array (y) and one list of arrays (mylist.of.array) with one or more arrays I need get y in function of the arrays in mylist.of.array . I am a newbie in R so I tryed the line bellow, that obviosly does not work g-lm(y~ mylist.of.array) May anybody help me? -- Thank you for your time and help, Wagner Costa [[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 -- Jim Holtman Cincinnati, OH +1 513 646 9390 (Cell) +1 513 247 0281 (Home) What is the problem you are trying to solve? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] HTML nsmall vector format problem
Hello All I am having a bit of trouble formatting my HTML with the desired number of digits after the decimal place. Am I doing something wrong/misunderstanding or is it a bug? Looking at the example supplied with ?HTML.data.frame: HTML(iris[1:2,1:2],nsmall=c(3,1),file=) Gives html output that includes the lines: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.500/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.000/td/tr My understanding of how nsmall works, as a vector, the output should be something like: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.5/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.0/td/tr i.e. first column with 3 digits after the decimal place and the second column with 1 digit after the decimal place. It appears to only use the first value in the vector. Has anybody got any suggestions? Thanks for any help. John Seers --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk http://www.ifr.ac.uk/ www.foodandhealthnetwork.com http://www.foodandhealthnetwork.com/ [[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] barplot dataframes w/ varying dimensions
Hi all, I would like to do a barplot of a dataframe like this one: alfa beta gamma delta qwert 56.5 58.5 56.5 58.5 asdfg 73.0 73.0 43.0 73.0 zxcvb 63.0 63.0 43.0 63.0 yuiop 63.0 63.0 43.0 63.0 with the labels of the rows and columns. I would like to have something that works for dataframes with varying dimensions, and so far I haven't found any way to do it. What would be the best way to do that? Thanks in advance, Albert. __ R-help@stat.math.ethz.ch 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] HTML nsmall vector format problem
John, I don't think nsmall uses a vector. Try the following with format (which HTML.data.frame uses): format(iris[1:2,1:2],nsmall=c(3,1)) Sepal.Length Sepal.Width 15.100 3.500 24.900 3.000 It looks like you'll have to do a format column by column with a loop. - Tom john seers (IFR) wrote: Hello All I am having a bit of trouble formatting my HTML with the desired number of digits after the decimal place. Am I doing something wrong/misunderstanding or is it a bug? Looking at the example supplied with ?HTML.data.frame: HTML(iris[1:2,1:2],nsmall=c(3,1),file=) Gives html output that includes the lines: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.500/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.000/td/tr My understanding of how nsmall works, as a vector, the output should be something like: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.5/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.0/td/tr i.e. first column with 3 digits after the decimal place and the second column with 1 digit after the decimal place. It appears to only use the first value in the vector. Has anybody got any suggestions? Thanks for any help. John Seers --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk http://www.ifr.ac.uk/ www.foodandhealthnetwork.com http://www.foodandhealthnetwork.com/ [[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 -- View this message in context: http://www.nabble.com/HTML-nsmall-vector-format-problem-t1760896.html#a4791061 Sent from the R help forum at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] appending arrays
Hi All, I have 2 arrays: dim(a1) [1] 3 23 23 dim(a2) [1] 3 23 23 And I want a new array, to say, a3, where: dim(a3) [1] 6 23 23 where the first dimension is supposed to be (months) so the resultating array would start in jan and finish in june. Best regards, Antonio __ R-help@stat.math.ethz.ch 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] barplot dataframes w/ varying dimensions
On Fri, 2006-06-09 at 06:05 -0500, Marc Schwartz wrote: On Fri, 2006-06-09 at 11:26 +0100, Albert Vilella wrote: Hi all, I would like to do a barplot of a dataframe like this one: alfa beta gamma delta qwert 56.5 58.5 56.5 58.5 asdfg 73.0 73.0 43.0 73.0 zxcvb 63.0 63.0 43.0 63.0 yuiop 63.0 63.0 43.0 63.0 with the labels of the rows and columns. I would like to have something that works for dataframes with varying dimensions, and so far I haven't found any way to do it. What would be the best way to do that? Thanks in advance, Albert. barplot() requires the 'height' argument to be a vector or matrix, so you need to coerce the data frame: barplot(as.matrix(DF)) or barplot(as.matrix(DF), beside = TRUE) depending upon the format you prefer. I forgot to note that you will get the colnames(DF) to label the groupings by default, but to get the rownames(DF) as well, you might do that with a legend: barplot(as.matrix(DF), legend.text = rownames(DF), ylim = c(0, max(colSums(DF)) * 1.4)) or barplot(as.matrix(DF), beside = TRUE, legend.text = rownames(DF), ylim = c(0, max(DF) * 1.4)) Note that I have adjusted the range of the y axis in each case to make room for the legend in the upper right hand corner. You would have more flexibility in legend formatting by using legend() separately. See ?legend for more information. HTH, Marc __ R-help@stat.math.ethz.ch 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] barplot dataframes w/ varying dimensions
On Fri, 2006-06-09 at 11:26 +0100, Albert Vilella wrote: Hi all, I would like to do a barplot of a dataframe like this one: alfa beta gamma delta qwert 56.5 58.5 56.5 58.5 asdfg 73.0 73.0 43.0 73.0 zxcvb 63.0 63.0 43.0 63.0 yuiop 63.0 63.0 43.0 63.0 with the labels of the rows and columns. I would like to have something that works for dataframes with varying dimensions, and so far I haven't found any way to do it. What would be the best way to do that? Thanks in advance, Albert. barplot() requires the 'height' argument to be a vector or matrix, so you need to coerce the data frame: barplot(as.matrix(DF)) or barplot(as.matrix(DF), beside = TRUE) depending upon the format you prefer. 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
[R] appending arrays
Hi All, I have 2 arrays: dim(a1) [1] 3 23 23 dim(a2) [1] 3 23 23 And I want a new array, to say, a3, where: dim(a3) [1] 6 23 23 where the first dimension is supposed to be (months) so the resultating array would start in jan and finish in june. Best regards, Antonio -- = Por favor, si me mandas correos con copia a varias personas, pon mi dirección de correo en copia oculta (CCO), para evitar que acabe en montones de sitios, eliminando mi privacidad, favoreciendo la propagación de virus y la proliferación del SPAM. Gracias. - If you send me e-mail which has also been sent to several other people, kindly mark my address as blind-carbon-copy (or BCC), to avoid its distribution, which affects my privacy, increases the likelihood of spreading viruses, and leads to more SPAM. 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
Re: [R] HTML nsmall vector format problem
Hi Tom Thanks for the reply. I see what you are saying - that format does not format using an nsmall vector, though the documentation (of HTML.data.frame) and the example suggest nsmall uses a vector. Even if I went through and changed the columns with a loop the HTML.data.frame would reformat them according to its formatting so I would still get all the columns with one value of nsmall. Specifically I want 0 for my first three columns and 4 for the remaining columns in my data frame. (I would also like to control the widths but I guess I may run into the same problem). I could reprocess the HTML output but that makes generating the HTML a bit redundant! Regards John --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk www.foodandhealthnetwork.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of tshort Sent: 09 June 2006 11:54 To: r-help@stat.math.ethz.ch Subject: Re: [R] HTML nsmall vector format problem John, I don't think nsmall uses a vector. Try the following with format (which HTML.data.frame uses): format(iris[1:2,1:2],nsmall=c(3,1)) Sepal.Length Sepal.Width 15.100 3.500 24.900 3.000 It looks like you'll have to do a format column by column with a loop. - Tom john seers (IFR) wrote: Hello All I am having a bit of trouble formatting my HTML with the desired number of digits after the decimal place. Am I doing something wrong/misunderstanding or is it a bug? Looking at the example supplied with ?HTML.data.frame: HTML(iris[1:2,1:2],nsmall=c(3,1),file=) Gives html output that includes the lines: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.500/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.000/td/tr My understanding of how nsmall works, as a vector, the output should be something like: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.5/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.0/td/tr i.e. first column with 3 digits after the decimal place and the second column with 1 digit after the decimal place. It appears to only use the first value in the vector. Has anybody got any suggestions? Thanks for any help. John Seers --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk http://www.ifr.ac.uk/ www.foodandhealthnetwork.com http://www.foodandhealthnetwork.com/ [[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 -- View this message in context: http://www.nabble.com/HTML-nsmall-vector-format-problem-t1760896.html#a4 791061 Sent from the R help forum at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch 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] barplot dataframes w/ varying dimensions
Hi something like tab alfa beta gamma delta qwert 56.5 58.5 56.5 58.5 asdfg 73.0 73.0 43.0 73.0 zxcvb 63.0 63.0 43.0 63.0 yuiop 63.0 63.0 43.0 63.0 barplot(as.matrix(tab), beside=T, legend.text=T) HTH Petr On 9 Jun 2006 at 11:26, Albert Vilella wrote: From: Albert Vilella [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Date sent: Fri, 09 Jun 2006 11:26:26 +0100 Subject:[R] barplot dataframes w/ varying dimensions Send reply to: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] Hi all, I would like to do a barplot of a dataframe like this one: alfa beta gamma delta qwert 56.5 58.5 56.5 58.5 asdfg 73.0 73.0 43.0 73.0 zxcvb 63.0 63.0 43.0 63.0 yuiop 63.0 63.0 43.0 63.0 with the labels of the rows and columns. I would like to have something that works for dataframes with varying dimensions, and so far I haven't found any way to do it. What would be the best way to do that? Thanks in advance, Albert. __ R-help@stat.math.ethz.ch 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] HTML nsmall vector format problem
John, you can use format ahead of time (this converts to character columns, so HTML won't reformat), and then use HTML: z=format(iris[1:2,1:2],nsmall=3) z[,2]=format(iris[1:2,2],nsmall=1) HTML(z,file=) - Tom -Original Message- From: john seers (IFR) [mailto:[EMAIL PROTECTED] Sent: Friday, June 09, 2006 7:19 AM To: Short, Tom; r-help@stat.math.ethz.ch Subject: RE: [R] HTML nsmall vector format problem Hi Tom Thanks for the reply. I see what you are saying - that format does not format using an nsmall vector, though the documentation (of HTML.data.frame) and the example suggest nsmall uses a vector. Even if I went through and changed the columns with a loop the HTML.data.frame would reformat them according to its formatting so I would still get all the columns with one value of nsmall. Specifically I want 0 for my first three columns and 4 for the remaining columns in my data frame. (I would also like to control the widths but I guess I may run into the same problem). I could reprocess the HTML output but that makes generating the HTML a bit redundant! Regards John --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk www.foodandhealthnetwork.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of tshort Sent: 09 June 2006 11:54 To: r-help@stat.math.ethz.ch Subject: Re: [R] HTML nsmall vector format problem John, I don't think nsmall uses a vector. Try the following with format (which HTML.data.frame uses): format(iris[1:2,1:2],nsmall=c(3,1)) Sepal.Length Sepal.Width 15.100 3.500 24.900 3.000 It looks like you'll have to do a format column by column with a loop. - Tom john seers (IFR) wrote: Hello All I am having a bit of trouble formatting my HTML with the desired number of digits after the decimal place. Am I doing something wrong/misunderstanding or is it a bug? Looking at the example supplied with ?HTML.data.frame: HTML(iris[1:2,1:2],nsmall=c(3,1),file=) Gives html output that includes the lines: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.500/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.000/td/tr My understanding of how nsmall works, as a vector, the output should be something like: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.5/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.0/td/tr i.e. first column with 3 digits after the decimal place and the second column with 1 digit after the decimal place. It appears to only use the first value in the vector. Has anybody got any suggestions? Thanks for any help. John Seers --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk http://www.ifr.ac.uk/ www.foodandhealthnetwork.com http://www.foodandhealthnetwork.com/ [[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 -- View this message in context: http://www.nabble.com/HTML-nsmall-vector-format-problem-t1760896.html#a4 791061 Sent from the R help forum at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch 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] appending arrays
antonio rodriguez antonio.raju at gmail.com writes: I have 2 arrays: dim(a1) [1] 3 23 23 dim(a2) [1] 3 23 23 And I want a new array, to say, a3, where: dim(a3) [1] 6 23 23 You can (1) figure out how to transpose the arrays (?aperm), put them together with c(), and re-array() them, *or* check out the abind package: install.packages(abind) library(abind) ?abind Ben __ R-help@stat.math.ethz.ch 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] deal with R.package panel
hello! my question conserns with use of panel package (written by R.C.Gentlman) (unfortunately the manual and help sites are very short) 1. is it possible to do analysis just without a(ny) covariate? i suggest do it by introducing a covariate with level=0 in all obervations, this because of Q(z)=Q_o exp(beta*z), but it seemingly doesn't work 2. in the option gamma in the call of panel function: do you mean an initial value for parameter vector gamma? say if i have 3 theta-parameters, so i have to initialize gamma=c(xxx,xxx,xxx), correct? 3. are the (first ) observed times =0 allowed (in $time vectors) or schould in such a case begin with =1, if there are any? thanks for your response __ R-help@stat.math.ethz.ch 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] Re-binning histogram data
On 6/8/2006 11:51 AM, Berton Gunter wrote: I would argue that histograms are outdated relics and that density plots (whatever your favorite flavor is) should **always** be used instead these days. But my favourite density plot is a histogram! I agree that computational complexity should weigh much less in the decision to do something than it used to. But I'd say a histogram (with more bins than the R default) is a good input to my mental density estimator. Adding a rug of points below it is helpful in small datasets. It is very easy to see how much smoothing has been done; that's often hard to see in presentations of density plots produced in other ways. It's also easier to recognize discrete atoms in the distribution: they'll show up as isolated bars a lot higher than the usual. For example, compare these two plots: set.seed(123) par(mfrow=c(2,1)) x - c(rnorm(1000), rbinom(100, 3, 0.5)) hist(x, breaks=60) plot(density(x)) This isn't a fair comparison, since I used the default bandwidth on the smoother but not on the histogram (it would be fairer to compare to plot(density(x,bw=0.05)) ), but I think it still illustrates my point: in the latter density plot where the atoms are clearly visible, I still need to read the text at the bottom to know the sample size and bandwidth, whereas I can see those at a glance in the histogram. And an untrained user could get a lot of information out of the histogram, whereas they'd have a lot of trouble getting anything out of the density plots. In this vein, I would appreciate critical rejoinders (public or private) to the following proposition: Given modern computer power and software like R on multi ghz machines, statistical and graphical relics of the pre-computer era (like histograms, low resolution printer-type plots, and perhaps even method of moments EMS calculations) should be abandoned in favor of superior but perhaps computation-intensive alternatives (like density plots, high resolution plots, and likelihood or resampling or Bayes based methods). NB: Please -- no pleadings that new methods would be mystifying to the non-cogniscenti. Following that to its logical conclusion would mean that we'd all have to give up our TV remotes and cell phones, and what kind of world would that be?! :-) Now, if you were to suggest that the stem() function is a bizarre simulation of a stone-age tool on a modern computer, I might agree. Duncan Murdoch -- Bert Gunter -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Petr Pikal Sent: Thursday, June 08, 2006 6:17 AM To: Justin Ashmall; r-help@stat.math.ethz.ch Subject: Re: [R] Re-binning histogram data On 8 Jun 2006 at 11:35, Justin Ashmall wrote: Date sent: Thu, 8 Jun 2006 11:35:46 +0100 (BST) From:Justin Ashmall [EMAIL PROTECTED] To: Petr Pikal [EMAIL PROTECTED] Copies to: r-help@stat.math.ethz.ch Subject: Re: [R] Re-binning histogram data Thanks for the reply Petr, It looks to me that truehist() needs a vector of data just like hist()? Whereas I have histogram-style input data? Am I missing something? Well, maybe you could use barplot. Or as you suggested recreate the original vector and call hist or truehist with other bins. hhh-hist(rnorm(1000)) barplot(tapply(hhh$counts, c(rep(1:7,each=2),7), sum)) tapply(hhh$mids, c(rep(1:7,each=2),7), mean) 1 2 3 4 5 6 7 -3.00 -2.00 -1.00 0.00 1.00 2.00 3.25 hhh1-rep(hhh$mids,hhh$counts) plot(hhh, freq=F) lines(density(hhh1)) HTH Petr Cheers, Justin On Thu, 8 Jun 2006, Petr Pikal wrote: Hi try truehist from MASS package and look for argument breaks or h. HTH Petr On 8 Jun 2006 at 10:46, Justin Ashmall wrote: Date sent: Thu, 8 Jun 2006 10:46:19 +0100 (BST) From:Justin Ashmall [EMAIL PROTECTED] To: r-help@stat.math.ethz.ch Subject: [R] Re-binning histogram data Hi, Short Version: Is there a function to re-bin a histogram to new, broader bins? Long version: I'm trying to create a histogram, however my input-data is itself in the form of a fine-grained histogram, i.e. numbers of counts in regular one-second bins. I want to produce a histogram of, say, 10-minute bins (though possibly irregular bins also). I suppose I could re-create a data set as expected by the hist() function (i.e. if time t=3600 has 6 counts, add six entries of 3600 to a list) however this seems neither elegant nor efficient (though I'd be pleased to be mistaken!). I could then re-create a histogram as normal. I guessing there's a better solution however! Apologies if this is a basic question - I'm rather new to R and trying to get up to speed. Regards,
[R] sqlSave() and rownames=TRUE makes my Rgui crash
Hello, I created a table in MySQL with this command CREATE TABLE example (pk INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(pk), id VARCHAR(30),col1 VARCHAR(30),col2 VARCHAR(30)) ### In R, I can connect to this table: library(DBI) library(RODBC) chan - odbcConnect(MySQL51, uid=root, pwd=xxx) first - sqlQuery(chan, select * from example) close(chan) First #[1] pk id col1 col2 #0 rows (or 0-length row.names) ### This is the table I'm trying to save: dframe -data.frame(matrix(1:6,2,3)) colnames(dframe)=c(id,col1,col2) dframe # id col1 col2 #1 135 #2 246 ### But this makes Rgui crash and close chan - odbcConnect(MySQL51, uid=root, pwd=xxx) sqlSave(chan, dframe, tablename=example, rownames = FALSE, append=T) close(chan) ### With rownames = T and safer=F, it works, but I loose the autoincrementing PK in MySQL chan - odbcConnect(MySQL51, uid=root, pwd=momie) #default database=fbn sqlSave(chan, dframe, tablename=example, rownames = T, addPK=T,append=T,safer=F) close(chan) Any idea? I'm on win2K, MySQL version 5.0.21-community-nt version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status Patched major 2 minor 3.0 year 2006 month 05 day11 svn rev38024 language R version.string Version 2.3.0 Patched (2006-05-11 r38024) Pierre Lapointe ** AVIS DE NON-RESPONSABILITE: Ce document transmis par courrie...{{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
Re: [R] Re-binning histogram data
On Jun 9, 2006, at 7:38 AM, Duncan Murdoch wrote: Now, if you were to suggest that the stem() function is a bizarre simulation of a stone-age tool on a modern computer, I might agree. But as a stone-age (blackboard) tool it is unsurpassed. It is the only bright spot in the usually depressing ritual of returning exam results. Full disclosure of the distribution in a very concise encoding. url:www.econ.uiuc.edu/~rogerRoger Koenker email[EMAIL PROTECTED]Department of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 __ R-help@stat.math.ethz.ch 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] HTML nsmall vector format problem
Hi Tom Excellent! Exactly what I need. I see what you mean now. Thanks very much for your help. John --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk www.foodandhealthnetwork.com -Original Message- From: Short, Tom [mailto:[EMAIL PROTECTED] Sent: 09 June 2006 12:36 To: john seers (IFR); r-help@stat.math.ethz.ch Subject: RE: [R] HTML nsmall vector format problem John, you can use format ahead of time (this converts to character columns, so HTML won't reformat), and then use HTML: z=format(iris[1:2,1:2],nsmall=3) z[,2]=format(iris[1:2,2],nsmall=1) HTML(z,file=) - Tom -Original Message- From: john seers (IFR) [mailto:[EMAIL PROTECTED] Sent: Friday, June 09, 2006 7:19 AM To: Short, Tom; r-help@stat.math.ethz.ch Subject: RE: [R] HTML nsmall vector format problem Hi Tom Thanks for the reply. I see what you are saying - that format does not format using an nsmall vector, though the documentation (of HTML.data.frame) and the example suggest nsmall uses a vector. Even if I went through and changed the columns with a loop the HTML.data.frame would reformat them according to its formatting so I would still get all the columns with one value of nsmall. Specifically I want 0 for my first three columns and 4 for the remaining columns in my data frame. (I would also like to control the widths but I guess I may run into the same problem). I could reprocess the HTML output but that makes generating the HTML a bit redundant! Regards John --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk www.foodandhealthnetwork.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of tshort Sent: 09 June 2006 11:54 To: r-help@stat.math.ethz.ch Subject: Re: [R] HTML nsmall vector format problem John, I don't think nsmall uses a vector. Try the following with format (which HTML.data.frame uses): format(iris[1:2,1:2],nsmall=c(3,1)) Sepal.Length Sepal.Width 15.100 3.500 24.900 3.000 It looks like you'll have to do a format column by column with a loop. - Tom john seers (IFR) wrote: Hello All I am having a bit of trouble formatting my HTML with the desired number of digits after the decimal place. Am I doing something wrong/misunderstanding or is it a bug? Looking at the example supplied with ?HTML.data.frame: HTML(iris[1:2,1:2],nsmall=c(3,1),file=) Gives html output that includes the lines: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.500/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.000/td/tr My understanding of how nsmall works, as a vector, the output should be something like: /tr trtd class=firstcolumn1/tdtd class=cellinside5.100/tdtd class=cellinside3.5/td/tr trtd class=firstcolumn2/tdtd class=cellinside4.900/tdtd class=cellinside3.0/td/tr i.e. first column with 3 digits after the decimal place and the second column with 1 digit after the decimal place. It appears to only use the first value in the vector. Has anybody got any suggestions? Thanks for any help. John Seers --- John Seers Institute of Food Research Norwich Research Park Colney Norwich NR4 7UA tel +44 (0)1603 251497 fax +44 (0)1603 507723 e-mail [EMAIL PROTECTED] e-disclaimer at http://www.ifr.ac.uk/edisclaimer/ http://www.ifr.ac.uk/edisclaimer/ Web sites: www.ifr.ac.uk http://www.ifr.ac.uk/ www.foodandhealthnetwork.com http://www.foodandhealthnetwork.com/ [[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 -- View this message in context: http://www.nabble.com/HTML-nsmall-vector-format-problem-t1760896.html#a4 791061 Sent from the R help forum at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch 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] Date calculation
Dear all R users, Suppose I have a data frame data like this: 5/2/2006 36560 5/3/2006 36538 5/4/2006 36452 5/5/2006 36510 5/8/2006 36485 5/9/2006 36502 5/10/2006 36584 5/11/200636571 Now I want to create a for loop like this: date = 5/10/2006 for (i in 1: 8) { if (data[i,1] date) break } But I get error while executing this. Can anyone tell me the right way to do this? Sincerely yours stat Send instant messages to your online friends http://in.messenger.yahoo.com Stay connected with your friends even when away from PC. Link: http://in.mobile.yahoo.com/new/messenger/ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
[R] Rotate values on Y axis
Hi, I have been working through one of the examples on the FAQ about rotating the labels on the x axis, I need to do the same but for the y axis. I have managed to change some of the code, but I am still not getting there, there is still something wrong. My syntax is as follows: par(mar = c(5, 7, 4, 2) + 0.1) plot(1 : 8, yaxt = n, ylab = ) axis(2, labels = FALSE) labels - paste(Label, 1:8, sep = ) text(1:8, par(usr)[3] - 0.25, srt = 45, adj = 1, + labels = labels, xpd = TRUE) If anybody knows what is wrong then I would appreciate your help...been working on this for far too long already! Regards, Dan __ R-help@stat.math.ethz.ch 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] generate random data
Dear R-Help, As with the rpois() function to generate random data from a poisson distribution, I need to generate random data from a quasi distribution with var=mu^2. Does anyone known how to do this? Thanks in advance, Hugues SANTIN-JANIN. [EMAIL PROTECTED] [[alternative HTML version deleted]] ___ Rendez-vous sur http://fr.yahoo.com/set __ R-help@stat.math.ethz.ch 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] sqlSave() and rownames=TRUE makes my Rgui crash
On 6/9/2006 8:51 AM, Lapointe, Pierre wrote: Hello, I created a table in MySQL with this command CREATE TABLE example (pk INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(pk), id VARCHAR(30),col1 VARCHAR(30),col2 VARCHAR(30)) ### In R, I can connect to this table: library(DBI) library(RODBC) chan - odbcConnect(MySQL51, uid=root, pwd=xxx) first - sqlQuery(chan, select * from example) close(chan) First #[1] pk id col1 col2 #0 rows (or 0-length row.names) ### This is the table I'm trying to save: dframe -data.frame(matrix(1:6,2,3)) colnames(dframe)=c(id,col1,col2) dframe # id col1 col2 #1 135 #2 246 ### But this makes Rgui crash and close chan - odbcConnect(MySQL51, uid=root, pwd=xxx) sqlSave(chan, dframe, tablename=example, rownames = FALSE, append=T) close(chan) ### With rownames = T and safer=F, it works, but I loose the autoincrementing PK in MySQL chan - odbcConnect(MySQL51, uid=root, pwd=momie) #default database=fbn sqlSave(chan, dframe, tablename=example, rownames = T, addPK=T,append=T,safer=F) close(chan) Any idea? I'm on win2K, MySQL version 5.0.21-community-nt I don't know why you're using DBI; perhaps it interferes with RODBC somehow. If that's not it, then you might want to try lower level methods than sqlSave: perhaps use sqlQuery to send an INSERT command to the database. Build up from there. You might also want to look at the thread Fast update of a lot of records in a database? from around May 20, though it was talking about updates rather than insertions. 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] Rotate values on Y axis
On Fri, 2006-06-09 at 14:13 +0100, d d [EMAIL PROTECTED] ac uk wrote: Hi, I have been working through one of the examples on the FAQ about rotating the labels on the x axis, I need to do the same but for the y axis. I have managed to change some of the code, but I am still not getting there, there is still something wrong. My syntax is as follows: par(mar = c(5, 7, 4, 2) + 0.1) plot(1 : 8, yaxt = n, ylab = ) axis(2, labels = FALSE) labels - paste(Label, 1:8, sep = ) text(1:8, par(usr)[3] - 0.25, srt = 45, adj = 1, + labels = labels, xpd = TRUE) If anybody knows what is wrong then I would appreciate your help...been working on this for far too long already! Regards, Dan Dan, You need to adjust two things: 1. par(usr)[3] is the minimum value of the y axis. You would use this (as in the FAQ example) when you want to move the text vertically below the x axis. See ?par for more information. In your case, you want to move the text to the left of the y axis. Thus you need to use par(usr)[1] instead, which is the minimum value of the x axis. 2. In the text call, you are setting the 'x' coordinate to 1:8, which is why the labels are appearing along the x axis, rather than along the y axis. So you want to set the y coordinate to 1:8 instead. So, the adjusted sequence would be: par(mar = c(5, 7, 4, 2) + 0.1) plot(1 : 8, yaxt = n, ylab = ) axis(2, labels = FALSE) labels - paste(Label, 1:8, sep = ) text(par(usr)[1] - 0.25, 1:8, srt = 45, adj = 1, labels = labels, xpd = TRUE) 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] sqlSave() and rownames=TRUE makes my Rgui crash
On 6/9/2006 8:51 AM, Lapointe, Pierre wrote: Hello, I created a table in MySQL with this command CREATE TABLE example (pk INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(pk), id VARCHAR(30),col1 VARCHAR(30),col2 VARCHAR(30)) ### In R, I can connect to this table: library(DBI) library(RODBC) chan - odbcConnect(MySQL51, uid=root, pwd=xxx) first - sqlQuery(chan, select * from example) close(chan) First #[1] pk id col1 col2 #0 rows (or 0-length row.names) ### This is the table I'm trying to save: dframe -data.frame(matrix(1:6,2,3)) colnames(dframe)=c(id,col1,col2) dframe # id col1 col2 #1 135 #2 246 ### But this makes Rgui crash and close chan - odbcConnect(MySQL51, uid=root, pwd=xxx) sqlSave(chan, dframe, tablename=example, rownames = FALSE, append=T) close(chan) ### With rownames = T and safer=F, it works, but I loose the autoincrementing PK in MySQL chan - odbcConnect(MySQL51, uid=root, pwd=momie) #default database=fbn sqlSave(chan, dframe, tablename=example, rownames = T, addPK=T,append=T,safer=F) close(chan) Any idea? I'm on win2K, MySQL version 5.0.21-community-nt I don't know why you're using DBI; perhaps it interferes with RODBC somehow. **It still crashes without DBI If that's not it, then you might want to try lower level methods than sqlSave: perhaps use sqlQuery to send an INSERT command to the database. Build up from there. **Good suggestion, however, I'm not sure how to pass a table through an sql statement. From this archived doc, http://finzi.psych.upenn.edu/R/Rhelp02a/archive/10073.html I tried this using a dataframe instead of a single number. But I get this error: #test chan - odbcConnect(MySQL51, uid=root, pwd=momie) #default database=fbn query - paste(INSERT INTO example VALUES (',dframe,'),sep=) sqlQuery(chan,query) close(chan) [1] [RODBC] ERROR: Could not SQLExecDirect [2] S1T00 1136 [MySQL][ODBC 3.51 Driver][mysqld-5.0.21-community-nt]Column count doesn't match value count at row 1 You might also want to look at the thread Fast update of a lot of records in a database? from around May 20, though it was talking about updates rather than insertions. Duncan Murdoch ** AVIS DE NON-RESPONSABILITE: Ce document transmis par courrie...{{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
Re: [R] Date calculation
test V1V2 1 5/2/2006 36560 2 5/3/2006 36538 3 5/4/2006 36452 4 5/5/2006 36510 5 5/8/2006 36485 6 5/9/2006 36502 7 5/10/2006 36584 8 5/11/2006 36571 dates - strptime(test$V1, %d/%m/%Y) --- Jacques VESLOT CNRS UMR 8090 I.B.L (2ème étage) 1 rue du Professeur Calmette B.P. 245 59019 Lille Cedex Tel : 33 (0)3.20.87.10.44 Fax : 33 (0)3.20.87.10.31 http://www-good.ibl.fr --- stat stat a écrit : Dear all R users, Suppose I have a data frame data like this: 5/2/2006 36560 5/3/2006 36538 5/4/2006 36452 5/5/2006 36510 5/8/2006 36485 5/9/2006 36502 5/10/2006 36584 5/11/200636571 Now I want to create a for loop like this: date = 5/10/2006 for (i in 1: 8) { if (data[i,1] date) break } But I get error while executing this. Can anyone tell me the right way to do this? Sincerely yours stat Send instant messages to your online friends http://in.messenger.yahoo.com Stay connected with your friends even when away from PC. Link: http://in.mobile.yahoo.com/new/messenger/ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch 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] Date calculation
Try this: Lines - 5/2/2006 36560 5/3/2006 36538 5/4/2006 36452 5/5/2006 36510 5/8/2006 36485 5/9/2006 36502 5/10/2006 36584 5/11/200636571 DF - read.table(textConnection(Lines), as.is = TRUE) fmt - %m/%d/%Y DF[,1] - as.Date(DF[,1], fmt) date - as.Date(5/10/2006, fmt) which.max(DF[,1] date) On 6/9/06, stat stat [EMAIL PROTECTED] wrote: Dear all R users, Suppose I have a data frame data like this: 5/2/2006 36560 5/3/2006 36538 5/4/2006 36452 5/5/2006 36510 5/8/2006 36485 5/9/2006 36502 5/10/2006 36584 5/11/200636571 Now I want to create a for loop like this: date = 5/10/2006 for (i in 1: 8) { if (data[i,1] date) break } But I get error while executing this. Can anyone tell me the right way to do this? Sincerely yours stat Send instant messages to your online friends http://in.messenger.yahoo.com Stay connected with your friends even when away from PC. Link: http://in.mobile.yahoo.com/new/messenger/ [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch 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] sqlSave() and rownames=TRUE makes my Rgui crash
On 6/9/2006 9:42 AM, Lapointe, Pierre wrote: On 6/9/2006 8:51 AM, Lapointe, Pierre wrote: Hello, I created a table in MySQL with this command CREATE TABLE example (pk INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(pk), id VARCHAR(30),col1 VARCHAR(30),col2 VARCHAR(30)) ### In R, I can connect to this table: library(DBI) library(RODBC) chan - odbcConnect(MySQL51, uid=root, pwd=xxx) first - sqlQuery(chan, select * from example) close(chan) First #[1] pk id col1 col2 #0 rows (or 0-length row.names) ### This is the table I'm trying to save: dframe -data.frame(matrix(1:6,2,3)) colnames(dframe)=c(id,col1,col2) dframe # id col1 col2 #1 135 #2 246 ### But this makes Rgui crash and close chan - odbcConnect(MySQL51, uid=root, pwd=xxx) sqlSave(chan, dframe, tablename=example, rownames = FALSE, append=T) close(chan) ### With rownames = T and safer=F, it works, but I loose the autoincrementing PK in MySQL chan - odbcConnect(MySQL51, uid=root, pwd=momie) #default database=fbn sqlSave(chan, dframe, tablename=example, rownames = T, addPK=T,append=T,safer=F) close(chan) Any idea? I'm on win2K, MySQL version 5.0.21-community-nt I don't know why you're using DBI; perhaps it interferes with RODBC somehow. **It still crashes without DBI If that's not it, then you might want to try lower level methods than sqlSave: perhaps use sqlQuery to send an INSERT command to the database. Build up from there. **Good suggestion, however, I'm not sure how to pass a table through an sql statement. From this archived doc, http://finzi.psych.upenn.edu/R/Rhelp02a/archive/10073.html I tried this using a dataframe instead of a single number. You can't. You can only insert one record at a time this way in general, but MySQL allows multiple inserts on one line. So it's a lot of work, but you might figure out what's causing your crash. But I get this error: #test chan - odbcConnect(MySQL51, uid=root, pwd=momie) #default database=fbn query - paste(INSERT INTO example VALUES (',dframe,'),sep=) sqlQuery(chan,query) close(chan) You'd want something like inserts - with(dframe, paste((', id, ',', col1, ',', col2, '), sep=, collapse=,) query - paste(INSERT INTO example(id, col1, col2) VALUES, inserts) sqlQuery(chan, query) (This isn't even tested to see if I got the syntax right, and it's probably not legal syntax on other databases. For those you could put together multiple INSERT statements.) Duncan Murdoch [1] [RODBC] ERROR: Could not SQLExecDirect [2] S1T00 1136 [MySQL][ODBC 3.51 Driver][mysqld-5.0.21-community-nt]Column count doesn't match value count at row 1 You might also want to look at the thread Fast update of a lot of records in a database? from around May 20, though it was talking about updates rather than insertions. Duncan Murdoch ** AVIS DE NON-RESPONSABILITE: Ce document transmis par courrier electronique est destine uniquement a la personne ou a l'entite a qui il est adresse et peut contenir des renseignements confidentiels et assujettis au secret professionnel. La confidentialite et le secret professionnel demeurent malgre l'envoi de ce document a la mauvaise adresse electronique. Si vous n'etes pas le destinataire vise ou la personne chargee de remettre ce document a son destinataire, veuillez nous en informer sans delai et detruire ce document ainsi que toute copie qui en aurait ete faite. Toute distribution, reproduction ou autre utilisation de ce document est strictement interdite. De plus, le Groupe Financiere Banque Nationale et ses filiales ne peuvent pas etre tenus responsables des dommages pouvant etre causes par des virus ou des erreurs de transmission. DISCLAIMER: This documentation transmitted by electronic mail is intended for the use of the individual to whom or the entity to which it is addressed and may contain information which is confidential and privileged. Confidentiality and privilege are not lost by this documentation having been sent to the wrong electronic mail address. If you are not the intended recipient or the person responsible for delivering it to the intended recipient please notify the sender immediately and destroy this document as well as any copies of it. Any distribution, reproduction or other use of this document is strictly prohibited. National Bank Financial Group and its affiliates cannot be held liable for any damage that may be caused by viruses or transmission errors. ** __ R-help@stat.math.ethz.ch 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] binomial lmer and fixed effects
Hi Folks, I think I have searched exhaustively, including, of course R-help (D. Bates, S. Graves, and others) and but I remain uncertain about testing fixed effects with lmer(..., family=binomial). I gather that mcmcsamp does not work with Do we rely exclusively on z values of model parameters, or could we use anova() with likelihood ratios, AIC and BIC, with (or without) method=ML (with didn't seem right to me)? I also received an error using adaptive Gaussian quadrature (but not Laplacian approximations): mod2 - lmer(yb ~ reg*nutrient*amd + + (1|rack) + (1|status) + + (1|popu) + (1|popu:amd) + + (1|gen) + (1|gen:nutrient) + (1|gen:amd) + + (1|gen:nutrient:amd), + data=datnm, family=binomial, method=AGQ) Error in lmer(yb ~ reg * nutrient * amd + (1 | rack) + (1 | status) + : method = AGQ not yet implemented for supernodal representation I would really appreciate any and all thoughts or leads. Cheers, Hank Stevens version _ platform powerpc-apple-darwin8.6.0 arch powerpc os darwin8.6.0 system powerpc, darwin8.6.0 status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) Dr. M. Hank H. Stevens, Assistant Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/~stevenmh/ http://www.muohio.edu/ecology/ http://www.muohio.edu/botany/ E Pluribus Unum __ R-help@stat.math.ethz.ch 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] sqlSave() and rownames=TRUE makes my Rgui crash
On 6/9/2006 9:42 AM, Lapointe, Pierre wrote: On 6/9/2006 8:51 AM, Lapointe, Pierre wrote: Hello, I created a table in MySQL with this command CREATE TABLE example (pk INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(pk), id VARCHAR(30),col1 VARCHAR(30),col2 VARCHAR(30)) ### In R, I can connect to this table: library(DBI) library(RODBC) chan - odbcConnect(MySQL51, uid=root, pwd=xxx) first - sqlQuery(chan, select * from example) close(chan) First #[1] pk id col1 col2 #0 rows (or 0-length row.names) ### This is the table I'm trying to save: dframe -data.frame(matrix(1:6,2,3)) colnames(dframe)=c(id,col1,col2) dframe # id col1 col2 #1 135 #2 246 ### But this makes Rgui crash and close chan - odbcConnect(MySQL51, uid=root, pwd=xxx) sqlSave(chan, dframe, tablename=example, rownames = FALSE, append=T) close(chan) ### With rownames = T and safer=F, it works, but I loose the autoincrementing PK in MySQL chan - odbcConnect(MySQL51, uid=root, pwd=momie) #default database=fbn sqlSave(chan, dframe, tablename=example, rownames = T, addPK=T,append=T,safer=F) close(chan) Any idea? I'm on win2K, MySQL version 5.0.21-community-nt I don't know why you're using DBI; perhaps it interferes with RODBC somehow. **It still crashes without DBI If that's not it, then you might want to try lower level methods than sqlSave: perhaps use sqlQuery to send an INSERT command to the database. Build up from there. **Good suggestion, however, I'm not sure how to pass a table through an sql statement. From this archived doc, http://finzi.psych.upenn.edu/R/Rhelp02a/archive/10073.html I tried this using a dataframe instead of a single number. You can't. You can only insert one record at a time this way in general, but MySQL allows multiple inserts on one line. So it's a lot of work, but you might figure out what's causing your crash. But I get this error: #test chan - odbcConnect(MySQL51, uid=root, pwd=momie) #default database=fbn query - paste(INSERT INTO example VALUES (',dframe,'),sep=) sqlQuery(chan,query) close(chan) You'd want something like inserts - with(dframe, paste((', id, ',', col1, ',', col2, '), sep=, collapse=,) query - paste(INSERT INTO example(id, col1, col2) VALUES, inserts) sqlQuery(chan, query) (This isn't even tested to see if I got the syntax right, and it's probably not legal syntax on other databases. For those you could put together multiple INSERT statements.) Nice workaround, but I'd be reluctant to use it for the same reason I'd prefer not to use RMySQL: I'd like my R code to be easily adaptable in case I port my DB to let's say PostgreSQL. Using RODBC, I would probably only have to change the DSN to make it work. Pierre Lapointe ** AVIS DE NON-RESPONSABILITE: Ce document transmis par courrie...{{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
Re: [R] [Fwd: R 2.20 Windows XP anaolgue of Splus unix() command ?]
Mark, I don't know how many of these files you have, so this may not be a viable solution, but what if you changed the function wait to be something like the following: wait - function() par(ask=T) for(i in 1:100){ plot(rnorm(100) ~ rnorm(100)) wait() } So, in general, this is not a solution to the unix() question, but it seems to produce what you want in this case. Hope this helps, Dave. Dave Armstrong University of Maryland Dept of Government and Politics 3140 Tydings Hall College Park, MD 20742 Office: 2103L Cole Field House Phone: 301-405-9735 e-mail: [EMAIL PROTECTED] web: www.davearmstrong-ps.com Facts are meaningless. You can use facts to prove anything that's even remotely true. - Homer Simpson On 6/9/06, ronggui [EMAIL PROTECTED] wrote: In my windows XP there is no read command as well,so the _ unix(read stuff)_ will not wor as what _system_ function does is to pass the 'read stuff' command argument to the system command. I guess the read command to specific to some Unix OS. Hope this helps. 2006/6/9, [EMAIL PROTECTED] [EMAIL PROTECTED]: Hi Everyone : As I mentioned earlier, I am taking a lot of Splus code and turning into R and I've run into another stumbling block that I have not been able to figure out. I did plotting in a loop when I was using Splus on unix and the way I made the plots stop so I could lookat them as they got plotted ( there are hundreds if not thousands getting plotted sequentially ) on the screen was by using the unix() command. Basically, I wrote a function called wait() wait-function() { cat(press return to continue) unix(read stuff) } and this worked nicely because I then did source(program name) at the Splus prompt and a plot was created on the screen and then the wait() function was right under the plotting code in the program so that you had to hit the return key to go to the next plot. I am trying to do the equivalent on R 2.20/windows XP I did a ?unix in R and it came back with system() and said unix was deprecated so I replaced unix(read stuff) with system(read stuff) but all i get is a warning read not found and it flies through the successive plots and i can't see them. Thanks for any help on this. It's much appreciated. Mark __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- 黄荣贵 Deparment of Sociology Fudan University __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html __ R-help@stat.math.ethz.ch 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] binomial lmer and fixed effects
AFAIK likelihood ratio tests are preferable, especially when you're interested in testing several fixed-effects simultaneously. However, since in GLMMs the likelihood cannot be calculated explicitly one could wonder how does this affect LRTs. Adaptive Gaussian quadrature is know to provide the best approximation; however, taking into account the random-effects structure in your model I doubt if it'd ever convergence in this year. Thus, I think Laplace is the best you can have in a reasonable computing time. Regarding `method = ML' I think this refers to the linear mixed model case where you also have the option for REML (the default). 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: Martin Henry H. Stevens [EMAIL PROTECTED] To: R-Help r-help@stat.math.ethz.ch Sent: Friday, June 09, 2006 3:55 PM Subject: [R] binomial lmer and fixed effects Hi Folks, I think I have searched exhaustively, including, of course R-help (D. Bates, S. Graves, and others) and but I remain uncertain about testing fixed effects with lmer(..., family=binomial). I gather that mcmcsamp does not work with Do we rely exclusively on z values of model parameters, or could we use anova() with likelihood ratios, AIC and BIC, with (or without) method=ML (with didn't seem right to me)? I also received an error using adaptive Gaussian quadrature (but not Laplacian approximations): mod2 - lmer(yb ~ reg*nutrient*amd + + (1|rack) + (1|status) + + (1|popu) + (1|popu:amd) + + (1|gen) + (1|gen:nutrient) + (1|gen:amd) + + (1|gen:nutrient:amd), + data=datnm, family=binomial, method=AGQ) Error in lmer(yb ~ reg * nutrient * amd + (1 | rack) + (1 | status) + : method = AGQ not yet implemented for supernodal representation I would really appreciate any and all thoughts or leads. Cheers, Hank Stevens version _ platform powerpc-apple-darwin8.6.0 arch powerpc os darwin8.6.0 system powerpc, darwin8.6.0 status major 2 minor 3.1 year 2006 month 06 day01 svn rev38247 language R version.string Version 2.3.1 (2006-06-01) Dr. M. Hank H. Stevens, Assistant Professor 338 Pearson Hall Botany Department Miami University Oxford, OH 45056 Office: (513) 529-4206 Lab: (513) 529-4262 FAX: (513) 529-4243 http://www.cas.muohio.edu/~stevenmh/ http://www.muohio.edu/ecology/ http://www.muohio.edu/botany/ E Pluribus Unum __ R-help@stat.math.ethz.ch 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
[R] Mod function?
Hi Folks! I need to execute a piece of R code inside a loop, say, every fourth time my counter increases (it increases by 1 unit each time.) Is there any sort of mod function in R to do this? Or is this done some other way? Many 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
[R] How add degree character in axis?
Hi user R, I am try to put degree character in axis x, but don't make this. I have the next code: plot(mot[,5], time1,xlim=c(-45,-10),type=l,yaxt=n,ylab=,col=1,lwd=2,xlab=,xaxt=n) The range of value in axis-x is -45 to -10, this values represents the longitudes positions in space. I try to put 45°S for real value (-45) in the axis-x, and for all elements . Anybody can give an advance in this problems. Thank for all -- ** Fernando Espindola Rebolledo Departamento de Evaluacion de Pesquerias Division de Investigacion Pesquera Instituto de Fomento Pesquero Blanco 839 Valparaiso - Chile tel: (+56)-32-322442 http://fespindola.mi-pagina.cl/index.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
[R] Saving dns2.plot as a jpg image
Hello, I am using R 2.2.1 with sn 0.4.0 and am trying to save a dns2.plot as a jpg file. Here is the latest version of the code I have tried: x - seq(0,200,length=200) y - seq(0, 35, length=200) jpeg(filename = C:/fig1.jpg, width = 5, height = 4,pointsize = 12, quality = 100, bg = white, res = NA) par(mfrow=c(1,2),plt=c(.15,.99,.15,.95),mgp=c(1.5,1,0),tcl=-.25,cex.axis=.8) dsn2.plot (x,y,xi=c(29,6),Omega=matrix(c(2580,458,458,84),2),alpha=c(5482940,-2120750)) dst2.plot(x,y, xi=c(29,6),Omega=matrix(c(2065,380,380,72),2),alpha =c(48,-13),df=10) dev.off() I've also tried using graphics.off(). Any help would be greatly appreciated? Thanks, Martin Heller [[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] reverse variables
Hello useRs, Is there a way to reverse values of 2 variables (like with the language Python) ? : a - 1 b - 2 a, b - b, a More specifically, I have a data frame : famnum generation germain1 germain2 fa mo ptpn1 ptpn2 drb11 drb12 1 2 200 201 101 102 1 1 1 1 2 2 200 201 101 102 0 1 1 1 3 2 200 201 101 102 1 0 1 1 ... I don't want 0 in the seventh column, so I would like to have : famnum generation germain1 germain2 fa mo ptpn1 ptpn2 drb11 drb12 1 2 200 201 101 102 1 1 1 1 2 2 201 200 101 102 1 0 1 1 3 2 200 201 101 102 1 0 1 1 ... I thought that a code like this would work : if (ptpn1 == 0 ptpn2 == 1) { germain1, germain2 - germain2, germain1 ptpn1, ptpn2 - ptpn2, ptpn1 drb11, drb12 - drb12n, drb11 } But R is not Python... Is there a way to do it easyly ? Thank you. -- David [[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] apologies if you aready received this ?
On Thu, 8 Jun 2006, [EMAIL PROTECTED] wrote: Hi Everyone : As I mentioned earlier, I am taking a lot of Splus code and turning into R and I've run into another stumbling block that I have not been able to figure out. I did plotting in a loop when I was using Splus on unix and the way I made the plots stop so I could lookat them as they got plotted ( there are hundreds if not thousands getting plotted sequentially ) on the screen was by using the unix() command. People have suggested ways to read stuff from the keyboard already. A simpler solution to the underlying problem may be par(ask=TRUE). However, when I have this problem I usually just send all the plots to a PDF file, so I can page through them at my leisure. -thomas Thomas Lumley Assoc. Professor, Biostatistics [EMAIL PROTECTED] University of Washington, Seattle __ R-help@stat.math.ethz.ch 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] Postscript output encoding on Windows
With R 2.3.1 on Windows, I've noticed that it defaults to the WinAsci.enc encoding, which throws up an error when viewed with the default install of GhostScript/GSView (versions 8.51/4.7 respectively). I didn't have this problem prior to upgrading to 2.3.1 as I can view all my old PS graphs and they don't have the WinAsci encoding. I've got around this problem by adding encoding=CP1251.enc to the postscript call but it seems a little bizarre that the default WinAsci wasn't working. Any ideas what the problem might be? A problem with Ghostscript, a bug in R, or something strange about my installation (there shouldn't be)?? Should WinAsci be the default? Thanks, Jamie __ R-help@stat.math.ethz.ch 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] reverse variables
There is a function here: http://tolstoy.newcastle.edu.au/R/help/04/06/1430.html that will facilitate this sort of construct: a - 1; b - 2 list[b,a] - list(a,b) a; b # 2 1 On 6/9/06, David Hajage [EMAIL PROTECTED] wrote: Hello useRs, Is there a way to reverse values of 2 variables (like with the language Python) ? : a - 1 b - 2 a, b - b, a More specifically, I have a data frame : famnum generation germain1 germain2 fa mo ptpn1 ptpn2 drb11 drb12 1 2 200 201 101 102 1 1 1 1 2 2 200 201 101 102 0 1 1 1 3 2 200 201 101 102 1 0 1 1 ... I don't want 0 in the seventh column, so I would like to have : famnum generation germain1 germain2 fa mo ptpn1 ptpn2 drb11 drb12 1 2 200 201 101 102 1 1 1 1 2 2 201 200 101 102 1 0 1 1 3 2 200 201 101 102 1 0 1 1 ... I thought that a code like this would work : if (ptpn1 == 0 ptpn2 == 1) { germain1, germain2 - germain2, germain1 ptpn1, ptpn2 - ptpn2, ptpn1 drb11, drb12 - drb12n, drb11 } But R is not Python... Is there a way to do it easyly ? Thank you. -- David [[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] How can i add a color bar with base package
Hi, I'm trying to find this for 3 hours now so i come here to find any help. How can I add a color bar to show the color scales to what is generated by image(), similar to the one in figures generated by filled.contour() using only the base package although i know there is solution with contributed package. it's sounds very easy but i can't get it! :-( thanks by advance. --- Yves Magliulo RD Engineer CLIMPACT : www.climpact.com tel : 01 44 27 34 31 [[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] deal with R.package panel
Hi, There should be a 20 page pdf document in the doc directory, distributed with the package. That answers most of these questions. Also, please read the posting guide so that you give enough information to actually have some chance of answering your questions, best wishes Robert Pavel Khomski wrote: hello! my question conserns with use of panel package (written by R.C.Gentlman) (unfortunately the manual and help sites are very short) 1. is it possible to do analysis just without a(ny) covariate? i suggest do it by introducing a covariate with level=0 in all obervations, this because of Q(z)=Q_o exp(beta*z), but it seemingly doesn't work meaning what? 2. in the option gamma in the call of panel function: do you mean an initial value for parameter vector gamma? say if i have 3 theta-parameters, so i have to initialize gamma=c(xxx,xxx,xxx), correct? yes 3. are the (first ) observed times =0 allowed (in $time vectors) or schould in such a case begin with =1, if there are any? I suspect 0, but since you have said nothing about what you are actually trying to do, it is entirely a guess on my part best wishes Robert thanks for your response __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Robert Gentleman, PhD Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M2-B876 PO Box 19024 Seattle, Washington 98109-1024 206-667-7700 [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] Re-binning histogram data
Charles: To be fair ... both histograms and densityplots are nonparametric density estimators whose appearance and effectiveness are dependent on various parameters. Neither are immune from misleading due to a poor choice of the parameters. For histograms they are the bin boundaries; for kde's and friends it is some version of bandwidth. -- Bert -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Charles Annis, P.E. Sent: Thursday, June 08, 2006 7:17 PM To: 'Justin Ashmall'; r-help@stat.math.ethz.ch Subject: Re: [R] Re-binning histogram data Concerning the several comments on your note relating to histograms, an informative and entertaining illustration, using Java, of how your subjective assessment of the data can change with different histograms constructed from the same data, is provided by R. Webster West, recently with the Department of Statistics at the University of South Carolina, but as of May 2006 with the Department of Statistics at Texas A M University, http://www.stat.sc.edu/~west/javahtml/Histogram.html and http://www.stat.tamu.edu/~west/ Charles Annis, P.E. [EMAIL PROTECTED] phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Justin Ashmall Sent: Thursday, June 08, 2006 5:46 AM To: r-help@stat.math.ethz.ch Subject: [R] Re-binning histogram data Hi, Short Version: Is there a function to re-bin a histogram to new, broader bins? Long version: I'm trying to create a histogram, however my input-data is itself in the form of a fine-grained histogram, i.e. numbers of counts in regular one-second bins. I want to produce a histogram of, say, 10-minute bins (though possibly irregular bins also). I suppose I could re-create a data set as expected by the hist() function (i.e. if time t=3600 has 6 counts, add six entries of 3600 to a list) however this seems neither elegant nor efficient (though I'd be pleased to be mistaken!). I could then re-create a histogram as normal. I guessing there's a better solution however! Apologies if this is a basic question - I'm rather new to R and trying to get up to speed. Regards, Justin __ R-help@stat.math.ethz.ch 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-help@stat.math.ethz.ch 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] Saving dns2.plot as a jpg image
You don't say what OS you are using, or whether you are getting any messages or errors. http://www.R-project.org/posting-guide.html Larry Howe On Friday June 9 2006 11:00, Martin Heller wrote: Hello, I am using R 2.2.1 with sn 0.4.0 and am trying to save a dns2.plot as a jpg file. Here is the latest version of the code I have tried: x - seq(0,200,length=200) y - seq(0, 35, length=200) jpeg(filename = C:/fig1.jpg, width = 5, height = 4,pointsize = 12, quality = 100, bg = white, res = NA) par(mfrow=c(1,2),plt=c(.15,.99,.15,.95),mgp=c(1.5,1,0),tcl=-.25,cex.axis=.8 ) dsn2.plot (x,y,xi=c(29,6),Omega=matrix(c(2580,458,458,84),2),alpha=c(5482940,-2120750 )) dst2.plot(x,y, xi=c(29,6),Omega=matrix(c(2065,380,380,72),2),alpha =c(48,-13),df=10) dev.off() I've also tried using graphics.off(). Any help would be greatly appreciated? Thanks, Martin Heller [[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] glm with negative binomial family
I am analysing parasite egg count data and am having trouble with glm with a negative binomial family. In my first data set, 55% of the 3000 cases have a zero count, and the non-zero counts range from 94 to 145,781. Eventually, I want to run bic.glm, so I need to be able to use glm(family= neg.bin(theta)). But first I ran glm.nb to get an estimate of theta: hook.nb- glm.nb(fh, data=hook) This works fine, with no errors, and summary( hook.nb) produces the following: Call: glm.nb(formula = fh, data = hook, init.theta = 0.0938126159640384, link = log) Deviance Residuals: Min1QMedian3Q Max -1.45830 -1.16385 -1.01820 0.00535 2.86513 snip Theta: 0.09381 Std. Err.: 0.00299 2 x log-likelihood: -23750.45300 Then I tried to use this estimate of theta to specify a glm of the negative binomial family but got the following error: hook.fam-glm(fh, data=hook, family=neg.bin(0.09381)) Error: NA/NaN/Inf in foreign function call (arg 1) In addition: Warning message: step size truncated due to divergence When I change theta to be 1 or more, the glm converges (as does bic.glm), so I thought maybe the estimate of theta was wrong. But when I ran a negative binomial regression in Stata, I got the same theta. (theta = 1/alpha = 1/10.65954 = .09381268) In my second set of data, 75% of the cases have zero counts, and the non-zero cases range from 94 - 16,688. In this case, I get errors when I run the glm.nb: asc.nb-glm.nb (fa, data=asc) There were 26 warnings (use warnings() to see them) warnings() Warning messages: 1: algorithm did not converge in: glm.fitter(x = X, y = Y, w = w, etastart = eta, offset = offset, ... exactly the same message in 2-24 25: algorithm did not converge in: glm.fitter(x = X, y = Y, w = w, etastart = eta, offset = offset, ... 26: alternation limit reached in: glm.nb(fa, data = asc) Despite these errors, I do get output: Call: glm.nb(formula = fa, data = asc, init.theta = 0.030379484707051, link = log) Deviance Residuals: Min 1Q Median 3Q Max - 0.949 -0.787 -0.745 -0.645 2.576 snip Theta: 0.03038 Std. Err.: 0.00125 Warning while fitting theta: alternation limit reached 2 x log-likelihood: -15743.70600 Again, this estimate of theta agrees with pretty well with Stata's estimate (theta = 1/alpha = 1/32.45225 = .03081451). But the glm with negative binomial family specification gave the same error as above: asc.fam-glm(fa, data=asc, family=neg.bin(0.0304)) Error: NA/NaN/Inf in foreign function call (arg 1) In addition: Warning message: step size truncated due to divergence Everything runs smoothly when theta is 1 or more, so I don't think anything is wrong with my data (which has no missings and all real numbers). I think the problem must be with theta or with my specification of it. I have the Venables and Ripley book, and am able to run glm(family=negative binomial( 0.03)) and bic.glm(glm.family=negative.binomial(0.03)) on the quine data that comes with MASS. I have looked in the R-help archives and googled, but have not found much besides a few old bug reports (which have been fixed) to help me figure out why one of the glm.nb algorithms did not converge and why both of the glm(family=neg.bin()) calls throw errors. Any ideas? Thanks, Elizabeth [[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] deal with R.package panel
I just realized that the pdf on CRAN is corrupt, a new package has been uploaded and will percolate through over the next few days, one supposes. Robert Gentleman wrote: Hi, There should be a 20 page pdf document in the doc directory, distributed with the package. That answers most of these questions. Also, please read the posting guide so that you give enough information to actually have some chance of answering your questions, best wishes Robert Pavel Khomski wrote: hello! my question conserns with use of panel package (written by R.C.Gentlman) (unfortunately the manual and help sites are very short) 1. is it possible to do analysis just without a(ny) covariate? i suggest do it by introducing a covariate with level=0 in all obervations, this because of Q(z)=Q_o exp(beta*z), but it seemingly doesn't work meaning what? 2. in the option gamma in the call of panel function: do you mean an initial value for parameter vector gamma? say if i have 3 theta-parameters, so i have to initialize gamma=c(xxx,xxx,xxx), correct? yes 3. are the (first ) observed times =0 allowed (in $time vectors) or schould in such a case begin with =1, if there are any? I suspect 0, but since you have said nothing about what you are actually trying to do, it is entirely a guess on my part best wishes Robert thanks for your response __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html -- Robert Gentleman, PhD Program in Computational Biology Division of Public Health Sciences Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N, M2-B876 PO Box 19024 Seattle, Washington 98109-1024 206-667-7700 [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] Postscript output encoding on Windows
It is WinAnsi, not WinAsci, and that may well be your problem. Vanilla R 2.3.1 uses WinAnsi (I have just re-checked), so there is `something strange about my installation'. On Fri, 9 Jun 2006, Jamie Lawrence wrote: With R 2.3.1 on Windows, I've noticed that it defaults to the WinAsci.enc encoding, which throws up an error when viewed with the default install of GhostScript/GSView (versions 8.51/4.7 respectively). I didn't have this problem prior to upgrading to 2.3.1 as I can view all my old PS graphs and they don't have the WinAsci encoding. I've got around this problem by adding encoding=CP1251.enc to the postscript call but it seems a little bizarre that the default WinAsci wasn't working. Any ideas what the problem might be? A problem with Ghostscript, a bug in R, or something strange about my installation (there shouldn't be)?? Should WinAsci be the default? Thanks, Jamie __ R-help@stat.math.ethz.ch 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] glm with negative binomial family
Did you consult the help page for neg.bin? Details: These are not intended to be called by the user. Some are for compatibility with earlier versions of MASS (the book). The book discusses the family negative.binomial() on p.206, and it is that which glm.nb uses. On Fri, 9 Jun 2006, Elizabeth Rainwater wrote: I am analysing parasite egg count data and am having trouble with glm with a negative binomial family. In my first data set, 55% of the 3000 cases have a zero count, and the non-zero counts range from 94 to 145,781. Eventually, I want to run bic.glm, so I need to be able to use glm(family= neg.bin(theta)). But first I ran glm.nb to get an estimate of theta: hook.nb- glm.nb(fh, data=hook) This works fine, with no errors, and summary( hook.nb) produces the following: Call: glm.nb(formula = fh, data = hook, init.theta = 0.0938126159640384, link = log) Deviance Residuals: Min1QMedian3Q Max -1.45830 -1.16385 -1.01820 0.00535 2.86513 snip Theta: 0.09381 Std. Err.: 0.00299 2 x log-likelihood: -23750.45300 Then I tried to use this estimate of theta to specify a glm of the negative binomial family but got the following error: hook.fam-glm(fh, data=hook, family=neg.bin(0.09381)) Error: NA/NaN/Inf in foreign function call (arg 1) In addition: Warning message: step size truncated due to divergence When I change theta to be 1 or more, the glm converges (as does bic.glm), so I thought maybe the estimate of theta was wrong. But when I ran a negative binomial regression in Stata, I got the same theta. (theta = 1/alpha = 1/10.65954 = .09381268) In my second set of data, 75% of the cases have zero counts, and the non-zero cases range from 94 - 16,688. In this case, I get errors when I run the glm.nb: asc.nb-glm.nb (fa, data=asc) There were 26 warnings (use warnings() to see them) warnings() Warning messages: 1: algorithm did not converge in: glm.fitter(x = X, y = Y, w = w, etastart = eta, offset = offset, ... exactly the same message in 2-24 25: algorithm did not converge in: glm.fitter(x = X, y = Y, w = w, etastart = eta, offset = offset, ... 26: alternation limit reached in: glm.nb(fa, data = asc) Despite these errors, I do get output: Call: glm.nb(formula = fa, data = asc, init.theta = 0.030379484707051, link = log) Deviance Residuals: Min 1Q Median 3Q Max - 0.949 -0.787 -0.745 -0.645 2.576 snip Theta: 0.03038 Std. Err.: 0.00125 Warning while fitting theta: alternation limit reached 2 x log-likelihood: -15743.70600 Again, this estimate of theta agrees with pretty well with Stata's estimate (theta = 1/alpha = 1/32.45225 = .03081451). But the glm with negative binomial family specification gave the same error as above: asc.fam-glm(fa, data=asc, family=neg.bin(0.0304)) Error: NA/NaN/Inf in foreign function call (arg 1) In addition: Warning message: step size truncated due to divergence Everything runs smoothly when theta is 1 or more, so I don't think anything is wrong with my data (which has no missings and all real numbers). I think the problem must be with theta or with my specification of it. I have the Venables and Ripley book, and am able to run glm(family=negative binomial( 0.03)) and bic.glm(glm.family=negative.binomial(0.03)) on the quine data that comes with MASS. I have looked in the R-help archives and googled, but have not found much besides a few old bug reports (which have been fixed) to help me figure out why one of the glm.nb algorithms did not converge and why both of the glm(family=neg.bin()) calls throw errors. Any ideas? Thanks, Elizabeth [[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 -- 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
[R] quantile() with weights
Hi list, I'm looking for a way to calculate quantiles (such as in quantile()), but with the ability to assign a different weight to each member of the sample vector. It is possible to write it out completely, but maybe there is a dedicated function out somewhere... cheers Wouter __ R-help@stat.math.ethz.ch 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] X'W in Matrix
Doug, I did mean wX = crossprod(X, W). sorry about that. Thanks for the suggestions and for the *very* useful package. Im still smiling about inverting a 6000x6000 matrix in one second with on line of R code. Best wishes, -r Douglas Bates wrote: On 6/9/06, Rafael A. Irizarry [EMAIL PROTECTED] wrote: Hi! I have used the Matrix package (Version: 0.995-10) successfully to obtain the OLS solution for a problem where the design matrix X is 44000x6000. X is very sparse (about 8 non-zeros elements). Now I want to do WLS: (X'WX)^-1X'Wy I tried W=Diagonal(length(w),w) and wX=solve(X,W) but after various minutes R gives a not enough memory error (Im using a 64bit machine with 16Gigs of RAM). That's an interesting question, Rafael, and very timely. I happen to be visiting Martin Maechler this week and he mentioned to me just a few minutes ago that we should add the capability for sparse least squares calculations to the Matrix package. Just for clarification, did you really mean wX = solve(X, W) above or were you thinking of wX = crossprod(X, W)? I would suggest storing the square root of the diagonal matrix W as a sparse matrix w - abs(rnorm(88000)) ind - seq(along = w) - 1:1 W - as(new(dgTMatrix, i = ind, j = ind, x = sqrt(w), Dim = c(length(w), length(w))), dgCMatrix) str(W) Formal class 'dgCMatrix' [package Matrix] with 6 slots ..@ i : int [1:88000] 0 1 2 3 4 5 6 7 8 9 ... ..@ p : int [1:88001] 0 1 2 3 4 5 6 7 8 9 ... ..@ Dim : int [1:2] 88000 88000 ..@ Dimnames:List of 2 .. ..$ : NULL .. ..$ : NULL ..@ x : num [1:88000] 0.712 0.989 1.032 0.348 0.573 ... ..@ factors : list() (The 1:1 expression in the calculation of ind is a cheap trick to get an integer value of 1 so that ind stays integer). Now you should be able to create wX - W %*% X and wy - W %*% y very quickly. I ended up doing this: wX=Matrix(as.matrix(X)*sqrt(w),sparse=TRUE) coefs1=as.vector(solve(crossprod(wX),crossprod(X,w*y))) which takes about 1-2 minutes, but it seems a better way, using the diagonal matrix, should exist. If there is I'd appreciate hearing it. If not, Im happy waiting 1-2 minute x #of iters. Thanks, Rafael __ R-help@stat.math.ethz.ch 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] How add degree character in axis?
Take a look at ?plotmath. -roger fernando espindola wrote: Hi user R, I am try to put degree character in axis x, but don't make this. I have the next code: plot(mot[,5], time1,xlim=c(-45,-10),type=l,yaxt=n,ylab=,col=1,lwd=2,xlab=,xaxt=n) The range of value in axis-x is -45 to -10, this values represents the longitudes positions in space. I try to put 45°S for real value (-45) in the axis-x, and for all elements . Anybody can give an advance in this problems. Thank for all -- 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
[R] date.mdy in date package
I'm having a problem with output from date.mdy in the date package. Goal: to take a long vector of dates of the form 01/22/99 and extract values month=01, day=22, year=1999. I am providing the vector of class dates in the attached file to date.mdy: mdy_dates-date.mdy(trimmed_dates) The first few obs of the attached vector of dates are: 1 1/2/20032 1/3/20033 1/6/20034 1/7/20035 1/8/20036 1/9/20037 1/10/20038 1/13/20039 1/14/2003 I am expecting to get a list with vectors for the day, month, and year. The function appears to spit out the format I expect (though I would like months/days with leading zeros) but incorrect values, But what I get in the first few lines is something like: mdy_dates $month [1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 [26] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 [51] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 $day [1] 1 2 5 6 7 8 9 12 13 14 15 16 19 20 21 22 23 26 27 28 29 30 2 3 4 [26] 5 6 9 10 11 12 13 16 17 18 19 20 23 24 25 26 27 2 3 4 5 6 9 10 11 [51] 12 13 16 17 18 19 20 23 24 25 26 27 30 31 1 2 3 6 7 8 9 10 13 14 15 $year [1] 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 [16] 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 [31] 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 1993 So: The first day of my list of dates is Jan 2, 2003, but in the list output the first date is Jan 1, 1993. Have I incorrectly formatted my input, or is there some other problem? Thanks in advance. __ __ R-help@stat.math.ethz.ch 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] quantile() with weights
Wouter wrote: Hi list, I'm looking for a way to calculate quantiles (such as in quantile()), but with the ability to assign a different weight to each member of the sample vector. It is possible to write it out completely, but maybe there is a dedicated function out somewhere... cheers Wouter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html See ?wtd.quantile in package Hmisc. --sundar __ R-help@stat.math.ethz.ch 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] quantile() with weights
Wouter wrote: Hi list, I'm looking for a way to calculate quantiles (such as in quantile()), but with the ability to assign a different weight to each member of the sample vector. It is possible to write it out completely, but maybe there is a dedicated function out somewhere... cheers Wouter See ?wtd.quantile in package Hmisc. --sundar __ R-help@stat.math.ethz.ch 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] function parameters - testing
Hello, I am trying to test a function argument to see if it is or is not a useful number. However I cannot seem to find a test that works. For example f = function(x) { + print(exists(x)) + print(is.null(x)) + } rm(x) f(z) [1] TRUE Error in print(is.null(x)) : Object z not found exists gives TRUE, but then any other kind of test I try to run gives me an error. I need a test for existence that will work inside a function. Larry Howe __ R-help@stat.math.ethz.ch 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] function parameters - testing
Larry Howe wrote: Hello, I am trying to test a function argument to see if it is or is not a useful number. However I cannot seem to find a test that works. For example f = function(x) { + print(exists(x)) + print(is.null(x)) + } rm(x) f(z) [1] TRUE Error in print(is.null(x)) : Object z not found exists gives TRUE, but then any other kind of test I try to run gives me an error. I need a test for existence that will work inside a function. Larry Howe This works because x exists in the function f. Perhaps you want this instead? f - function(x) { print(deparse(substitute(x))) print(exists(deparse(substitute(x print(is.null(x)) invisible() } z - 2 f(z) rm(z) f(z) Also, see the where argument in ?exists. HTH, --sundar __ R-help@stat.math.ethz.ch 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 add degree character in axis?
On Fri, 2006-06-09 at 11:01 +, fernando espindola wrote: Hi user R, I am try to put degree character in axis x, but don't make this. I have the next code: plot(mot[,5], time1,xlim=c(-45,-10),type=l,yaxt=n,ylab=,col=1,lwd=2,xlab=,xaxt=n) The range of value in axis-x is -45 to -10, this values represents the longitudes positions in space. I try to put 45°S for real value (-45) in the axis-x, and for all elements . Anybody can give an advance in this problems. Thank for all In general, as Roger noted, see ?plotmath for adding mathematical annotation to R plots. To do the degree symbol is relatively straightforward, but adding the S takes a bit of a trick: # Create vector of x values at - seq(-45, -10, 5) # Create a mock plot plot(at, 1:8, xlim = range(at), xaxt = n) # Now create a set of plotmath expressions, one for # each value of 'at' using paste() and parse() # The general format for the degrees symbol is x*degree # However, to add the S we use the ~ to create # a right and left hand side for the expression and # place the S after it. The ~ will not print. L - parse(text = paste(at, *degree ~ S, sep = )) # Now do the x axis axis(1, at = at, labels = L) 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] glm with negative binomial family
Many thanks to Dr Ripley, who told me to use negative.binomial instead of neg.bin, and to Dr Lancelot, who pointed toward the excellent aod. My models are now converging and the output I am getting seems reasonable. Cheers, Elizabeth On 6/9/06, Prof Brian Ripley [EMAIL PROTECTED] wrote: Did you consult the help page for neg.bin? Details: These are not intended to be called by the user. Some are for compatibility with earlier versions of MASS (the book). The book discusses the family negative.binomial() on p.206, and it is that which glm.nb uses. On 6/9/06, Renaud Lancelot [EMAIL PROTECTED] wrote:Hi Elizabeth, You might want to try the function negbin in package aod (on CRAN) which uses another parameterization (phi = 1 / theta). There are anova and AIC methods for this function in the package. The AIC methods computes AIC and AICc, and setting the argument k to log(n) provides the BIC. Let me know if you meet problems. [[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] function parameters - testing
x exists within the function f so the first print is TRUE; however, exists does not try to evaluate it. is.null does try to evaluate it and so at that point it discovers the error. Perhaps you want this: f - function(x) if (exists(deparse(substitute(x print(is.null(x)) else print(none) if (exists(z)) rm(z) f(z) # none z - 3 f(z) # FALSE z - NULL f(z) # TRUE On 6/9/06, Larry Howe [EMAIL PROTECTED] wrote: Hello, I am trying to test a function argument to see if it is or is not a useful number. However I cannot seem to find a test that works. For example f = function(x) { + print(exists(x)) + print(is.null(x)) + } rm(x) f(z) [1] TRUE Error in print(is.null(x)) : Object z not found exists gives TRUE, but then any other kind of test I try to run gives me an error. I need a test for existence that will work inside a function. Larry Howe __ R-help@stat.math.ethz.ch 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] question about using ancova in R to do variable selection
Hi, I have a microarray data which has about 1 genes and 15 measurements. The 15 measurements contain 6 control, 3 low dose, 3 medium dose, 3 high dose. If I treat the dose level as a continuous variable, how can I use ANCOVA to do gene selection? (I mean to select those genes that response to different level of doses differently?). Thank you very much! James __ [[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] seeing the code that is called inside a function
this is probably a bad question but if you type a function name( the function is from a package ) at an R prompt and you see that the main work of the function is done by a fortran call (.Fortran ), is it possible to see the fortran code ? i am using windows xp and R-2.20 but i doubt that matters. 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
Re: [R] seeing the code that is called inside a function
1. Google for: CRAN mypkg where the package is called mypkg and then download and 2. unpack the .tar.gz from there: tar xfvz mypkg_0.1-1.tar.gz (replace with correct filename) On 6/9/06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: this is probably a bad question but if you type a function name( the function is from a package ) at an R prompt and you see that the main work of the function is done by a fortran call (.Fortran ), is it possible to see the fortran code ? i am using windows xp and R-2.20 but i doubt that matters. 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
[R] interaction terms in regression analysis
G'day, My problem is I'm not sure how to extract effect sizes from a nonlinear regression model with a significant interaction term. My data sets are multiple measurements of force response to an agonist with two superimposed treatments each having two levels. This is very similar to the Ludbrook example in Venables and Ripley. The experiment is that a muscle is exposed to an agonist and the force response is measured. The resulting data is fit to a logistic fit (a three parameter rather than the four parameter used by Ludbrook) . This is done for each combination of two factors (treatmentA and Treatment B) each having two levels (- and +). Each set of measurements is obtained on a muscle from a different animal (i.e. each dose response curve represents an independent experiment). The data are stored as follows: expttreatA treatB dose force I use a groupedData object mydata=groupedData(force ~ dose | expt) I used an nlme obect to model the data as follows (pseudocode): myfit - nlme(force ~ ssThreeParLogistic(dose, upper, ed50,slope), fixed=list(ed50~factor(treatmentA)*factor(treatmentC))) The ThreeParLogistic is a properly debugged and fully functional selfstarting object that I wrote- no problem here. I also included terms for the other terms; upper and slope, but my main focus is on the ed50 so that's all I've included here Running an anova on the resulting object I found theA -/B- (control) to be significantly different from zero, treatment A had no significant effect, treatment B was significantly different and there was a significant interaction between treatment A and treatment B. The interaction term is likely to be real. The treatments are on sequential steps in a pathway and treatment A may be blocking the effect of treatment B, i.e. treatment A alone has no effect because it blocks a pathway that is not active, treatment B reduces force via this pathway and treament A therefore blocks the effect of treatment B when used together. So back to my question How do I extract estimates of the parameters from my model object for a specific combination of factors including the interaction term. i.e. what is the ed50 (and std err) for A-/B-, A+/B-, A-/B+, A+/B+ ? Regards John S. Walker, PhD Department of Physiology Biophysics University of Illinois at Chicago 835 Sth Wolcott Ave MC 901 Chicago IL 60612 USA email: [EMAIL PROTECTED] phone: 1 312 355 0150 fax: 1 312 355 0261 Please avoid sending me Word or PowerPoint attachments. See http://www.fsf.org/philosophy/no-word-attachments.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] function parameters - testing
On Friday June 9 2006 16:06, Sundar Dorai-Raj wrote: Larry Howe wrote: This works because x exists in the function f. Perhaps you want this instead? f - function(x) { print(deparse(substitute(x))) print(exists(deparse(substitute(x print(is.null(x)) invisible() } Your example code works, but when I try to apply it to my function, it does not behave as expected. My variable seems to exist before I pass it into the function, but once inside the function it does not exist. I guess what I need is an in-depth guide to functions: scoping, arguments, parameters, etc. I am also becoming curious about how to pass values out of a function. Can someone point me in the right direction? Larry __ R-help@stat.math.ethz.ch 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] Quantile Regressions/Multi-stage complex survey design
Hello, I am utilizing linear quantile regression models to analyze health survey data. The survey (NHANES) is a multi-stage complex survey and I want to incorporate survey sampling weights in generating my quantile estimates. To my knowledge, this is currently not possible in SAS or STATA. Is there any way to do this in R? If so, how? Thanks! -Kish __ R-help@stat.math.ethz.ch 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] multiple return values and optimization
I have a function (masheff) which returns a value which I can optimize no problem, eg: optimize(masheff, c(15,30), maximum=TRUE, m_gd=5.13, v_tot=41, e_c=1.0) I would like masheff() to return multiple values say as a list with named elements like so: v = masheff(...) v$eff v$extract etc Is there a simple way to do this in an optimize context or would I need to set some global variables and inspect them afterwards? __ R-help@stat.math.ethz.ch 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] multiple return values and optimization
optimize will preserve attributes so try this: f - function(x) structure(x^2, cubed = x^3) optimize(f, c(-1, 1)) On 6/9/06, paul sorenson [EMAIL PROTECTED] wrote: I have a function (masheff) which returns a value which I can optimize no problem, eg: optimize(masheff, c(15,30), maximum=TRUE, m_gd=5.13, v_tot=41, e_c=1.0) I would like masheff() to return multiple values say as a list with named elements like so: v = masheff(...) v$eff v$extract etc Is there a simple way to do this in an optimize context or would I need to set some global variables and inspect them afterwards? __ R-help@stat.math.ethz.ch 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] Regex engine types
version _ platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major2 minor2.1 year 2005 month12 day 20 svn rev 36812 language R grep([W-Z], LETTERS, value = TRUE) [1] W X Y Z That's what I'd have expected. grep([W-Z], letters, value = TRUE) [1] x y z Not what I'd have thought. However, grep([B-D], letters, value = TRUE, perl = TRUE) character(0) So what is it that standard regular expressions use that's different from Perl-type ones? The help file for grep refers to POSIX 1003.2 which looked a bit daunting to delve into. From my limited reading, it seems there are different gegex Engine Types which seems to be getting somewhat tangential to what I was working on. I could probably avoid problems if I always set perl=TRUE, but it would be good to know what basic and extended regular expressions do that's different. If someone has a quick line or two describing it, I'd be interested to know. Thanks -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___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] Math symbols for labels in Perspective plots
Hi .. I would like to have math symbols in perspective plots i tried : persp(x,y,z,xlab=expression(phi)) but it plots it as phi. Thanks. Harsh __ [[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] Regex engine types
I get the same thing on Version 2.3.1 Patched (2006-06-04 r38279) but on R version 2.2.1, 2005-12-20 it gives character(0), as expected, so there is some change between versions of R. I am on Windows XP. On 6/9/06, Patrick Connolly [EMAIL PROTECTED] wrote: version _ platform x86_64-unknown-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu status major2 minor2.1 year 2005 month12 day 20 svn rev 36812 language R grep([W-Z], LETTERS, value = TRUE) [1] W X Y Z That's what I'd have expected. grep([W-Z], letters, value = TRUE) [1] x y z Not what I'd have thought. However, grep([B-D], letters, value = TRUE, perl = TRUE) character(0) So what is it that standard regular expressions use that's different from Perl-type ones? The help file for grep refers to POSIX 1003.2 which looked a bit daunting to delve into. From my limited reading, it seems there are different gegex Engine Types which seems to be getting somewhat tangential to what I was working on. I could probably avoid problems if I always set perl=TRUE, but it would be good to know what basic and extended regular expressions do that's different. If someone has a quick line or two describing it, I'd be interested to know. Thanks -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___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