Re: [R] ipredknn - How may I find values?
On Oct 27, 2009, at 8:37 PM, Grzes wrote: I'm sorry David, this is my code once again: library(klaR) library(ipred) library(mlbench) data(PimaIndiansDiabetes2) dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)] dane[,2]=log(dane[,2]) dane[,1:2]=scale(dane[,1:2]) zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F) klasyfikatorKNN=ipredknn(diabetes~glucose +insulin,data=dane,subset=zbior.uczacy,k=3) oceny=predict(klasyfikatorKNN,dane[-zbior.uczacy,],class) df=data.frame(glucose=c(klasyfikatorKNN$learn$X[, 1]),insulin=klasyfikatorKNN$learn$X[,2],diabetes=c(klasyfikatorKNN $learn$y)) df$diabetes=factor(df$diabetes) drawparti(df$diabetes, df$glucose, df$insulin, method = sknn, prec = 100, xlab = NULL, ylab = NULL) If this had used lattice/grid graphics you would have gotten an object, but this was done with base graphics. If you type drawparti, you get the code. Seems fairly likely that this section could be modified to return the vector that has the information about a particular run: colorw - grouping != khead err - round(mean(colorw), 3) color - ifelse(colorw, col.wrong, col.correct) Why not try adding return(color) or return( matrix( c(color,grouping), ncol=2) ) after that section? I then get this draw.obj - drawparti(df$diabetes, df$glucose, df$insulin, method = sknn, prec = 100, xlab = NULL, ylab = NULL) head(draw.obj) [,1][,2] [1,] red 1 [2,] black 1 [3,] black 1 [4,] black 2 [5,] black 1 [6,] red 1 That seems to capture the information you are requesting. Appears that a red 1 is in one of the red areas, a black 2 is in red. -- David But in my computer everything is ok. The drawparti is in klaR package. Or maybe try like this: drawparti(klasyfikatorKNN$learn$y, df$glucose, klasyfikatorKNN$learn $X[,2], method = sknn, prec = 100, xlab = NULL, ylab = NULL) David Winsemius wrote: On Oct 27, 2009, at 10:18 AM, Grzes wrote: Yes, I want to know which points in my picture are in red or green area. For example: .glucose..insulin.diabetes 609 0.95177272 1.139969011 - I want to know that it's for example: black point in red area red area? 253 -1.05724970 -1.158814331 - it's for example: black point in green area green area? 319 -0.24716002 0.184830541 302 0.69254402 0.132529652 If it's impossible plese give me any package or function which can do it. I already asked what was different about your code that was able to do plotting without error on your machine. -- David Max Kuhn wrote: I think we are having some difficulty understanding what you are looking for. If you are looking to find which of the training samples were closest to the prediction sample, I don't think that you can get it from this function. If this is what you want, I use the dist function in the proxy package. Max On Tue, Oct 27, 2009 at 8:46 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 27, 2009, at 6:02 AM, Grzes wrote: Hi everybody! I want to find a closer neighbourins observation. This is my code: ## library(klaR) library(ipred) library(mlbench) data(PimaIndiansDiabetes2) dane=na.omit(PimaIndiansDiabetes2)[,c(2,5,9)] dane[,2]=log(dane[,2]) dane[,1:2]=scale(dane[,1:2]) zbior.uczacy=sample(1:nrow(dane),nrow(dane)/2,F) klasyfikatorKNN=ipredknn(diabetes~glucose +insulin,data=dane,subset=zbior.uczacy,k=3) oceny=predict(klasyfikatorKNN,dane[-zbior.uczacy,],class) #data frames with my result from klasyfikatorKNN df=data.frame(glucose=c(klasyfikatorKNN$learn$X[, 1]),insulin=klasyfikatorKNN$learn$X[, 2],diabetes=c(klasyfikatorKNN $learn$y)) #And picture drawparti(as.factor(df$diabetes), df$glucose, df$insulin, method = sknn, prec = 100, xlab = NULL, ylab = NULL) I get an error: Error: could not find function drawparti ## My question is: How or where may I find correct or wrong values which were drawn (found,classification) in this picture? No picture resulted. It means I'm looking for x, y values. Not sure exactly what you are asking. Does this modification to df and fairly obvious the cross table help? df=data.frame(glucose=c(klasyfikatorKNN$learn$X[, 1]),insulin=klasyfikatorKNN$learn$X[, 2],pred.diabetes=klasyfikatorKNN$learn$y, trueDiab=dane[,3]) Warning message: In data.frame(glucose = c(klasyfikatorKNN$learn$X[, 1]), insulin = klasyfikatorKNN$learn$X[, : row names were found from a short variable and have been discarded with( df, table(pred.diabetes, trueDiab)) trueDiab pred.diabetes neg pos neg 174 86 pos 88 44 -- View this message in context: http://www.nabble.com/%22ipredknn%22---How-may-I-find-values--tp26074994p26074994.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting
Re: [R] Cannot activate chm help in R 2.10
Charles, not quite in response to your question, but I think a better message in R 2.10 would be to suggest use of help_type=html (which can of course be included in Rprofile.site). While chm is no longer supported, html has been substantially improved and provides new linking facilities between packages. Regards, Ulrike Charles Annis, P.E. wrote: R-insiders: While trying to be clever I inserted these lines in ..\Rprofile.site (which works in R2.9.2 and earlier) # to prefer Compiled HTML help options(chmhelp=TRUE) but upon re-starting R2.10.0 I learned that chmhelp = TRUE is no longer supported: use help_type =text I'm sure this was explained elsewhere but I missed it. Could someone explain why the compiled html help is no longer supported? Thanks. Charles Annis, P.E. charles.an...@statisticalengineering.com phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ulrike Groemping Sent: Tuesday, October 27, 2009 4:17 PM To: r-help@r-project.org Subject: Re: [R] Cannot activate chm help in R 2.10 Uwe Ligges-3 wrote: Duncan Murdoch wrote: On 10/27/2009 10:56 AM, Ulrike Groemping wrote: Duncan Murdoch-2 wrote: Ulrike Groemping wrote: ... My system is Windows XP, German locale computer. On installation, I was asked to decide for text or html help and chose html (there was no radio button for chm help). ... If you set options(help_type=html) you'll get HTML help with links in your default browser. Duncan Murdoch Thank you very much, this works. But I am very surprised that it is not the default. Having chosen html help during installation, I would have expected this to be active without having to change an option. Yes, it should have been, but there was a bug in the installer, and the preference indicated there was ignored. This is why it's useful to have people doing testing during the beta test period: things like this are easy to fix, but they need to be noticed first. Duncan Murdoch And let me add: The whole statistics department has been on two pre-release versions (beta and release-candidate) and nobody reported any error. The installer problem has not been found because I installed from sources anyway. This shows it makes sense to have more than just 400+ beta testers. ;-) Uwe Two more comments: For those of us who have already installed the version with this installer bug: If you do not want to change the option each time you call R, it is easy to change it permanently in the file R_HOME/etc/Rprofile.site (where R_HOME stands for the directory in which your R is installed, e.g. c:\programs\r\r-2.10.0). Regarding beta testing (yes, I admit, I usually leave that to others, and am nevertheless looking for beta testers of my package RcmdrPlugin.DoE), maybe it would be time for an experimental design that specifies characteristics of beta testers to ensure some diversity there, perhaps package DoE.base or FrF2 could help there (half-, but only half-jokingly) ;-) Regards, Ulrike -- View this message in context: http://www.nabble.com/Cannot-activate-chm-help-in-R-2.10-tp26067423p26084237 .html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/Cannot-activate-chm-help-in-R-2.10-tp26067423p26090080.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how do I plot a regression curve with the data?
Ken Ervin wrote: I have a data set of 6 or so ordered pairs, and I've been able to graph them and have decided to use a high-order polynomial regression. I've used the following piece of code: regression - function(x,y) { x - c(insert_numbers_here) y - c(insert_other_numbers_here) fit - lm(y ~ x + I(x^2) + I(x^3) + I(x^4) + I(x^5) + I(x^6) + I(x^7) + I(x^8) + I(x^9)) summary(fit) This gives me the coefficients for the regression very nicely, but I would like to plot both the data and the regression curve together. How do I plot that regression curve as a function, and can I put it on the same set of axes as my data scatter plot? Are you sure that fitting such a high-degree polynomial makes sense? Is there any theory to support the model? If you really want to do this, then use predict.lm(): ## with xmin, xmax as the limits of your scatterplot xx - seq(xmin, xmax, length=51) yy - predict(fit, newdata=list(x=xx)) lines(xx, yy) ## add to scatterplot -Peter Ehlers Thanks in advance for your help! -KE __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] re gression with multiple dependent variables?
thanks for the quick and accurate responses! cheers, Rnewb -- View this message in context: http://www.nabble.com/regression-with-multiple-dependent-variables--tp26088025p26088943.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] need help explain the routine input parameters for seROC and cROC found in the R archive
waverley palo wrote: I found the code in the archive. The author of this script says: The first function (seROC) calculate the standard error of ROC curve, the second function (cROC) compare ROC curves. From: Bernardo Rangel Tura ... The original post has given the definition of the parameters; see http://markmail.org/message/zqjeadvflv2fkumd But also check Frank Harrell's comment on using (nor better: not using) these standard errors. http://markmail.org/message/sy5nlkdl2rk4roxm Dieter -- View this message in context: http://www.nabble.com/need-help-explain-the-routine-input-parameters-for-seROC-and-cROC-found-in-the-R-archive-tp26089482p26090309.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rjava, RImageJ, and/or S4 question.
Hello, On 10/28/2009 12:21 AM, Robert Baer wrote: I am out of my league with this question. The following code starts the java imaging program ImageJ from within R, and displays an image (assuming ImageJ is installed on your computer). It does not assume ImageJ is installed, a version of the imagej jar file is shipped with the package. library(RImageJ) img- IJ$openImage( file.choose() ) #pick an available .tif file img$show()# make the image object visible # An image is now displayed str is not particularly useful in that case. jobj is an external pointer to the java object and jclass is the class name of the object, so IJ is a pointer to an instance of the ij.IJ class. # find out about the objects involved str(IJ) Formal class 'jobjRef' [package rJava] with 2 slots ..@ jobj :externalptr ..@ jclass: chr ij/IJ str(img) Formal class 'jobjRef' [package rJava] with 2 slots ..@ jobj :externalptr ..@ jclass: chr java/lang/Object # now use an IJ java method to find out existing screen size IJ$getScreenSize() [1] Java-Object{java.awt.Dimension[width=1680,height=1050]} What you get here is an object of class java.awt.Dimension, for which the standard java has documentation. http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/awt/Dimension.html You can access the information you want by one of these options: # access the fields width and height of the Dimension object size - IJ$getScreenSize() size$height [1] 1050 size$width [1] 1680 # call methods of the java object size$getHeight() [1] 1050 size$getWidth() [1] 1680 IJ is an instance of the ij.IJ class which is a class of ImageJ, you'll find documentation about it here: http://rsbweb.nih.gov/ij/developer/api/index.html Now if you use a recent version of rJava, you can get completion on java objects, so for example : size$TAB size$clone() size$getClass() size$getSize()size$hashCode() size$notify() size$setSize( size$wait(size$width size$equals( size$getHeight() size$getWidth() size$height size$notifyAll() size$toString() size$wait() You can also query methods and fields of the object this way : .jmethods( size ) [1] public int java.awt.Dimension.hashCode() [2] public boolean java.awt.Dimension.equals(java.lang.Object) [3] public java.lang.String java.awt.Dimension.toString() [4] public java.awt.Dimension java.awt.Dimension.getSize() [5] public void java.awt.Dimension.setSize(double,double) [6] public void java.awt.Dimension.setSize(java.awt.Dimension) [7] public void java.awt.Dimension.setSize(int,int) [8] public double java.awt.Dimension.getHeight() [9] public double java.awt.Dimension.getWidth() [10] public java.lang.Object java.awt.geom.Dimension2D.clone() [11] public void java.awt.geom.Dimension2D.setSize(java.awt.geom.Dimension2D) [12] public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException [13] public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException [14] public final void java.lang.Object.wait() throws java.lang.InterruptedException [15] public final native java.lang.Class java.lang.Object.getClass() [16] public final native void java.lang.Object.notify() [17] public final native void java.lang.Object.notifyAll() .jfields( size ) [1] public int java.awt.Dimension.width [2] public int java.awt.Dimension.height str(IJ$getScreenSize()) Formal class 'jobjRef' [package rJava] with 2 slots ..@ jobj :externalptr ..@ jclass: chr java/lang/Object I am gathering that the RJava library (which is required by the RImageJ library) is using 'slots' which are related to S4 You don't really need to know about that, just consider that these are java objects on which you call methods. My question is whether there is any way to extract the width and height information from the IJ$getScreenSize() command which has the vague appearance of being a string vector size is a java object class( size ) [1] jobjRef attr(,package) [1] rJava typeof( size ) [1] S4 you can get the java class of the object this way: .jclass( size ) [1] java.awt.Dimension size$getClass()$getName() or list but is obviously something far more complex like a java str object? Question 2. Is there recommended reading on how one coerces objects back and forth in this type of situation. For example the ImageJ documentation for the IJ class shows the following for the makeOval method: static void makeOval(int x, int y, int width, int height) Creates an elliptical selection. Here is what happens in R: IJ$makeOval(694, 265, 274, 129); Error in .jrcall(x, name, ...) : Cannot find Java method `makeOval' matching the supplied parameters. You need to either use as.integer to coerce numbers to integers, or use the L notation: IJ$makeOval( as.integer(694), as.integer(265), as.integer(274), as.integer(129) ) IJ$makeOval(694L, 265L, 274L, 129L) This is because:
Re: [R] Detection Times and Poisson Distribution
On Tue, 27 Oct 2009 12:11:42 -0700 (PDT) Ben Bolker bol...@ufl.edu wrote: This is not quite right because we have estimated the rate from the data -- from ?ks.test ... But perhaps not a bad start. Actually, it is a very bad start. Using estimated parameters in tests like ks.test gives you a *completely* wrong distribution of the test statistic and the resulting p-value. Here's a simple example: library(MASS) n=20 r=1 f=function(n,r) { x=rexp(n,rate=r); ks.test(x,pexp,rate=r)$p.value } g=function(n,r) { x=rexp(n,rate=r); ks.test(x,pexp,rate=1/mean(x))$p.value } truehist(replicate(1000, f(n,r)), h=.1, col=wheat) truehist(replicate(1000, g(n,r)), h=.1, col=wheat) Note that increasing the number of observations n does *not* help. Also note that under the null distribution, the parameter estimation mostly has an effect on the power; i.e., it *reduces* the probability of a type I error, and very much so. I'm not sure what the effect under the non- null alternative is, but I know there have been written several papers on this topic. -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] read.table but more tables at once
Dear all, I have a lot of data files (.txt) that I want to read in all at once, if possible. the files have names in time system. for example: RA940101, RA940102, RA940103, RA940104 an so on. (meaning: RA, year:91, month: here january, day of the month.) I tried something like vektor - c(RA940101,RA940102,RA940103) for (x in 1:3) { data - read.table(paste(vektor[x],sep=),header=F) } But how can I put the vektor on the left side, so that data would be instead of data the three first days of the year 1994? best wishes and thanks a lot for your answers, Sybille [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Non-normal residuals.
On Tue, 27 Oct 2009 18:06:02 -0400 Ben Bolker bol...@ufl.edu wrote: If transforming your data brings you closer to satisfying the assumptions of your analytic methods and having a sensible analysis, then that's good. If it makes things worse, that's bad. Other choices, depending on the situation, include robust methods (for outlier problems); generalized linear models etc. (for discrete data from standard distributions); models using t- instead of normally distributed residuals; I have sometimes wondered about this: Which functions/packages do you use to fit a (perhaps just a simple linear) model with t-distributed residuals (or residuals of a different distribution)? -- Karl Ove Hufthammer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] read.table but more tables at once
Hi, Try this, files - paste(RA94010,1:3,sep=) # or files - list.files(pattern = RA94010) list.of.data - lapply(files, read.table, header=F) # if required, collapse into a single data.frame do.call(rbind, list.of.data) HTH, baptiste 2009/10/28 Sybille Wendel wendel.sybi...@googlemail.com: Dear all, I have a lot of data files (.txt) that I want to read in all at once, if possible. the files have names in time system. for example: RA940101, RA940102, RA940103, RA940104 an so on. (meaning: RA, year:91, month: here january, day of the month.) I tried something like vektor - c(RA940101,RA940102,RA940103) for (x in 1:3) { data - read.table(paste(vektor[x],sep=),header=F) } But how can I put the vektor on the left side, so that data would be instead of data the three first days of the year 1994? best wishes and thanks a lot for your answers, Sybille [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] read.table but more tables at once
On Wed, Oct 28, 2009 at 9:38 AM, Sybille Wendel wendel.sybi...@googlemail.com wrote: Dear all, I have a lot of data files (.txt) that I want to read in all at once, if possible. the files have names in time system. for example: RA940101, RA940102, RA940103, RA940104 an so on. (meaning: RA, year:91, month: here january, day of the month.) I tried something like vektor - c(RA940101,RA940102,RA940103) for (x in 1:3) { data - read.table(paste(vektor[x],sep=),header=F) } But how can I put the vektor on the left side, so that data would be instead of data the three first days of the year 1994? Store in a list: data = list() for(x in 1:3){ data[[vektor[x]]] = read.table(...) } then you can do data[[RA940101]] to get that set of data. You can also do this by number: data[[x]] = read.table() and then get data[[1]], data[[2]] etc etc. See any basic R help/tutorial for more information about 'lists'. Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] x11(title=' ')
Dear all I was trying to put a title for my plot, but i got this result, x11(width=10,height=5,title=seedling);par(mfrow=c(1,2))Error in x11(width = 10, height = 5, title = seedling) : unused argument(s) (title = seedling) The title is not taking How can i give a title for the plot (where in need to make 2 plots within a window of x11() ) thanking you in anticipation Warm regard MS Nepal _ WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen3:102009 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] tk_choose.files without multiple selection?
Thanks a lot. I installed tcl8.5 and tk8.5 (version 8.5.6) of ubuntu jaunty (there were no conflicts with dependencies = hardy) and everything works. Regards Marcus -Ursprüngliche Nachricht- Von: Prof Brian Ripley [mailto:rip...@stats.ox.ac.uk] Gesendet: Dienstag, 27. Oktober 2009 22:42 An: Eger, Marcus Cc: r-help@r-project.org Betreff: Re: [R] tk_choose.files without multiple selection? This depends on the version of Tk you have installed. The Tk 8.5.7 ChangeLog has 2008-08-25 Todd M. Helfter t...@users.sourceforge.net The patch is associated with the bug tracker id: 1936220 library/tkfbox.tcl : fix the multiple selection error for tk_getOpenFile -multiple 1 which fails on all unix platforms since the adoption of ttk widgets. for just after 8.5.4. So I suggest you update your OS's Tcl/Tk if it is older than that (and that fix is 14 months old, so one would hope that your OS has updates available). R for Windows ships with 8.5.6, R for Mac OS X with 8.5.5. On Tue, 27 Oct 2009, Eger, Marcus wrote: Dear all, I compared tk_choose.files on linux with choose.files or tk_choose.files on windows and found that tk_choose.files does not allow multiple selection on linux - independent on keyword setting multi. tk_choose.files(default=paste(path.original,,sep=),caption=Selec t file(s)) On linux I get the error message: File list of selected filenames does not exist. I have to click cancel to get out of the dialog. Any ideas? Regards Marcus Windows XP: --- platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 9.2 year 2009 month 08 day24 svn rev49384 language R version.string R version 2.9.2 (2009-08-24) Linux Ubuntu 8.04.3: platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 9.2 year 2009 month 08 day24 svn rev49384 language R version.string R version 2.9.2 (2009-08-24) -- Brian D. Ripley, rip...@stats.ox.ac.uk 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 --- This communication contains confidential information. If you are not the intended recipient please return this email to the sender and delete it from your records. Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht der beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an den Absender zurück und löschen Sie die E-mail aus Ihrem System. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Non-normal residuals.
Karl Ove Hufthammer wrote: On Tue, 27 Oct 2009 18:06:02 -0400 Ben Bolker bol...@ufl.edu wrote: If transforming your data brings you closer to satisfying the assumptions of your analytic methods and having a sensible analysis, then that's good. If it makes things worse, that's bad. Other choices, depending on the situation, include robust methods (for outlier problems); generalized linear models etc. (for discrete data from standard distributions); models using t- instead of normally distributed residuals; I have sometimes wondered about this: Which functions/packages do you use to fit a (perhaps just a simple linear) model with t-distributed residuals (or residuals of a different distribution)? Package sn has this facility I believe. David Scott -- _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] re gression with multiple dependent variables?
Rnewb, Have you given any thought to multivariate linear regression (i.e. MAOVA in which there are multiple dependent variables )? This type of regression makes a number of assumptions beyond the usual regression model including multivariate normality of the outcome variables, but can be very useful in the situation you describe. John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Daniel Malter dan...@umd.edu 10/27/2009 11:17 PM Hi, cbind the dependent variables such as in: x=rnorm(100) e1=rnorm(100) e2=rnorm(100) e3=rnorm(100) y1=2*x+e1 y2=-1*x+e2 y3=0.7*x+e3 reg=lm(cbind(y1,y2,y3)~x) summary(reg) Cheers, Daniel - cuncta stricte discussurus - -Ursprüngliche Nachricht- Von: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Im Auftrag von Rnewb Gesendet: Tuesday, October 27, 2009 9:44 PM An: r-help@r-project.org Betreff: [R] re gression with multiple dependent variables? i have a series of regressions i need to run where everything is the same except for the dependent variable, e.g.: lm(y1 ~ x1+x2+x3+x4+x5, data=data) lm(y2 ~ x1+x2+x3+x4+x5, data=data) lm(y3 ~ x1+x2+x3+x4+x5, data=data) is it possible to run all these regs with a single command? given that the bulk of the work for linear regressions is inverting a matrix that depends only on the independent variables, it seems like a waste to do it over and over for each new dependent variable. thanks, Rnewb -- View this message in context: http://www.nabble.com/regression-with-multiple-dependent-variables--tp260880 25p26088025.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Cannot activate chm help in R 2.10
On 27/10/2009 10:18 PM, Charles Annis, P.E. wrote: R-insiders: While trying to be clever I inserted these lines in ..\Rprofile.site (which works in R2.9.2 and earlier) # to prefer Compiled HTML help options(chmhelp=TRUE) but upon re-starting R2.10.0 I learned that chmhelp = TRUE is no longer supported: use help_type =text I'm sure this was explained elsewhere but I missed it. Could someone explain why the compiled html help is no longer supported? Several reasons. The two that convinced me are: - it is static-only. There's no possibility of dynamic pages, as the other formats support. - it requires tools that are not ours, and that we can't distribute. There are also security concerns with the format. Duncan Murdoch Thanks. Charles Annis, P.E. charles.an...@statisticalengineering.com phone: 561-352-9699 eFax: 614-455-3265 http://www.StatisticalEngineering.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ulrike Groemping Sent: Tuesday, October 27, 2009 4:17 PM To: r-help@r-project.org Subject: Re: [R] Cannot activate chm help in R 2.10 Uwe Ligges-3 wrote: Duncan Murdoch wrote: On 10/27/2009 10:56 AM, Ulrike Groemping wrote: Duncan Murdoch-2 wrote: Ulrike Groemping wrote: ... My system is Windows XP, German locale computer. On installation, I was asked to decide for text or html help and chose html (there was no radio button for chm help). ... If you set options(help_type=html) you'll get HTML help with links in your default browser. Duncan Murdoch Thank you very much, this works. But I am very surprised that it is not the default. Having chosen html help during installation, I would have expected this to be active without having to change an option. Yes, it should have been, but there was a bug in the installer, and the preference indicated there was ignored. This is why it's useful to have people doing testing during the beta test period: things like this are easy to fix, but they need to be noticed first. Duncan Murdoch And let me add: The whole statistics department has been on two pre-release versions (beta and release-candidate) and nobody reported any error. The installer problem has not been found because I installed from sources anyway. This shows it makes sense to have more than just 400+ beta testers. ;-) Uwe Two more comments: For those of us who have already installed the version with this installer bug: If you do not want to change the option each time you call R, it is easy to change it permanently in the file R_HOME/etc/Rprofile.site (where R_HOME stands for the directory in which your R is installed, e.g. c:\programs\r\r-2.10.0). Regarding beta testing (yes, I admit, I usually leave that to others, and am nevertheless looking for beta testers of my package RcmdrPlugin.DoE), maybe it would be time for an experimental design that specifies characteristics of beta testers to ensure some diversity there, perhaps package DoE.base or FrF2 could help there (half-, but only half-jokingly) ;-) Regards, Ulrike __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] compilation options to get install.packages() to invoke tcl/tk
Hi UseRs, I've just installed 2.10.0 on Ubuntu hardy, compiling from the tar.gz bundle. install.packages() just says Error in install.packages() : no packages were specified The normal hardy 2.6.2 version pops up a tcl/tk menu for repositories. I'm assuming I missed a configure option for tcl/tk, but the configure script says that --with-tcltk is the default. Can anybody tell me what I missed please? Cheers, Geoff Russell __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] regression on large file
Dear R community, I have a fairly large file with variables in rows. Every variable (thousands) needs to be regressed on a reference variable. The file is too big to load into R (or R gets too slow having done it) and I do now read in line by line with scan (see below) and write the results to out. Although improved, this is still very slow... Can someone please help me and suggest how I can make this faster? Thank you and best regards, Georg. *** Georg Ehret, Johns Hopkins U, Baltimore MD, USA for (i in 16:nmax){ line-scan(file=paste(file),nlines=1,skip=(i-1),what=integer,sep=,) d-as.numeric(line[-1]) name-line[1] modela - lm(s1~a+a2+b+s+M+W) modelb - lm(s2~a+a2+b+s+M+W+d) modelc - lm(s3~a+2+b+s+M+W+d+d*s) p_main - anova(modela,modelb)$P[2] p_main_i - anova(modela,modelc)$P[2] p_i - anova(modelb,modelc)$P[2] cat(c(name,p_main,p_main_i,p_i),file=paste(out,.txt,sep=),append=T) cat(\n,file=paste(out,.txt,sep=),append=T) } [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] x11(title=' ')
On Wed, 28 Oct 2009, ms.com wrote: Dear all I was trying to put a title for my plot, but i got this result, x11(width=10,height=5,title=seedling);par(mfrow=c(1,2))Error in x11(width = 10, height = 5, title = seedling) : unused argument(s) (title = seedling) The title is not taking How can i give a title for the plot (where in need to make 2 plots within a window of x11() ) thanking you in anticipation Are you perchance x11() on Windows, when you should be using windows()? The posting guide asked you to tell us your OS, amongst other things x11() and X11() on Windows do not have a 'title' argument, as the help file shows, but windows() does. Warm regard MS Nepal _ WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen3:102009 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. PLEASE do read it. -- Brian D. Ripley, rip...@stats.ox.ac.uk 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] compilation options to get install.packages() to invoke tcl/tk
Geoff Russell wrote: Hi UseRs, I've just installed 2.10.0 on Ubuntu hardy, compiling from the tar.gz bundle. install.packages() just says Error in install.packages() : no packages were specified The normal hardy 2.6.2 version pops up a tcl/tk menu for repositories. I'm assuming I missed a configure option for tcl/tk, but the configure script says that --with-tcltk is the default. Can anybody tell me what I missed please? Not off-hand, but it is not supposed not to work; my SUSE build does the pop-up just fine. The output from configure may contain a clue: It should end with something like this R is now configured for x86_64-unknown-linux-gnu Source directory: ../R Installation directory:/usr/local C compiler:gcc -std=gnu99 -g -O2 Fortran 77 compiler: gfortran -g -O C++ compiler: g++ -g -O2 Fortran 90/95 compiler:gfortran -g -O Obj-C compiler: Interfaces supported: X11, tcltk External libraries:readline Additional capabilities: PNG, JPEG, TIFF, NLS, cairo Options enabled: shared BLAS, R profiling, maintainer mode Recommended packages: yes If tcltk is absent, then you have a problem with your build configuration (most likely, development packages for tcl and/or tk are not installed). Further clues can be found earlier in the output. I have: checking for tclConfig.sh... no checking for tclConfig.sh in library (sub)directories... /usr/lib64/tclConfig.sh checking for tkConfig.sh... no checking for tkConfig.sh in library (sub)directories... /usr/lib64/tkConfig.sh checking tcl.h usability... yes checking tcl.h presence... yes checking for tcl.h... yes checking tk.h usability... yes checking tk.h presence... yes checking for tk.h... yes checking whether compiling/linking Tcl/Tk code works... yes -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] regression on large file
On Wed, Oct 28, 2009 at 11:50 AM, Georg Ehret georgeh...@gmail.com wrote: Dear R community, I have a fairly large file with variables in rows. Every variable (thousands) needs to be regressed on a reference variable. The file is too big to load into R (or R gets too slow having done it) and I do now read in line by line with scan (see below) and write the results to out. Although improved, this is still very slow... Can someone please help me and suggest how I can make this faster? Thank you and best regards, Georg. *** Georg Ehret, Johns Hopkins U, Baltimore MD, USA for (i in 16:nmax){ line-scan(file=paste(file),nlines=1,skip=(i-1),what=integer,sep=,) d-as.numeric(line[-1]) name-line[1] modela - lm(s1~a+a2+b+s+M+W) modelb - lm(s2~a+a2+b+s+M+W+d) modelc - lm(s3~a+2+b+s+M+W+d+d*s) p_main - anova(modela,modelb)$P[2] p_main_i - anova(modela,modelc)$P[2] p_i - anova(modelb,modelc)$P[2] cat(c(name,p_main,p_main_i,p_i),file=paste(out,.txt,sep=),append=T) cat(\n,file=paste(out,.txt,sep=),append=T) } Normally you shouldn't try to optimise something until you know where the time is going. It could be that fitting your three linear models is taking most time, in which case there's no point optimising the input/output... But I reckon (and this is a guess) the time is taken by the fact that scan() is having to skip from the start every time. You can confirm this by commenting out all the stuff inside the loop except for the line-scan(...) line. If this still takes ages then we've found the bottleneck. So, what you then do to fix that is to get R to read from a connection - this is an object that you can read from sequentially without having to skip from the start every time. There's examples in help(connections) that will get you going. Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating a sparse matrix from a file
Hi Martin, I followed your example on my set of data. Which has non zero values in 300k positions in 22638 X 80914 sparse matrix. I am able to load data into a field and was able to do some operations (essentially t(m) %*% m). However, when I tried to display the value in the resulted matrix. I am getting below error * Error in asMethod(object) : Cholmod error 'out of memory' at file:../Core/cholmod_memory.c, line 148* The sequence of commands I used are: uac=read.table('C:\\personal\\code\\data\\user_album_count.csv',sep=',' , header=T) library(Matrix) m-sparseMatrix(i=uac[,user],j=uac[,item],x=uac[,count]) cm-t(m) %*% m upto this point, I was able to run, however when I tried to display cm[1,1], I got above error. Kindly let me know if there is anything wrong going on here. Thanks Pallavi On Tue, Oct 27, 2009 at 8:34 PM, Martin Maechler maech...@stat.math.ethz.ch wrote: PP == Pallavi P pallavip...@gmail.com on Tue, 27 Oct 2009 18:13:22 +0530 writes: PP Hi Martin, PP Thanks for the help. Just to make sure I understand correctly. PP The below steps are for creating an example table similar to the one that I PP read from file. yes, exactly n - 22638 m - 80914 nnz - 30 # no idea if this is realistic for you set.seed(101) ex - cbind(i = sample(n,nnz, replace=TRUE), j = sample(m,nnz, replace=TRUE), x = round(100 * rnorm(nnz))) PP and I can understand the way sparseMatrix is initialized right now as M - sparseMatrix(i = ex[,i], j = ex[,j], x = ex[,x]) PP How ever, I couldn't understand the use of below commands. MM. - tcrossprod(M) # == MM' := M %*% t(M) M.1 - M %*% rep(1, ncol(M)) stopifnot(identical(drop(M.1), rowSums(M))) They were just for illustrative purposes, to show how and that you can work with the created sparse matrix 'M'. Regards, Martin Maechler, ETH Zurich PP Kindly let me know if I missed something. PP Thanks PP Pallavi [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] compilation options to get install.packages() to invoke tcl/tk
On Wed, Oct 28, 2009 at 9:27 PM, Peter Dalgaard p.dalga...@biostat.ku.dk wrote: Geoff Russell wrote: Hi UseRs, I've just installed 2.10.0 on Ubuntu hardy, compiling from the tar.gz bundle. install.packages() just says Error in install.packages() : no packages were specified [snip ... ] checking for tk.h... yes checking whether compiling/linking Tcl/Tk code works... yes Ah ... the tcl and tk development packages are not installed be default on Ubuntu hardy .. once installed the tcltk interface shows up on the configure and all should be fine. Many Thanks, Geoff. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] boxplot, data frame and html
Hi, I'm trying put in same page: - a data frame with 3 columns and 45 lines; - a box plot; the code is: require(hwriter) hwrite(t1000[,c(1,5,6)], 'T1000.html', bgcolor='#ffdc98', row.bgcolor='#ffdc98', br=TRUE) p = openPage('T1000.html') hwriteImage('caixa.jpg', p, br=TRUE) hwrite('',p, br=TRUE) closePage(p) but isn't working. What's wrong? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 'R CMD check' fails with evaluation nested too deeply: infinite recursion
I get the error Error : evaluation nested too deeply: infinite recursion / options(expressions=)? during a 'R CMD check ...' on one of my packages. The reason seems to be that this package is mutually dependent on another one (i.e. the DESCRIPTION files of package A lists package B under Depends and vice versa). this might be bad design (having bits in both packages needed by the other), but I believe prior to R 2.9. this did not cause trouble. now the log file of the 'check' is something like Installing *source* package 'roiutils' ... ** R ** exec ** preparing package for lazy loading Loading required package: roiutils Loading required package: fzrutils ===CUT (many more of the same) Loading required package: roiutils Loading required package: fzrutils Loading required package: roiutils Error : evaluation nested too deeply: infinite recursion / options(expressions=)? i.e. it seems that R loads both packages again and again. what am I missing/doing wrong? thanks in advance joerg PS: platform powerpc-apple-darwin8.11.1 arch powerpc os darwin8.11.1 system powerpc, darwin8.11.1 status major 2 minor 9.2 year 2009 month 08 day24 svn rev49384 language R version.string R version 2.9.2 (2009-08-24) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] wilcox.exact() problem
Dear Achim, let me thank you for this assurance! The sample size is too large (~4000 observations per group) to solve this problem exactly. The error message could maybe be improved, but the message is clear: This is too large to deal with. However, this is not a problem. With several thousand observations, standard normal approximations should work sufficiently well. And if you don't believe it, then you can look at approximate solutions that draw a sufficiently large number of permutations. Both is easily available when using wilcox_test() in coin as the startup message of exactRankTests suggests. But in my dataset there are many, many tied ranks between group_1 and group_2 and the other ones. I wanted to use the exact procedure because I read the approximate solution would not give me exact p values in case of tied ranks... Am I paranoid, or am I in search of an exactness statistics cannot deliver? Well, then I'll try permutation tests, and thank you again! Kind regards, David __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how can i call R program from one java program?
Dear All I want to call the R program from one Java program because In my project R program parameters are set by one web page developed by java. Is this possible to call R program from java? many thanks in advance -- Wesley C Mathew [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Generating sequence of dates
Hello All: I have the following question # instantiate a date current = as.Date(2009/10/25) #generate a sequence of dates in the future future_dates = seq(current,by='1 week',length=53) Question: How to generate a sequence of past dates starting one week in the past relative to the current date. Obviously, what I wrote below is not correct. I think I can write a for loop and push each value into a vector. Is this the best way? Thanks. Satish past_dates = seq(current,by=-'1 week',length=156) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how can i call R program from one java program?
On 10/28/2009 12:47 PM, wesley mathew wrote: Dear All I want to call the R program from one Java program because In my project R program parameters are set by one web page developed by java. Is this possible to call R program from java? many thanks in advance Hi, This has many different answers. You can : - use ProcessBuilder to build an R process child from the java process (or System.exec) - use jri to embed R within the same java process. For this you need to install rJava and follow the examples in the jri directory. See http://www.rforge.net/JRI/ http://www.rforge.net/rJava/ - run RServe and connect to it via the java client : http://www.rforge.net/Rserve/ rJava and Rserve share the same mailing list : http://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel where I would suggest you to repost (after you have browsed these options) Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr |- http://tr.im/BcPw : celebrating R commit #5 |- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc `- http://tr.im/yw8E : New R package : sos __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Vector grouping challenge
Dear all, Is there an efficient way to get this list testList - list(c(1),c(2,3,4),c(5,6),c(7),c(8),c(9,10,11,12),c(13)) from this vector testVector - c(12,32,NA,NA,56,NA,78,65,87,NA,NA,NA,90) ? Basically the vector should be grouped, such that non-NA and all following NAs end up in one group. Thanks for any hint, Joh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generating sequence of dates
try this: current = as.Date(2009/10/25) start - seq(current, by='-1 week', length=2)[2] seq(start, by='1 week', length=10) [1] 2009-10-18 2009-10-25 2009-11-01 2009-11-08 2009-11-15 2009-11-22 2009-11-29 2009-12-06 2009-12-13 [10] 2009-12-20 On Wed, Oct 28, 2009 at 7:57 AM, Vadlamani, Satish {FLNA} satish.vadlam...@fritolay.com wrote: Hello All: I have the following question # instantiate a date current = as.Date(2009/10/25) #generate a sequence of dates in the future future_dates = seq(current,by='1 week',length=53) Question: How to generate a sequence of past dates starting one week in the past relative to the current date. Obviously, what I wrote below is not correct. I think I can write a for loop and push each value into a vector. Is this the best way? Thanks. Satish past_dates = seq(current,by=-'1 week',length=156) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplot, data frame and html
Hello Silvano, 'hwrite' appends HTML elements in a web page. The web page has to be opened before adding elements in it. The following code should work: require(hwriter) p = openPage('T1000.html') hwrite(t1000[,c(1,5,6)], p, bgcolor='#ffdc98', row.bgcolor='#ffdc98', br=TRUE) hwriteImage('caixa.jpg', p, br=TRUE) hwrite('', p, br=TRUE) closePage(p) Greg --- Gregoire Pau EMBL Research Officer http://www.ebi.ac.uk/~gpau/ Silvano wrote: Hi, I'm trying put in same page: - a data frame with 3 columns and 45 lines; - a box plot; the code is: require(hwriter) hwrite(t1000[,c(1,5,6)], 'T1000.html', bgcolor='#ffdc98', row.bgcolor='#ffdc98', br=TRUE) p = openPage('T1000.html') hwriteImage('caixa.jpg', p, br=TRUE) hwrite('',p, br=TRUE) closePage(p) but isn't working. What's wrong? Thanks, -- Silvano Cesar da Costa Departamento de Estatística Universidade Estadual de Londrina Fone: 3371-4346 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Vector grouping challenge
Is this what you want: testVector - c(12,32,NA,NA,56,NA,78,65,87,NA,NA,NA,90) # get the breaks at the NAs xb - cumsum(!is.na(testVector)) split(seq(length(testVector)), xb) $`1` [1] 1 $`2` [1] 2 3 4 $`3` [1] 5 6 $`4` [1] 7 $`5` [1] 8 $`6` [1] 9 10 11 12 $`7` [1] 13 On Wed, Oct 28, 2009 at 7:57 AM, Johannes Graumann johannes_graum...@web.de wrote: Dear all, Is there an efficient way to get this list testList - list(c(1),c(2,3,4),c(5,6),c(7),c(8),c(9,10,11,12),c(13)) from this vector testVector - c(12,32,NA,NA,56,NA,78,65,87,NA,NA,NA,90) ? Basically the vector should be grouped, such that non-NA and all following NAs end up in one group. Thanks for any hint, Joh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Generating sequence of dates
Thanks. Please expect more newbie questions!! Satish -Original Message- From: jim holtman [mailto:jholt...@gmail.com] Sent: Wednesday, October 28, 2009 7:05 AM To: Vadlamani, Satish {FLNA} Cc: R-help@r-project.org Subject: Re: [R] Generating sequence of dates try this: current = as.Date(2009/10/25) start - seq(current, by='-1 week', length=2)[2] seq(start, by='1 week', length=10) [1] 2009-10-18 2009-10-25 2009-11-01 2009-11-08 2009-11-15 2009-11-22 2009-11-29 2009-12-06 2009-12-13 [10] 2009-12-20 On Wed, Oct 28, 2009 at 7:57 AM, Vadlamani, Satish {FLNA} satish.vadlam...@fritolay.com wrote: Hello All: I have the following question # instantiate a date current = as.Date(2009/10/25) #generate a sequence of dates in the future future_dates = seq(current,by='1 week',length=53) Question: How to generate a sequence of past dates starting one week in the past relative to the current date. Obviously, what I wrote below is not correct. I think I can write a for loop and push each value into a vector. Is this the best way? Thanks. Satish past_dates = seq(current,by=-'1 week',length=156) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] x11(title=' ')
On 10/28/2009 09:51 PM, Prof Brian Ripley wrote: ... Are you perchance x11() on Windows, when you should be using windows()? The posting guide asked you to tell us your OS, amongst other things I say, my dear professor, if this MS chap who has used a Microsoft email client and a Microsoft email service turns out to be using Linux, he's covered his tracks pretty well. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Vector grouping challenge
Just so. I got until 'split' but was stuck on how to get the breaks ... Thank you! Joh jim holtman wrote: Is this what you want: testVector - c(12,32,NA,NA,56,NA,78,65,87,NA,NA,NA,90) # get the breaks at the NAs xb - cumsum(!is.na(testVector)) split(seq(length(testVector)), xb) $`1` [1] 1 $`2` [1] 2 3 4 $`3` [1] 5 6 $`4` [1] 7 $`5` [1] 8 $`6` [1] 9 10 11 12 $`7` [1] 13 On Wed, Oct 28, 2009 at 7:57 AM, Johannes Graumann johannes_graum...@web.de wrote: Dear all, Is there an efficient way to get this list testList - list(c(1),c(2,3,4),c(5,6),c(7),c(8),c(9,10,11,12),c(13)) from this vector testVector - c(12,32,NA,NA,56,NA,78,65,87,NA,NA,NA,90) ? Basically the vector should be grouped, such that non-NA and all following NAs end up in one group. Thanks for any hint, Joh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Vector grouping challenge
What the breaks are is that you are looking to see where the NAs start. In your case, you wanted the value at the start of the NA string to be grouped with the following NAs. The 'is.na' will return TRUE for NAs and if you invert the vector, you will have TRUE for each of the non-NA values. By doing the 'cumsum' you will get the same values for the NAs that follow a non-NA: is.na(testVector) [1] FALSE FALSE TRUE TRUE FALSE TRUE FALSE FALSE FALSE TRUE TRUE TRUE FALSE cumsum(!is.na(testVector)) [1] 1 2 2 2 3 3 4 5 6 6 6 6 7 The result of the 'cumsum' is then then grouping factor for split. HTH On Wed, Oct 28, 2009 at 8:43 AM, Johannes Graumann johannes_graum...@web.de wrote: Just so. I got until 'split' but was stuck on how to get the breaks ... Thank you! Joh jim holtman wrote: Is this what you want: testVector - c(12,32,NA,NA,56,NA,78,65,87,NA,NA,NA,90) # get the breaks at the NAs xb - cumsum(!is.na(testVector)) split(seq(length(testVector)), xb) $`1` [1] 1 $`2` [1] 2 3 4 $`3` [1] 5 6 $`4` [1] 7 $`5` [1] 8 $`6` [1] 9 10 11 12 $`7` [1] 13 On Wed, Oct 28, 2009 at 7:57 AM, Johannes Graumann johannes_graum...@web.de wrote: Dear all, Is there an efficient way to get this list testList - list(c(1),c(2,3,4),c(5,6),c(7),c(8),c(9,10,11,12),c(13)) from this vector testVector - c(12,32,NA,NA,56,NA,78,65,87,NA,NA,NA,90) ? Basically the vector should be grouped, such that non-NA and all following NAs end up in one group. Thanks for any hint, Joh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cross-over designs
Hi, I have a dataset from a client where the data is from a cross-over design. Basically, each subject in a survey was asked to rate two products, A and B. The subject sampled A first and then after an appropriate wash-out period he/she sampled B. The next subject did the same, but in a different order. How can I do an ANOVA analysis on a cross-over design with only two treatments. This is also a balanced design Thanks, Walt -- Walter R. Paczkowski, Ph.D. Data Analytics Corp. 44 Hamilton Lane Plainsboro, NJ 08536 (V) 609-936-8999 (F) 609-936-3733 w...@dataanalyticscorp.com www.dataanalyticscorp.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] WAR file installation
I know of one called Biocep / Virtual R workbench! Info here: http://www.ebi.ac.uk/microarray-srv/frontendapp/ Best, Parthiban. 2009/10/27 Cedrick W. Johnson cedr...@cedrickjohnson.com WAR files are strictly in the J2EE realm, not something related to R. You have to install your choice of app server and write java code that either uses something similar to RServe or fancy footwork using the underlying system commands to interact with R. I don't have the link off the top of my head/home computer, but someone did write an R / Web interface (using J2EE/Struts). Perhaps someone else on the list can help? rgds, cedrick -- = *Cedrick W. Johnson* **note new updated phone #'s office) 203.340.3442 cell) 646.434.8052 aolim) cedrickjcvgr www.cedrickjohnson.com *New York - Chicago* Madan Mohan wrote: Hi Friends, Currently i am using R-2.9.1. I am new to R and i am in learning stage. Can any one tell me whether R allows WAR file installation? Other concerns i have are: 1. Does R allows WAR file installation? 2. Does R has a web server or application server concept? 3. Can we create login credentials in R? Kindly clarify these things... Regards, Madana ** __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] HoltWinters function
Hi David, I am facing some issues with the HoltWinters function in R (v2.9.2). I am doing time series analysis using this method. For the time series data that I used, (alpha,beta,gamma) parameters came out to be (1,0,0). I think this theoretically should mean that the predicted timeseries values will be constant. But the predicted values were not coming out to be constant. What does this mean ? One more point is that when I ran the same code in older version(v2.8.x), I got different parameter values and different predicted values. Was there any change in HoltWinters function? Below is my R window text: a=as.matrix(read.table(embedded_mani1.txt)) K=dim(a)[2] N=dim(a)[1] ts1=ts(a, frequency=7, start=c(1,1)) Holtwinters with start.period=7 params = matrix(nrow=3,ncol=K) prediction=matrix(0,nrow=K,ncol=28) ts_result=HoltWinters(ts1[,1], start.periods =7) params[,1]=c(ts_result$alpha,ts_result$beta,ts_result$gamma) print(params) [,1] [,2] [,3] [,4] [1,]1 NA NA NA [2,]0 NA NA NA [3,]0 NA NA NA pre=predict(ts_result,28,se.fit=FALSE) head(pre) [1] 0.2703228 1.0252342 1.4506853 1.3881035 1.3030489 1.0624612 Please give your comments on this. Regards, Karthik, Graduate Student, Georgia Tech. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Non-normal residuals.
There is also the tlm() function in hett package for fitting linear models under t-distributed, heteroscedastic errors. Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty_personal_pages/Varadhan.h tml -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of David Scott Sent: Wednesday, October 28, 2009 6:26 AM To: Karl Ove Hufthammer Cc: r-h...@stat.math.ethz.ch Subject: Re: [R] Non-normal residuals. Karl Ove Hufthammer wrote: On Tue, 27 Oct 2009 18:06:02 -0400 Ben Bolker bol...@ufl.edu wrote: If transforming your data brings you closer to satisfying the assumptions of your analytic methods and having a sensible analysis, then that's good. If it makes things worse, that's bad. Other choices, depending on the situation, include robust methods (for outlier problems); generalized linear models etc. (for discrete data from standard distributions); models using t- instead of normally distributed residuals; I have sometimes wondered about this: Which functions/packages do you use to fit a (perhaps just a simple linear) model with t-distributed residuals (or residuals of a different distribution)? Package sn has this facility I believe. David Scott -- _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142,NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Non-normal residuals.
On Wed, Oct 28, 2009 at 7:25 AM, David Scott d.sc...@auckland.ac.nz wrote: Karl Ove Hufthammer wrote: On Tue, 27 Oct 2009 18:06:02 -0400 Ben Bolker bol...@ufl.edu wrote: If transforming your data brings you closer to satisfying the assumptions of your analytic methods and having a sensible analysis, then that's good. If it makes things worse, that's bad. Other choices, depending on the situation, include robust methods (for outlier problems); generalized linear models etc. (for discrete data from standard distributions); models using t- instead of normally distributed residuals; I have sometimes wondered about this: Which functions/packages do you use to fit a (perhaps just a simple linear) model with t-distributed residuals (or residuals of a different distribution)? Package sn has this facility I believe. Yes, for independent data, but for time series??? Kjetil David Scott -- _ David Scott Department of Statistics The University of Auckland, PB 92019 Auckland 1142, NEW ZEALAND Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055 Email: d.sc...@auckland.ac.nz, Fax: +64 9 373 7018 Director of Consulting, Department of Statistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] MLE for lambda of Poisson distribution using fitdistr
In general Poisson data consists of a pair of numbers (y,n), where y is the event count for the unit and n is the size of the unit. The Poisson MLE is sum(y)/sum(n). A general example is county level data where y is the number of events (rare cancer) and n is the county size. Two special cases are where n==1 for all cases and the mle=mean(y), or where y==1 for all subjects and n= observation time until the first event, where mle=1/mean(n). My preferred way to fit the distribution is glm( y ~ offset(log(n)) + other covariates, family=poisson) because of the mature printout,standard errors, residuals, etc. The other covariates are optional of course. If n=1 for all observations the offset can be omitted. Terry Therneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating a sparse matrix from a file
PP == Pallavi P pallavip...@gmail.com on Wed, 28 Oct 2009 16:30:25 +0530 writes: PP Hi Martin, PP I followed your example on my set of data. Which has non zero values in PP 300k positions in 22638 X 80914 sparse matrix. I am able to load data into a PP field and was able to do some operations (essentially t(m) %*% m). However, PP when I tried to display the value in the resulted matrix. I am getting below PP error PP * PP Error in asMethod(object) : PP Cholmod error 'out of memory' at file:../Core/cholmod_memory.c, line 148* PP The sequence of commands I used are: uac=read.table('C:\\personal\\code\\data\\user_album_count.csv',sep=',' , PP header=T) library(Matrix) m-sparseMatrix(i=uac[,user],j=uac[,item],x=uac[,count]) cm-t(m) %*% m The above is less efficient than cm - crossprod(m) please use the latter {not just for sparse matrices; for all matrices in R !} PP upto this point, I was able to run, however when I tried to display cm[1,1], PP I got above error. Kindly let me know if there is anything wrong going on PP here. Interestingly, we had a recent thread on R-devel, which also made a point about excessive memory usage when accessing elements of a sparse matrix. I'd really like to investigate further; but can you ***PLEASE*** use reproducible code, i.e., similar to the one I used, rather than reading data from one of your files. Note that your matrix is still fine and should be able to work with it, even thoug it seems the operation a - cm[1,1] is currently implemented very sub-optimally. I'm busy for the rest of today with other duties, but am looking forward to receive **reproducible** code from you, by tonight. Also, please do not forget to also show the result of sessionInfo() ! Martin Maechler, PP Thanks PP Pallavi PP On Tue, Oct 27, 2009 at 8:34 PM, Martin Maechler maech...@stat.math.ethz.ch wrote: PP == Pallavi P pallavip...@gmail.com on Tue, 27 Oct 2009 18:13:22 +0530 writes: PP Hi Martin, PP Thanks for the help. Just to make sure I understand correctly. PP The below steps are for creating an example table similar to the one that I PP read from file. yes, exactly n - 22638 m - 80914 nnz - 30 # no idea if this is realistic for you set.seed(101) ex - cbind(i = sample(n,nnz, replace=TRUE), j = sample(m,nnz, replace=TRUE), x = round(100 * rnorm(nnz))) PP and I can understand the way sparseMatrix is initialized right now as M - sparseMatrix(i = ex[,i], j = ex[,j], x = ex[,x]) PP How ever, I couldn't understand the use of below commands. MM. - tcrossprod(M) # == MM' := M %*% t(M) M.1 - M %*% rep(1, ncol(M)) stopifnot(identical(drop(M.1), rowSums(M))) They were just for illustrative purposes, to show how and that you can work with the created sparse matrix 'M'. Regards, Martin Maechler, ETH Zurich PP Kindly let me know if I missed something. PP Thanks PP Pallavi PP Hi Martin,brbrI followed your example on my set of data. Which has non zero values in 300k positions in 22638 X 80914 sparse matrix. I am able to load data into a field and was able to do some operations (essentially t(m) %*% m). However, when I tried to display the value in the resulted matrix. I am getting below errorbr PP bbrError in asMethod(object) : br Cholmod error #39;out of memory#39; at file:../Core/cholmod_memory.c, line 148/bbrbrThe sequence of commands I used are:brbrgt;uac=read.table(#39;C:\\personal\\code\\data\\user_album_count.csv#39;,sep=#39;,#39; , header=T)br PP gt;library(Matrix)brgt;mlt;-sparseMatrix(i=uac[,quot;userquot;],j=uac[,quot;itemquot;],x=uac[,quot;countquot;])brgt;cmlt;-t(m) %*% mbrupto this point, I was able to run, however when I tried to display cm[1,1], I got above error. Kindly let me know if there is anything wrong going on here.br PP brThanksbrPallavibrbrdiv class=gmail_quoteOn Tue, Oct 27, 2009 at 8:34 PM, Martin Maechler span dir=ltrlt;a href=mailto:maech...@stat.math.ethz.ch;maech...@stat.math.ethz.ch/agt;/span wrote:brblockquote class=gmail_quote style=border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex; PP gt;gt;gt;gt;gt; quot;PPquot; == Pallavi P lt;a href=mailto:pallavip...@gmail.com;pallavip...@gmail.com/agt;br PP gt;gt;gt;gt;gt; on Tue, 27 Oct 2009 18:13:22 +0530 writes:br PP br PP PPgt; Hi Martin,br PP PPgt; Thanks for the help. Just to make sure I understand correctly.br PP br PP PPgt; The below steps are for creating an example table similar to the one that Ibr PP PPgt; read from file.br PP br PP yes, exactlybr PP div class=imbr PP n lt;- 22638br PP m lt;- 80914br
Re: [R] GGPLOT2 Different Layers Different X Values
Hi John, Could you please provide a small reproducible example? Thanks, Hadley Sent from my iPhone On 26/10/2009, at 6:50 PM, Jonathan Bleyhl jonathan_ble...@affymetrix.com wrote: I'm trying to plot values based on a date and then overlay a histogram also by date. The problem is that both data sets don't have exactly the same dates. So when I add the histogram, any dates that aren't already there from from the scatter plot just get tacked on at the end and are out of order. I tried using scale_x_discrete, but to no avail. Thanks, Jon -- View this message in context: http://www.nabble.com/GGPLOT2-Different-Layers-Different-X-Values-tp26069893p26069893.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Regex matching that gives byte offset?
Hi, Is there any way of doing 'grep' ore something like it on the content of a text file and extract the byte positioning of the match in the file? I'm facing the need to access rather largish (600MB) XML files and would like to be able to index them ... Thanks for any help or flogging, Joh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Reading data
Hi User's, This might be a simple question but it is giving me a hard time as I am a new user. I installed R version 2.9.2 (2009-08-24) 1. I just copied a short script from Fox (2002) as a practice and wanted to save it as Rossi.R. The system saved it without complain but when I looked at using a windows explorer it is not *.R file but only Rossi. Why this is happening? 2. the script and the data files are in the same working directory. When I run the following script Rossi - read.table('Rossi',header=T) Rossi[1:5,1:10] I got the following error messages Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Rossi[1:5,1:10] Error: object 'Rossi' not found Thank you for your help in advance Val [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Antropometrics with R
You might want to take a look at this article by WEI, PERE, KOENKER, AND HE. Its in the research files of Koenker who is a regular contributor to R-help: http://www.econ.uiuc.edu/~roger/research/growth/growth.pdf In particular it mentions lmsqreg, which would be a package that implements the L M S methodology used by the CDC to produce these files. the above paper discusses that package as a starting point and then offers an alternative using quantreg. The lmsqreg package can be acquired with this code: install.packages(lmsqreg, repos=http://R-Forge.R-project.org;) library(lmsqreg) There is a function, zscores, that might illustrate how to apply the L, M, S columns in those CDC datasets. You might consider posting on the Bioconductor list if these queries are unsuccessfl or contacting Vincent Carey, who is a Bioconductor Core member and appears to have done quite a bit of work in related areas: http://biosun1.harvard.edu/~carey/ (I have taken the liberty of correcting the spelling of the subject line so it can be found on searches more easily. Seems possible that searching with that alternate spelling might improve your subsequent searches as well.) -- David On Oct 28, 2009, at 3:24 AM, Orvalho Augusto wrote: Thanks! Yes I want a program in R that uses that data and produce percentiles and z-scores. Is there any ready program or not? Caveman On Wed, Oct 28, 2009 at 2:16 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 27, 2009, at 7:27 PM, Orvalho Augusto wrote: Hey greate ones, is there any way to have something similar to stata zanthro on R? I suppose it is possible that someone will know what is in that stata package, but it would make more sense if you were to summarize what features would be of use. I want a package that contains functions to give antropometric values, at least for the children. You are perhaps trying to map ht, weight, and head circumference to age-specific percentiles??? http://www.cdc.gov/growthcharts/percentile_data_files.htm -- David Winsemius, MD Heritage Laboratories West Hartford, CT David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data
Hi Val, I am not sure what it is that you are trying to do. read.table Is not used to open an R script, but to open a data file. You will also need to give the extension of the file when using the command (someone please correct me if I am wrong). If you wish to open an R script, I would just use the GUI menu and use: file - open script and find your script to open. Good luck, Tal -- My contact information: Tal Galili E-mail: tal.gal...@gmail.com Phone number: 972-52-7275845 FaceBook: Tal Galili My Blogs: http://www.talgalili.com (Web and general, Hebrew) http://www.biostatistics.co.il (Statistics, Hebrew) http://www.r-statistics.com/ (Statistics,R, English) On Wed, Oct 28, 2009 at 4:04 PM, Val valkr...@gmail.com wrote: Hi User's, This might be a simple question but it is giving me a hard time as I am a new user. I installed R version 2.9.2 (2009-08-24) 1. I just copied a short script from Fox (2002) as a practice and wanted to save it as Rossi.R. The system saved it without complain but when I looked at using a windows explorer it is not *.R file but only Rossi. Why this is happening? 2. the script and the data files are in the same working directory. When I run the following script Rossi - read.table('Rossi',header=T) Rossi[1:5,1:10] I got the following error messages Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Rossi[1:5,1:10] Error: object 'Rossi' not found Thank you for your help in advance Val [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cross-over designs
Data Analytics Corp. wrote: Hi, I have a dataset from a client where the data is from a cross-over design. Basically, each subject in a survey was asked to rate two products, A and B. The subject sampled A first and then after an appropriate wash-out period he/she sampled B. The next subject did the same, but in a different order. How can I do an ANOVA analysis on a cross-over design with only two treatments. This is also a balanced design Thanks, Walt The hard bit is often to knock data into the right format. Assuming that you have a data in a data frame mydata in long format like this ID product period score 1 A 1 2,3 1 B 2 3.4 10 B 1 5.6 10 A 2 7.8 then this should do the trick: summary(aov(score~A*B+Error(ID),data=mydata)) Alternatively, you can do it with t-tests comparing differences within ID between the two product orderings. The test for main effect of product can be obtained as a test of whether 1st - 2nd depends on whether A or B came first, and vice-versa for the main effect of period. The interaction test (carry-over, etc.) is obtained as a test of whether the _sum_ of the two scores is order-dependent. (Cynics may point out that it is usually no great loss just to do a paired t-test, since period effects are usually weak and interactions mostly undetectable in such designs.) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data
Hi Val, Windows does not display extensions by default. Check the 'Type' column; it should read 'R file'. Keep in mind what you are dealing with; Rossi.R is a script, so you cannot open it with read.table. You have to use source() for that. Moreover, use the extension, as well (Rossi.R, not Rossi) Cheers! On Wed, Oct 28, 2009 at 3:04 PM, Val valkr...@gmail.com wrote: Hi User's, This might be a simple question but it is giving me a hard time as I am a new user. I installed R version 2.9.2 (2009-08-24) 1. I just copied a short script from Fox (2002) as a practice and wanted to save it as Rossi.R. The system saved it without complain but when I looked at using a windows explorer it is not *.R file but only Rossi. Why this is happening? 2. the script and the data files are in the same working directory. When I run the following script Rossi - read.table('Rossi',header=T) Rossi[1:5,1:10] I got the following error messages Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Rossi[1:5,1:10] Error: object 'Rossi' not found Thank you for your help in advance Val [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data
On Oct 28, 2009, at 10:04 AM, Val wrote: Hi User's, This might be a simple question but it is giving me a hard time as I am a new user. I installed R version 2.9.2 (2009-08-24) 1. I just copied a short script from Fox (2002) as a practice and wanted to save it as Rossi.R. How? The system saved it without complain but when I looked at using a windows explorer it is not *.R file but only Rossi. Why this is happening? If you were to include the code, we perhaps could tell you. In its default mode Windows may be hiding the extension from you. (Or possibly because R does not postpend file types and (I am now guessing here about a package I have not used and don't even know if you are) neither does Rcmdr.) 2. the script and the data files are in the same working directory. When I run the following script Rossi - read.table('Rossi',header=T) No path specification. And ??? thought you said it was a script, which would have been loaded with source() Rossi[1:5,1:10] But this suggests you are using it as data. What do you get when your type this: getwd() Maybe if you tried (untested)... Nah ... not going to do further guessing. Read the posting guide and supply the missing elements. I got the following error messages Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Rossi[1:5,1:10] Error: object 'Rossi' not found Thank you for your help in advance Val -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] regression on large file
bigmemory and biglm packages may be of your interest. b On Oct 28, 2009, at 8:50 AM, Georg Ehret wrote: Dear R community, I have a fairly large file with variables in rows. Every variable (thousands) needs to be regressed on a reference variable. The file is too big to load into R (or R gets too slow having done it) and I do now read in line by line with scan (see below) and write the results to out. Although improved, this is still very slow... Can someone please help me and suggest how I can make this faster? Thank you and best regards, Georg. *** Georg Ehret, Johns Hopkins U, Baltimore MD, USA for (i in 16:nmax){ line- scan(file=paste(file),nlines=1,skip=(i-1),what=integer,sep=,) d-as.numeric(line[-1]) name-line[1] modela - lm(s1~a+a2+b+s+M+W) modelb - lm(s2~a+a2+b+s+M+W+d) modelc - lm(s3~a+2+b+s+M+W+d+d*s) p_main - anova(modela,modelb)$P[2] p_main_i - anova(modela,modelc)$P[2] p_i - anova(modelb,modelc)$P[2] cat (c(name,p_main,p_main_i,p_i),file=paste(out,.txt,sep=),append=T) cat(\n,file=paste(out,.txt,sep=),append=T) } [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] structural equation modeling
Dear R-help, I am interested in using structural equation modeling. Just getting started with it, but I'm looking for suggestions for packages. As an aside, what's the best way for looking for packages at CRAN? -- Robert Terwilliger Biomedical Physicist Laboratory of Neurocognitive Development Western Psychiatric Institute and Clinic University of Pittsburgh Medical Center Loeffler Building 121 Meyran Avenue #114 Pittsburgh, PA 15213 412.383.8174 - Office 412.383.8179 - Fax em: rater...@gmail.com http://www.wpic.pitt.edu/research/lncd/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] structural equation modeling
On 10/28/2009 10:37 AM, Robert Terwilliger wrote: Dear R-help, I am interested in using structural equation modeling. Just getting started with it, but I'm looking for suggestions for packages. As an aside, what's the best way for looking for packages at CRAN? The task views are great: see http://cran.r-project.org/web/views/. Google is also good: searching for CRAN structural equation models took me to both the econometrics and psychometrics task views, among other things. Duncan Murdoh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cross-over designs
Peter Dalgaard wrote: Data Analytics Corp. wrote: Hi, I have a dataset from a client where the data is from a cross-over design. Basically, each subject in a survey was asked to rate two products, A and B. The subject sampled A first and then after an appropriate wash-out period he/she sampled B. The next subject did the same, but in a different order. How can I do an ANOVA analysis on a cross-over design with only two treatments. This is also a balanced design Thanks, Walt The hard bit is often to knock data into the right format. Assuming that you have a data in a data frame mydata in long format like this ID product period score 1 A 1 2,3 1 B 2 3.4 10 B 1 5.6 10 A 2 7.8 then this should do the trick: summary(aov(score~A*B+Error(ID),data=mydata)) Oops, make that product*period, not A*B. And make sure that ID, product, and period are factors. Alternatively, you can do it with t-tests comparing differences within ID between the two product orderings. The test for main effect of product can be obtained as a test of whether 1st - 2nd depends on whether A or B came first, and vice-versa for the main effect of period. The interaction test (carry-over, etc.) is obtained as a test of whether the _sum_ of the two scores is order-dependent. (Cynics may point out that it is usually no great loss just to do a paired t-test, since period effects are usually weak and interactions mostly undetectable in such designs.) -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - (p.dalga...@biostat.ku.dk) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] structural equation modeling
There is the 'sem' package: http://cran.r-project.org/web/packages/sem/index.html The task views (http://cran.r-project.org/web/views/) are often a good place to start when looking for particular techniques/methods. Best, -- Wolfgang Viechtbauerhttp://www.wvbauer.com/ Department of Methodology and StatisticsTel: +31 (0)43 388-2277 School for Public Health and Primary Care Office Location: Maastricht University, P.O. Box 616 Room B2.01 (second floor) 6200 MD Maastricht, The Netherlands Debyeplein 1 (Randwyck) From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of Robert Terwilliger [rater...@gmail.com] Sent: Wednesday, October 28, 2009 3:37 PM To: r-help@r-project.org Subject: [R] structural equation modeling Dear R-help, I am interested in using structural equation modeling. Just getting started with it, but I'm looking for suggestions for packages. As an aside, what's the best way for looking for packages at CRAN? -- Robert Terwilliger Biomedical Physicist Laboratory of Neurocognitive Development Western Psychiatric Institute and Clinic University of Pittsburgh Medical Center Loeffler Building 121 Meyran Avenue #114 Pittsburgh, PA 15213 412.383.8174 - Office 412.383.8179 - Fax em: rater...@gmail.com http://www.wpic.pitt.edu/research/lncd/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] please join the R group on LinkedIn
LinkedIn is a professional networking site but we have discussions and news items as well. We have over fifteen hundred group members. http://www.linkedin.com/groups?about=gid=77616trk=anet_ug_grppro -- _ Ajit Gemunu de Silva Oakland CA 94619 skype: ajit_de_silva [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2: stat_bin ..count.. with geom_text when NA is present
Hi Bryan, Thanks for the reproducible example. The problem is actually in your code, not mine ;) You probably want: y = min(res, na.rm = TRUE) - 0.1 * diff(range(res, na.rm = TRUE)) Hadley (drop = TRUE solves a difference problem - it controls whether or not to remove bins with zero count) On Fri, Oct 23, 2009 at 6:34 PM, Bryan Hanson han...@depauw.edu wrote: .. Adding to my original post... OK, here's a little function which demonstrates the behavior I described. Try it with rem = FALSE to see the annotation, then TRUE to see the annotations disappear. What's going on here? Thanks, Bryan res = runif(50, 0, 100) fac = rep(c(A, B), 50) df - data.frame(res = res, fac = as.factor(fac)) test - function(df, rem = TRUE) { if (rem) rem - runif(15, 1, 100); df$res[rem] - NA p - ggplot(df, aes(fac, res)) + geom_point() p - p + geom_text(aes(x = fac, y = min(res) - 0.1 * diff(range(res)), label = paste(n = , ..count.. , sep = )), color = black, size = 4.0, stat = bin) print(p) } On 10/23/09 1:19 PM, Bryan Hanson han...@depauw.edu wrote: One for the ggplot2 gurus... I have a function which makes a plot just fine if the response vector (res in the example; fac1 is a factor) has no NA in it. It plots the data, then makes a little annotation at the bottom with the data counts using: p - p + geom_text(aes(x = fac1, y = min(res) - 0.1 * diff(range(res)), label = paste(n = , ..count.. , sep = )), color = black, size = 4.0, stat = bin) If there are NA in the res vector, I get warnings from stat_summary and geom_point about removing rows; these arise from an earlier part of the function and the points and error bars all plot. However, the count annotation does not appear on the plot when there are NA in res. Looking at the ggplot2 web site, there is a drop parameter for stat_bin. I inserted drop = TRUE several places in the snippet above and the function did not complain but still did not plot the counts. I looked at the function bin{ggplot2} which apparently does the work. There are some programming tricks there I'm not really familiar with, but generally it looks like it na.rm or na.omit's in several places, while the drop = TRUE is carried out as the last step. So, any suggestions about why the counts don't appear on my plot? I suppose I can always clean the data first, but it would be much more practical to do that in the background during the preparation of the plot. Thanks as always, Bryan * Bryan Hanson Acting Chair Professor of Chemistry Biochemistry DePauw University, Greencastle IN USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data
The working directory is getwd() [1] C:/Documents and Settings/Val/My Documents The data file(Rossi.dat) and the script(Rossi.R) are in C:/Documents and Settings/Val/My Documents/R_data/prd How should I write to read the file? source(???) # what should be included here? Rossi - read.table('Rossi.dat',header=T) I still got the same error message. Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Thanks Val On Wed, Oct 28, 2009 at 10:32 AM, David Winsemius dwinsem...@comcast.netwrote: On Oct 28, 2009, at 10:04 AM, Val wrote: Hi User's, This might be a simple question but it is giving me a hard time as I am a new user. I installed R version 2.9.2 (2009-08-24) 1. I just copied a short script from Fox (2002) as a practice and wanted to save it as Rossi.R. How? The system saved it without complain but when I looked at using a windows explorer it is not *.R file but only Rossi. Why this is happening? If you were to include the code, we perhaps could tell you. In its default mode Windows may be hiding the extension from you. (Or possibly because R does not postpend file types and (I am now guessing here about a package I have not used and don't even know if you are) neither does Rcmdr.) 2. the script and the data files are in the same working directory. When I run the following script Rossi - read.table('Rossi',header=T) No path specification. And ??? thought you said it was a script, which would have been loaded with source() Rossi[1:5,1:10] But this suggests you are using it as data. What do you get when your type this: getwd() the working directory is getwd() [1] C:/Documents and Settings/val/My Documents getwd() Maybe if you tried (untested)... Nah ... not going to do further guessing. Read the posting guide and supply the missing elements. I got the following error messages Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Rossi[1:5,1:10] Error: object 'Rossi' not found Thank you for your help in advance Val -- David Winsemius, MD Heritage Laboratories West Hartford, CT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Anthropometric calculations with R
On Oct 28, 2009, at 10:18 AM, David Winsemius wrote: You might want to take a look at this article by WEI, PERE, KOENKER, AND HE. Its in the research files of Koenker who is a regular contributor to R-help: http://www.econ.uiuc.edu/~roger/research/growth/growth.pdf In particular it mentions lmsqreg, which would be a package that implements the L M S methodology used by the CDC to produce these files. the above paper discusses that package as a starting point and then offers an alternative using quantreg. The lmsqreg package can be acquired with this code: install.packages(lmsqreg, repos=http://R-Forge.R-project.org;) library(lmsqreg) There is a function, zscores, that might illustrate how to apply the L, M, S columns in those CDC datasets. You might consider posting on the Bioconductor list if these queries are unsuccessfl or contacting Vincent Carey, who is a Bioconductor Core member and appears to have done quite a bit of work in related areas: http://biosun1.harvard.edu/~carey/ (I have taken the liberty of correcting the spelling of the subject line so it can be found on searches more easily. Seems possible that searching with that alternate spelling might improve your subsequent searches as well.) I had corrected the subject line in my response to Orvalho (not noticing that he had not copied the list in his reply to me), but he then pointed out to me that this may be of general interest, and I suggested that I should be the one to send a copy to r-help. I then forgot to substitute the English spelling of anthropometric. -- David On Oct 28, 2009, at 3:24 AM, Orvalho Augusto wrote: Thanks! Yes I want a program in R that uses that data and produce percentiles and z-scores. Is there any ready program or not? Caveman On Wed, Oct 28, 2009 at 2:16 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 27, 2009, at 7:27 PM, Orvalho Augusto wrote: Hey greate ones, is there any way to have something similar to stata zanthro on R? I suppose it is possible that someone will know what is in that stata package, but it would make more sense if you were to summarize what features would be of use. I want a package that contains functions to give antropometric values, at least for the children. You are perhaps trying to map ht, weight, and head circumference to age-specific percentiles??? http://www.cdc.gov/growthcharts/percentile_data_files.htm -- David Winsemius, MD Heritage Laboratories West Hartford, CT David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Anthropometric calculations with R
Dear David, This information is very helpful, thanks. Best, Shige On Wed, Oct 28, 2009 at 10:55 AM, David Winsemius dwinsem...@comcast.netwrote: On Oct 28, 2009, at 10:18 AM, David Winsemius wrote: You might want to take a look at this article by WEI, PERE, KOENKER, AND HE. Its in the research files of Koenker who is a regular contributor to R-help: http://www.econ.uiuc.edu/~roger/research/growth/growth.pdfhttp://www.econ.uiuc.edu/%7Eroger/research/growth/growth.pdf In particular it mentions lmsqreg, which would be a package that implements the L M S methodology used by the CDC to produce these files. the above paper discusses that package as a starting point and then offers an alternative using quantreg. The lmsqreg package can be acquired with this code: install.packages(lmsqreg, repos=http://R-Forge.R-project.org;) library(lmsqreg) There is a function, zscores, that might illustrate how to apply the L, M, S columns in those CDC datasets. You might consider posting on the Bioconductor list if these queries are unsuccessfl or contacting Vincent Carey, who is a Bioconductor Core member and appears to have done quite a bit of work in related areas: http://biosun1.harvard.edu/~carey/ http://biosun1.harvard.edu/%7Ecarey/ (I have taken the liberty of correcting the spelling of the subject line so it can be found on searches more easily. Seems possible that searching with that alternate spelling might improve your subsequent searches as well.) I had corrected the subject line in my response to Orvalho (not noticing that he had not copied the list in his reply to me), but he then pointed out to me that this may be of general interest, and I suggested that I should be the one to send a copy to r-help. I then forgot to substitute the English spelling of anthropometric. -- David On Oct 28, 2009, at 3:24 AM, Orvalho Augusto wrote: Thanks! Yes I want a program in R that uses that data and produce percentiles and z-scores. Is there any ready program or not? Caveman On Wed, Oct 28, 2009 at 2:16 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 27, 2009, at 7:27 PM, Orvalho Augusto wrote: Hey greate ones, is there any way to have something similar to stata zanthro on R? I suppose it is possible that someone will know what is in that stata package, but it would make more sense if you were to summarize what features would be of use. I want a package that contains functions to give antropometric values, at least for the children. You are perhaps trying to map ht, weight, and head circumference to age-specific percentiles??? http://www.cdc.gov/growthcharts/percentile_data_files.htm -- David Winsemius, MD Heritage Laboratories West Hartford, CT David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data
Val, please take it slow, you are missing basic stuff here. (1) Windows Explorer may hide extensions; the 'Type' column should read 'R file' anyway. (2) Script files are included in your workspace with the comand source(). Please type ?source for details. (3) You should call files with their path and extensions (in your case 'Rossi.R') Hope the above help, On Wed, Oct 28, 2009 at 3:55 PM, Val valkr...@gmail.com wrote: The working directory is getwd() [1] C:/Documents and Settings/Val/My Documents The data file(Rossi.dat) and the script(Rossi.R) are in C:/Documents and Settings/Val/My Documents/R_data/prd How should I write to read the file? source(???) # what should be included here? Rossi - read.table('Rossi.dat',header=T) I still got the same error message. Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Thanks Val On Wed, Oct 28, 2009 at 10:32 AM, David Winsemius dwinsem...@comcast.netwrote: On Oct 28, 2009, at 10:04 AM, Val wrote: Hi User's, This might be a simple question but it is giving me a hard time as I am a new user. I installed R version 2.9.2 (2009-08-24) 1. I just copied a short script from Fox (2002) as a practice and wanted to save it as Rossi.R. How? The system saved it without complain but when I looked at using a windows explorer it is not *.R file but only Rossi. Why this is happening? If you were to include the code, we perhaps could tell you. In its default mode Windows may be hiding the extension from you. (Or possibly because R does not postpend file types and (I am now guessing here about a package I have not used and don't even know if you are) neither does Rcmdr.) 2. the script and the data files are in the same working directory. When I run the following script Rossi - read.table('Rossi',header=T) No path specification. And ??? thought you said it was a script, which would have been loaded with source() Rossi[1:5,1:10] But this suggests you are using it as data. What do you get when your type this: getwd() the working directory is getwd() [1] C:/Documents and Settings/val/My Documents getwd() Maybe if you tried (untested)... Nah ... not going to do further guessing. Read the posting guide and supply the missing elements. I got the following error messages Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Rossi[1:5,1:10] Error: object 'Rossi' not found Thank you for your help in advance Val -- David Winsemius, MD Heritage Laboratories West Hartford, CT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Question on Bias calculations and question on read.fwf
Hi All: Bear with me on this longer e-mail. Questions: 1) Can you share with me on any example code that you may have that calculates bias of a statistical forecast in a time series? 2) Supposed I have the file in the fixed width format (details below). 1-62 character key 63-76 sales data point 1 77-90 sales data 2 91-94 sales data 3 and so on (each of the data points are 14 characters in width) What is the read.fwf command that will extract these columns? Some more details below. If you have any thoughts, please share with me. Basically I want to do some analysis on how we are biased on our forecasts. I have several files as shown below. I have put one record each for the sales file and the forecast file. The file is fixed width format. THe first 62 characters is the key for the records. THis should be further broken down into several column values. For A006004004016004016011 can be broken down as follows: Category = A006, BU = 004 Class = 004 Size = 016 BDC = 004016011 I then want to do cbind on both of these dataframes and compare the statistical forecast and the actual sales for a given time window. EXAMPLE RECORD FROM THE Sales file (columns truncated) A0050010240032314231003030050303A00600400401600401601123.200 23.70022.80023.300 Example record from the Stat Forecast file (columns truncated) A0050010240032314231003030050303A00600400401600401605134.800 35.50034.20034.900 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Data Partition Package
Hi, Users, I am a new user. I am trying to partition data into training and test. Is there any R package or function that can partition dataset? Also, is there any package do crossvalidation? Any help will be appreciated. Best, Pat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how do I plot a regression curve with the data?
?curve regards, Tom Ken Ervin schrieb: I have a data set of 6 or so ordered pairs, and I've been able to graph them and have decided to use a high-order polynomial regression. I've used the following piece of code: regression - function(x,y) { x - c(insert_numbers_here) y - c(insert_other_numbers_here) fit - lm(y ~ x + I(x^2) + I(x^3) + I(x^4) + I(x^5) + I(x^6) + I(x^7) + I(x^8) + I(x^9)) summary(fit) This gives me the coefficients for the regression very nicely, but I would like to plot both the data and the regression curve together. How do I plot that regression curve as a function, and can I put it on the same set of axes as my data scatter plot? Thanks in advance for your help! -KE __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Regex matching that gives byte offset?
Do you mean like regexpr() (on the same help page)? Depending on your locale, you might actually prefer the character offset: if you want to match in a MBCS and have byte offsets you will need to work a bit harder if useBytes=TRUE is not sufficient for you. On Wed, 28 Oct 2009, Johannes Graumann wrote: Hi, Is there any way of doing 'grep' ore something like it on the content of a text file and extract the byte positioning of the match in the file? I'm facing the need to access rather largish (600MB) XML files and would like to be able to index them ... Thanks for any help or flogging, Joh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, rip...@stats.ox.ac.uk 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@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Data Partition Package
There are a few. I'm partial to the function in the caret package: createDataPartition. Also, there are functions there for pre-processing on training sets and applying it to new data sets. For a somewhat dated summary of the packages, see: http://www.jstatsoft.org/v28/i05 also: http://caret.r-forge.r-project.org/Classification_and_Regression_Training.html Max On Wed, Oct 28, 2009 at 11:06 AM, Xu xjpat2...@gmail.com wrote: Hi, Users, I am a new user. I am trying to partition data into training and test. Is there any R package or function that can partition dataset? Also, is there any package do crossvalidation? Any help will be appreciated. Best, Pat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Max __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data
On Oct 28, 2009, at 10:55 AM, Val wrote: The working directory is getwd() [1] C:/Documents and Settings/Val/My Documents The data file(Rossi.dat) and the script(Rossi.R) are in C:/Documents and Settings/Val/My Documents/R_data/prd So you are not giving a proper path when you issue the read.table command. The default path when not explicitly provided is to the working directory, and you have stored your data elsewhere. How should I write to read the file? source(???) # what should be included here? The guess I was about to make when I realized you were conflating data and scripts was that you might want: Rossi - read.table(paste(getwd(), 'Rossi.dat', sep=/), header=T) # but that would not have been effectively different from the default behavior. So you instead want: Rossi - read.table(paste(C:/Documents and Settings/Val/My Documents/ R_data/prd, Rossi.dat, sep=/), header=T) Only if you wanted to read in a script with valid r-code would you use source(). I still got the same error message. Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory -- David On Wed, Oct 28, 2009 at 10:32 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 28, 2009, at 10:04 AM, Val wrote: Hi User's, This might be a simple question but it is giving me a hard time as I am a new user. I installed R version 2.9.2 (2009-08-24) 1. I just copied a short script from Fox (2002) as a practice and wanted to save it as Rossi.R. How? The system saved it without complain but when I looked at using a windows explorer it is not *.R file but only Rossi. Why this is happening? If you were to include the code, we perhaps could tell you. In its default mode Windows may be hiding the extension from you. (Or possibly because R does not postpend file types and (I am now guessing here about a package I have not used and don't even know if you are) neither does Rcmdr.) 2. the script and the data files are in the same working directory. When I run the following script Rossi - read.table('Rossi',header=T) No path specification. And ??? thought you said it was a script, which would have been loaded with source() Rossi[1:5,1:10] But this suggests you are using it as data. What do you get when your type this: getwd() the working directory is getwd() [1] C:/Documents and Settings/val/My Documents getwd() Maybe if you tried (untested)... Nah ... not going to do further guessing. Read the posting guide and supply the missing elements. I got the following error messages Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Rossi[1:5,1:10] Error: object 'Rossi' not found Thank you for your help in advance Val -- David Winsemius, MD Heritage Laboratories West Hartford, CT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how do I plot a regression curve with the data?
On Wed, Oct 28, 2009 at 9:23 AM, Tom Gottfried tom.gottfr...@wzw.tum.de wrote: ?curve regards, Tom and I was in the process of writing a curve example when I noticed Tom sent this. Here it is: set.seed(777) x - runif(100, 0, 100) y - 10*x + x^2 - .01*x^3 + rnorm(100, 0, 500) fit - lm(y ~ x + I(x^2) + I(x^3)) B - coef(fit) plot(x, y) curve(10*x + x^2 - .01*x^3, col = 4, lty = 4, lwd = 2, add = TRUE) curve(B[1] + B[2]*x + B[3]*x^2 + B[4]*x^3, col = 2, lty = 2, lwd = 2, add = TRUE) legend('topleft', c('truth', 'fit'), lty = c(4, 2), col = c(4, 2), lwd = 2) btw, it's not possible to fit a 9th-degree polynomial model with lm based on only '6 or so ordered pairs' (assuming that means 6 data points). A 5th degree polynomial would be a direct interpolater. hth, Kingsford Ken Ervin schrieb: I have a data set of 6 or so ordered pairs, and I've been able to graph them and have decided to use a high-order polynomial regression. I've used the following piece of code: regression - function(x,y) { x - c(insert_numbers_here) y - c(insert_other_numbers_here) fit - lm(y ~ x + I(x^2) + I(x^3) + I(x^4) + I(x^5) + I(x^6) + I(x^7) + I(x^8) + I(x^9)) summary(fit) This gives me the coefficients for the regression very nicely, but I would like to plot both the data and the regression curve together. How do I plot that regression curve as a function, and can I put it on the same set of axes as my data scatter plot? Thanks in advance for your help! -KE __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Lost all script
Hi all, I just had a rather unpleasant experience. After considerable work I finally got a script working and set it to run. It had some memory allocation problems when I came back so I used Windows to stop it. During that process it told me that the script had been changed and asked if I wanted to save it. Not being positive that I'd saved the very last changes I said yes. Now when I turn on R again the script is now completely blank. I guess my questions are: Is there a way to interrupt a program without using Windows? Is there anyway to recover my script? And a nice to know: Anybody know why it saved blank space as the new script? Thanks for any advice. A humble, and humbled, new R user. -- Best regards, David Young Marketing and Statistical Consultant Madrid, Spain +34 913 540 381 http://www.linkedin.com/in/europedavidyoung mailto:dyo...@telefonica.net __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] x11(title=' ')
The general way to create a title for multiple plots on the same page is to first create some room for the title by setting the outer margins (using par(oma=...)), then use mtext or title with the outer=TRUE argument to place the overall title. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of ms.com Sent: Wednesday, October 28, 2009 3:47 AM To: R Help Subject: [R] x11(title=' ') Dear all I was trying to put a title for my plot, but i got this result, x11(width=10,height=5,title=seedling);par(mfrow=c(1,2))Error in x11(width = 10, height = 5, title = seedling) : unused argument(s) (title = seedling) The title is not taking How can i give a title for the plot (where in need to make 2 plots within a window of x11() ) thanking you in anticipation Warm regard MS Nepal _ WLMTAGL:ON:WL:en-US:WWL_WIN_evergreen3:102009 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data
Val, please take it slow, you are missing basic stuff here. (1) Windows Explorer may hide extensions; the 'Type' column should read 'R file' anyway. * Yes I looked at it and it only shows type. To check I downloaded another script with R extension test.R and the type column shows the exact extension(i.e., test.R). * (2) Script files are included in your workspace with the comand source(). Please type ?source for details. (3) You should call files with their path and extensions (in your case 'Rossi.R') I can open the script using this command, * Rossi - read.table( file.choose(),header=T) * *Why I can not open with this command?* Rossi - read.table(C:/Documents and Settings/Val/My Documents/R_data/prd/Rossi.dat,header=T) *David, *You suggested to use , Rossi - read.table(paste(C:/Documents and Settings/Val/My Documents/R_data/prd, Rossi.dat, sep=/), header=T) This is not working as well I got the same error message. Any help is highly appreciated Val Hope the above help, On Wed, Oct 28, 2009 at 3:55 PM, Val valkr...@gmail.com wrote: The working directory is getwd() [1] C:/Documents and Settings/Val/My Documents The data file(Rossi.dat) and the script(Rossi.R) are in C:/Documents and Settings/Val/My Documents/R_data/prd How should I write to read the file? source(???) # what should be included here? Rossi - read.table('Rossi.dat',header=T) I still got the same error message. Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Thanks Val On Wed, Oct 28, 2009 at 10:32 AM, David Winsemius dwinsem...@comcast.netwrote: On Oct 28, 2009, at 10:04 AM, Val wrote: Hi User's, This might be a simple question but it is giving me a hard time as I am a new user. I installed R version 2.9.2 (2009-08-24) 1. I just copied a short script from Fox (2002) as a practice and wanted to save it as Rossi.R. How? The system saved it without complain but when I looked at using a windows explorer it is not *.R file but only Rossi. Why this is happening? If you were to include the code, we perhaps could tell you. In its default mode Windows may be hiding the extension from you. (Or possibly because R does not postpend file types and (I am now guessing here about a package I have not used and don't even know if you are) neither does Rcmdr.) 2. the script and the data files are in the same working directory. When I run the following script Rossi - read.table('Rossi',header=T) No path specification. And ??? thought you said it was a script, which would have been loaded with source() Rossi[1:5,1:10] But this suggests you are using it as data. What do you get when your type this: getwd() the working directory is getwd() [1] C:/Documents and Settings/val/My Documents getwd() Maybe if you tried (untested)... Nah ... not going to do further guessing. Read the posting guide and supply the missing elements. I got the following error messages Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Rossi[1:5,1:10] Error: object 'Rossi' not found Thank you for your help in advance Val -- David Winsemius, MD Heritage Laboratories West Hartford, CT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Kruskal-Wallis test and kruskalmc
Dear all, I am using the Kruskal-Wallis test in R (kruskal.test()) to compare non-normally distributed observations for 5 different groups. I now want to perform multiple comparisons to identify the groups with significant differences in the mean ranks. On searching the forum I found a number of suggestions of approaches to try and decided to use kruskalmc() from the pgirmess package. However, I appear to get contradicting results as I have a significant p-value of 0.0007 from the Kruskal-Wallis test indicating a difference between at least two groups but no apparent differences in the 5 groups. Why is this the case? Apologies for my ignorance if there is an obvious answer to this question! Cheers, Karen -- View this message in context: http://www.nabble.com/Kruskal-Wallis-test-and-kruskalmc-tp26094625p26094625.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cox regression extract strata as numeric
-- begin included message --- (basehazzft.ln$stra[285]) [1] stra=2 134 Levels: stra=1 stra=10 stra=100 stra=101 stra=102 ... stra=99 c(basehazzft.ln$stra[285]) [1] 47 while the desired value is 2, I get a 47. What am I doing wrong? I tried the as.numeric function but I have the same problem.. --- end included --- The variable in question is a factor. The internal codes used for the levels of a factor variable 'x', as reported by as.numeric(x) or c(x), are not the same as the names of the levels, which appear from printing x itself. The confusing nature of factor variables makes a regular appearance on R help. I would suggest reading the section on factor variables in one of the many introductory R texts. Your question is not per se an issue with the Cox model routines. But to answer your underlying query, try substring(x, 6,10). PS If you use survfit() instead of basehaz() you will get back a survival curve object, which is often much more useful. I never use basehaz myself, but there was a cry for a function with the same name and same (limite) output as the SAS phreg option. (Basehaz calls survfit and then throws away 1/2 the information.) Terry T. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Labelling individual points on 3D PCA scatterplot
Hi There, I'm attempting to plot 10 values on a three-dimensional PCA with text labels next to each point. While i have no trouble doing this on 2D plots using the 'text' or 'textxy' function, I cannot find a function to do this on a 3D plot. I am using princomp for my PCA: PCA-princomp(eucdata, cor=TRUE) PCA$scores [,1:3]# the three principal components i want to plot Then i am using 'scatterplot3d' to plot my first 3 principal components: scatterplot3d(PCA$scores [,1:3],xlab=Component 1 (26.9%),main=My 3D PCA,ylab=Component 2 + (17.9%), zlab=Component 3 (12.4%),type=h,box=FALSE,pch=21,bg=color) And i get this: http://www.nabble.com/file/p26096592/myPCA.jpeg 'text' and 'textxy' only accept 2D coordinates so they do not label my points in a way that makes sense. I'm open to other 3D plotting functions in R, i just think this one is easy to visually understand. In addition, If there is any way to move the grid up to z=0 please let me know. To be clear i am trying to make my PCA look more like this one i found in a journal article (Trejaut et al., 2005): http://www.nabble.com/file/p26096592/journal.pbio.0030247.g003.png Thanks in advance! Tom -- View this message in context: http://www.nabble.com/Labelling-individual-points-on-3D-PCA-scatterplot-tp26096592p26096592.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Data Partition Package
Thanks a lot. Have a nice day! Best, Pat On Wed, Oct 28, 2009 at 10:29 AM, Max Kuhn mxk...@gmail.com wrote: There are a few. I'm partial to the function in the caret package: createDataPartition. Also, there are functions there for pre-processing on training sets and applying it to new data sets. For a somewhat dated summary of the packages, see: http://www.jstatsoft.org/v28/i05 also: http://caret.r-forge.r-project.org/Classification_and_Regression_Training.html Max On Wed, Oct 28, 2009 at 11:06 AM, Xu xjpat2...@gmail.com wrote: Hi, Users, I am a new user. I am trying to partition data into training and test. Is there any R package or function that can partition dataset? Also, is there any package do crossvalidation? Any help will be appreciated. Best, Pat [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Max [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data
David Winsemius wrote: On Oct 28, 2009, at 10:55 AM, Val wrote: The working directory is getwd() [1] C:/Documents and Settings/Val/My Documents The data file(Rossi.dat) and the script(Rossi.R) are in C:/Documents and Settings/Val/My Documents/R_data/prd So you are not giving a proper path when you issue the read.table command. The default path when not explicitly provided is to the working directory, and you have stored your data elsewhere. How should I write to read the file? source(???) # what should be included here? The guess I was about to make when I realized you were conflating data and scripts was that you might want: Rossi - read.table(paste(getwd(), 'Rossi.dat', sep=/), header=T) # but that would not have been effectively different from the default behavior. So you instead want: Rossi - read.table(paste(C:/Documents and Settings/Val/My Documents/R_data/prd, Rossi.dat, sep=/), header=T) Sometimes it's easiest to use Rossi - read.table(file.choose(), header=TRUE) which allows the mouse-addicted to click away. -Peter Ehlers Only if you wanted to read in a script with valid r-code would you use source(). I still got the same error message. Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lost all script
On 10/28/2009 11:37 AM, David Young wrote: Hi all, I just had a rather unpleasant experience. After considerable work I finally got a script working and set it to run. It had some memory allocation problems when I came back so I used Windows to stop it. During that process it told me that the script had been changed and asked if I wanted to save it. Not being positive that I'd saved the very last changes I said yes. Now when I turn on R again the script is now completely blank. Are you sure you're looking at whatever file was saved? You may be looking at a different file. If you really did lose your content, then I think the usual general advice applies: don't kill a process that contains unsaved data, because you might lose it. I guess my questions are: Is there a way to interrupt a program without using Windows? Hit the escape key. R checks for that at regular times, and aborts calculations. It is possible to run things that don't do the checks, so it isn't guaranteed to work. Is there anyway to recover my script? Recover it from a backup. Use a version control system so that you have backups routinely on request (and remember to request it), or a backup system like Time Machine on MacOS so you have hourly backups automatically. And a nice to know: Anybody know why it saved blank space as the new script? No, but if you can make it happen reproducibly when it shouldn't, we'll try to fix it. Duncan Murdoch Thanks for any advice. A humble, and humbled, new R user. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data
On Oct 28, 2009, at 11:46 AM, Val wrote: Val, please take it slow, you are missing basic stuff here. (1) Windows Explorer may hide extensions; the 'Type' column should read 'R file' anyway. * Yes I looked at it and it only shows type. To check I downloaded another script with R extension test.R and the type column shows the exact extension(i.e., test.R). * (2) Script files are included in your workspace with the comand source(). Please type ?source for details. (3) You should call files with their path and extensions (in your case 'Rossi.R') I can open the script using this command, * Rossi - read.table( file.choose(),header=T) * *Why I can not open with this command?* Rossi - read.table(C:/Documents and Settings/Val/My Documents/R_data/prd/Rossi.dat,header=T) *David, *You suggested to use , Rossi - read.table(paste(C:/Documents and Settings/Val/My Documents/R_data/prd, Rossi.dat, sep=/), header=T) This is not working as well I got the same error message. H0: there is no file by that name in that directory. HA: (or Windows and the email process is mucking up the spaces in the path). I do not see a space between My and Documents in the email representation. I originally asked and you never answered...HOW did your save Rossi or Rossi.dat? Code and output ... we want all your code and console output! So, please reproduce complete code and complete error messages. There are often details in those messages that new users are unable to decode. Any help is highly appreciated Val Hope the above help, On Wed, Oct 28, 2009 at 3:55 PM, Val valkr...@gmail.com wrote: The working directory is getwd() [1] C:/Documents and Settings/Val/My Documents The data file(Rossi.dat) and the script(Rossi.R) are in C:/Documents and Settings/Val/My Documents/R_data/prd How should I write to read the file? source(???) # what should be included here? Rossi - read.table('Rossi.dat',header=T) I still got the same error message. Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Thanks Val On Wed, Oct 28, 2009 at 10:32 AM, David Winsemius dwinsem...@comcast.netwrote: On Oct 28, 2009, at 10:04 AM, Val wrote: Hi User's, This might be a simple question but it is giving me a hard time as I am a new user. I installed R version 2.9.2 (2009-08-24) 1. I just copied a short script from Fox (2002) as a practice and wanted to save it as Rossi.R. How? The system saved it without complain but when I looked at using a windows explorer it is not *.R file but only Rossi. Why this is happening? If you were to include the code, we perhaps could tell you. In its default mode Windows may be hiding the extension from you. (Or possibly because R does not postpend file types and (I am now guessing here about a package I have not used and don't even know if you are) neither does Rcmdr.) 2. the script and the data files are in the same working directory. When I run the following script Rossi - read.table('Rossi',header=T) No path specification. And ??? thought you said it was a script, which would have been loaded with source() Rossi[1:5,1:10] But this suggests you are using it as data. What do you get when your type this: getwd() the working directory is getwd() [1] C:/Documents and Settings/val/My Documents getwd() Maybe if you tried (untested)... Nah ... not going to do further guessing. Read the posting guide and supply the missing elements. I got the following error messages Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Rossi[1:5,1:10] Error: object 'Rossi' not found Thank you for your help in advance Val -- David Winsemius, MD Heritage Laboratories West Hartford, CT [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained,
Re: [R] Antropometrics with R
The gamlss package, by Mikis Stasinopoulos and available at http://www.gamlss.com/ as well as from CRAN, is also very flexible, allowing shape and scale adjustment. Steve E David Winsemius dwinsem...@comcast.net 28/10/2009 14:18 You might want to take a look at this article by WEI, PERE, KOENKER, AND HE. Its in the research files of Koenker who is a regular contributor to R-help: http://www.econ.uiuc.edu/~roger/research/growth/growth.pdf In particular it mentions lmsqreg, which would be a package that implements the L M S methodology used by the CDC to produce these files. the above paper discusses that package as a starting point and then offers an alternative using quantreg. The lmsqreg package can be acquired with this code: install.packages(lmsqreg, repos=http://R-Forge.R-project.org;) library(lmsqreg) There is a function, zscores, that might illustrate how to apply the L, M, S columns in those CDC datasets. You might consider posting on the Bioconductor list if these queries are unsuccessfl or contacting Vincent Carey, who is a Bioconductor Core member and appears to have done quite a bit of work in related areas: http://biosun1.harvard.edu/~carey/ (I have taken the liberty of correcting the spelling of the subject line so it can be found on searches more easily. Seems possible that searching with that alternate spelling might improve your subsequent searches as well.) -- David On Oct 28, 2009, at 3:24 AM, Orvalho Augusto wrote: Thanks! Yes I want a program in R that uses that data and produce percentiles and z-scores. Is there any ready program or not? Caveman On Wed, Oct 28, 2009 at 2:16 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 27, 2009, at 7:27 PM, Orvalho Augusto wrote: Hey greate ones, is there any way to have something similar to stata zanthro on R? I suppose it is possible that someone will know what is in that stata package, but it would make more sense if you were to summarize what features would be of use. I want a package that contains functions to give antropometric values, at least for the children. You are perhaps trying to map ht, weight, and head circumference to age-specific percentiles??? http://www.cdc.gov/growthcharts/percentile_data_files.htm -- David Winsemius, MD Heritage Laboratories West Hartford, CT David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lost all script
To stop in Rgui mode, you can try pressing the ESC key. If you are using within emacs, change to R buffer and try C-c C-c to stop it. I am not sure how to recover the script (emacs usually makes a .R~ backup). Maybe if you still have the output printed to screen or terminal make a copy of it - you may be able to rewrite with some work. If your machine is backed up on regular basis, then try to get the last available backup. Also note that you can view the same file (even while it is in the R session) using notepad etc externally. So next time, if you face a similar situation then you can check/save externally first. Regards, Adai David Young wrote: Hi all, I just had a rather unpleasant experience. After considerable work I finally got a script working and set it to run. It had some memory allocation problems when I came back so I used Windows to stop it. During that process it told me that the script had been changed and asked if I wanted to save it. Not being positive that I'd saved the very last changes I said yes. Now when I turn on R again the script is now completely blank. I guess my questions are: Is there a way to interrupt a program without using Windows? Is there anyway to recover my script? And a nice to know: Anybody know why it saved blank space as the new script? Thanks for any advice. A humble, and humbled, new R user. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Standard Time Stamps
Hello I have a data set which contains a column of Standard Time Stamps (2008-09-12T23:48:07.747Z, 2008-09-12T20:35:07.747Z, etc) I need to find differences in consecutive time stamps and then need to plot a graph using it, can anyone guide me as to how to handle this type of data? Thanks in advance Sunita -- View this message in context: http://www.nabble.com/Standard-Time-Stamps-tp26097512p26097512.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Selecting rows according to a column
Hi, With a data such as: z = data.frame(a = 1:5, b=10*a, c = c(a, a, b, b, b) ) * a b c* *1* 10 *a* *2* 20 *a* 3 *30* *b* 4 *40* *b* 5 *50* *b* Can anyone suggest a way to select [1, 2, 30, 40, 50], ie. using column c to specify which column is selected for each row. Many thanks G [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Standard Time Stamps
How about this: x - c(2008-09-12T23:48:07.747Z, 2008-09-12T20:35:07.747Z) x.t - as.POSIXct(x, format=%Y-%m-%dT%H:%M:%OS) x.t [1] 2008-09-12 23:48:07 EDT 2008-09-12 20:35:07 EDT diff(x.t) Time difference of -3.216667 hours On Wed, Oct 28, 2009 at 12:11 PM, Sunita22 sunita...@gmail.com wrote: Hello I have a data set which contains a column of Standard Time Stamps (2008-09-12T23:48:07.747Z, 2008-09-12T20:35:07.747Z, etc) I need to find differences in consecutive time stamps and then need to plot a graph using it, can anyone guide me as to how to handle this type of data? Thanks in advance Sunita -- View this message in context: http://www.nabble.com/Standard-Time-Stamps-tp26097512p26097512.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Standard Time Stamps
Hello Jim Thanx a lot. Actually since long I was trying dts = c(1989-09-28, 2001-01-15, 2004-08-30, 1990-02-09) dts [1] 1989-09-28 2001-01-15 2004-08-30 1990-02-09 GMT = timeDate(dts, zone = GMT, FinCenter = GMT) GMT GMT [1] [1989-09-28] [2001-01-15] [2004-08-30] [1990-02-09] difftimeDate(GMT[1:2], GMT[-(1:2)]) Time differences in days [1] -5450 3993 attr(,tzone) [1] GMT *But the same was not working for 2008-09-12T23:48:07.747Z Thank you very much*, *it worked* Regards Our Thoughts have the Power to Change our Destiny. Sunita On Wed, Oct 28, 2009 at 9:45 PM, jim holtman jholt...@gmail.com wrote: How about this: x - c(2008-09-12T23:48:07.747Z, 2008-09-12T20:35:07.747Z) x.t - as.POSIXct(x, format=%Y-%m-%dT%H:%M:%OS) x.t [1] 2008-09-12 23:48:07 EDT 2008-09-12 20:35:07 EDT diff(x.t) Time difference of -3.216667 hours On Wed, Oct 28, 2009 at 12:11 PM, Sunita22 sunita...@gmail.com wrote: Hello I have a data set which contains a column of Standard Time Stamps (2008-09-12T23:48:07.747Z, 2008-09-12T20:35:07.747Z, etc) I need to find differences in consecutive time stamps and then need to plot a graph using it, can anyone guide me as to how to handle this type of data? Thanks in advance Sunita -- View this message in context: http://www.nabble.com/Standard-Time-Stamps-tp26097512p26097512.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Reading data
On Wed, Oct 28, 2009 at 11:59 AM, David Winsemius dwinsem...@comcast.netwrote: On Oct 28, 2009, at 11:46 AM, Val wrote: Val, please take it slow, you are missing basic stuff here. (1) Windows Explorer may hide extensions; the 'Type' column should read 'R file' anyway. * Yes I looked at it and it only shows type. To check I downloaded another script with R extension test.R and the type column shows the exact extension(i.e., test.R). * (2) Script files are included in your workspace with the comand source(). Please type ?source for details. (3) You should call files with their path and extensions (in your case 'Rossi.R') I can open the script using this command, * Rossi - read.table( file.choose(),header=T) * *Why I can not open with this command?* Rossi - read.table(C:/Documents and Settings/Val/My Documents/R_data/prd/Rossi.dat,header=T) *David, *You suggested to use , Rossi - read.table(paste(C:/Documents and Settings/Val/My Documents/R_data/prd, Rossi.dat, sep=/), header=T) This is not working as well I got the same error message. H0: there is no file by that name in that directory. HA: (or Windows and the email process is mucking up the spaces in the path). I do not see a space between My and Documents in the email representation. I originally asked and you never answered...HOW did your save Rossi or Rossi.dat? Code and output ... we want all your code and console output! *Sorry for that and this is the code that was saved as Ross.R. Now I manged to save it as *.R. By default when I clicked file -- save as --- the window asks file name and shows save as type -- R files(*.R) file type. In my case I was typing only the file name Ross without the extension assuming that the window will append the extension since it asked me R files(*.R). I thought it is just like the other windows program like Word or Excel. Now I have to type the full file name Ross.R. The script file name is Ross.R * *Rossi - read.table(paste(C:/Documents and Settings/Val/My Documents/R_data/prd, Rossi.dat, sep=/), header=T)* the console output is Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'C:/Documents and Settings/Val/My Documents/R_data/prd/Rossi.dat': No such file or directory So, please reproduce complete code and complete error messages. There are often details in those messages that new users are unable to decode. Any help is highly appreciated Val Hope the above help, On Wed, Oct 28, 2009 at 3:55 PM, Val valkr...@gmail.com wrote: The working directory is getwd() [1] C:/Documents and Settings/Val/My Documents The data file(Rossi.dat) and the script(Rossi.R) are in C:/Documents and Settings/Val/My Documents/R_data/prd How should I write to read the file? source(???) # what should be included here? Rossi - read.table('Rossi.dat',header=T) I still got the same error message. Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Thanks Val On Wed, Oct 28, 2009 at 10:32 AM, David Winsemius dwinsem...@comcast.netwrote: On Oct 28, 2009, at 10:04 AM, Val wrote: Hi User's, This might be a simple question but it is giving me a hard time as I am a new user. I installed R version 2.9.2 (2009-08-24) 1. I just copied a short script from Fox (2002) as a practice and wanted to save it as Rossi.R. How? The system saved it without complain but when I looked at using a windows explorer it is not *.R file but only Rossi. Why this is happening? If you were to include the code, we perhaps could tell you. In its default mode Windows may be hiding the extension from you. (Or possibly because R does not postpend file types and (I am now guessing here about a package I have not used and don't even know if you are) neither does Rcmdr.) 2. the script and the data files are in the same working directory. When I run the following script Rossi - read.table('Rossi',header=T) No path specification. And ??? thought you said it was a script, which would have been loaded with source() Rossi[1:5,1:10] But this suggests you are using it as data. What do you get when your type this: getwd() the working directory is getwd() [1] C:/Documents and Settings/val/My Documents getwd() Maybe if you tried (untested)... Nah ... not going to do further guessing. Read the posting guide and supply the missing elements. I got the following error messages Error in file(file, r) : cannot open the connection In addition: Warning message: In file(file, r) : cannot open file 'Rossi': No such file or directory Rossi[1:5,1:10] Error: object 'Rossi' not found Thank you for your help in advance Val --
Re: [R] Selecting rows according to a column
Hello, Here's an idea: ifelse(z$c == a, z$a, z$b) -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gurpal Kalsi Sent: Wednesday, October 28, 2009 11:15 AM To: r-help@r-project.org Subject: [R] Selecting rows according to a column Hi, With a data such as: z = data.frame(a = 1:5, b=10*a, c = c(a, a, b, b, b) ) * a b c* *1* 10 *a* *2* 20 *a* 3 *30* *b* 4 *40* *b* 5 *50* *b* Can anyone suggest a way to select [1, 2, 30, 40, 50], ie. using column c to specify which column is selected for each row. Many thanks G [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] structural equation modeling
There is a package in beta testing now that looks interesting: http://openmx.psyc.virginia.edu/installing-openmx -Ista On Wed, Oct 28, 2009 at 10:37 AM, Robert Terwilliger rater...@gmail.com wrote: Dear R-help, I am interested in using structural equation modeling. Just getting started with it, but I'm looking for suggestions for packages. As an aside, what's the best way for looking for packages at CRAN? -- Robert Terwilliger Biomedical Physicist Laboratory of Neurocognitive Development Western Psychiatric Institute and Clinic University of Pittsburgh Medical Center Loeffler Building 121 Meyran Avenue #114 Pittsburgh, PA 15213 412.383.8174 - Office 412.383.8179 - Fax em: rater...@gmail.com http://www.wpic.pitt.edu/research/lncd/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Selecting rows according to a column
Not very elegant but try: z - data.frame(a = 1:5, b=10*(1:5), c = c(a, a, b, b, b) ) z[ cbind( 1:nrow(z), match( as.character(z$c) , colnames(z) ) ) ] If you have very few columns, you can use ifelse() too. Regards, Adai Gurpal Kalsi wrote: Hi, With a data such as: z = data.frame(a = 1:5, b=10*a, c = c(a, a, b, b, b) ) * a b c* *1* 10 *a* *2* 20 *a* 3 *30* *b* 4 *40* *b* 5 *50* *b* Can anyone suggest a way to select [1, 2, 30, 40, 50], ie. using column c to specify which column is selected for each row. Many thanks G [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Need help locating the longest series of consecutive numbers in a matrix
I need to determine the length of the longest series of consecutive numbers (1's to be specific) and the start time of that series. For example, in the following sample, the first column is time and the second column indicates the presence of the target behavior. I would like a function that would return 21 as the start time and 17 as the length. sample - matrix(data=c(1:40,rep(0,10),rep(1,3),rep(0,3),1,0,1,0,rep(1,17),0,0,0),40,2 ) I would appreciate any suggestions you have. Respectfully, ~ Angela __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Selecting rows according to a column
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erik Iverson Sent: Wednesday, October 28, 2009 9:22 AM To: Gurpal Kalsi; r-help@r-project.org Subject: Re: [R] Selecting rows according to a column Hello, Here's an idea: ifelse(z$c == a, z$a, z$b) If there may be many columns to select from (so the nested ifelse's become tedious) one might try z[,-3][cbind(seq_len(nrow(z)),z$c)] [1] 1 2 30 40 50 The initial [,-3] is there only so when the data.frame is converted to a matrix by [.data.frame's processing of a matrix subscript it becomes a numeric matrix, not a character matrix. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gurpal Kalsi Sent: Wednesday, October 28, 2009 11:15 AM To: r-help@r-project.org Subject: [R] Selecting rows according to a column Hi, With a data such as: z = data.frame(a = 1:5, b=10*a, c = c(a, a, b, b, b) ) * a b c* *1* 10 *a* *2* 20 *a* 3 *30* *b* 4 *40* *b* 5 *50* *b* Can anyone suggest a way to select [1, 2, 30, 40, 50], ie. using column c to specify which column is selected for each row. Many thanks G [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Easy method to set user-mode virtual memory space in Windows Vista and 7
I thought I'd share this with the list since it appears to provide a quick fix to some memory problems, and I haven't see it discussed in relation to R. To reallocate virtual memory from kernel-mode to user-mode in 32-bit Vista or Windows 7 one can use the increaseuserva boot option value. See http://msdn.microsoft.com/en-us/library/aa906211.aspx On my 4GB Vista machine, R is now able to use 3GB memory (previously at the default value of 2GB). Here's the method: Open cmd.exe as administrator and type BCDEdit /set IncreaseUserVA value where value is between 2048 and 3072 (ie 2-3GB), then reboot. Given that you've set the --max-mem-size flag, or used the memory.limit function in an R session to increase R's memory allocation, your R processes should now be allowed to access up to 3GB of virtual memory. I am not a Windows expert, so if anyone knows of disadvantages of using this method *please* post a response. best, Kingsford Jones __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] New variables remember how they were created?
Your example is too complicated for me. But few points: 1) What do you mean by instrument? Do you mean variable? 2) diff(demand) is identical to demand[-1] - demand[-204] 3) system() is a built-in R function, so avoid using it as variable name 4) The variable yd is in the eqInvest formula and subsequently to the system formula. The variable y.1 is in the instruments formula. Both formulas are passed onto systemfit() call. Thus I see no surprises here. Try simplifying and rephrasing please if you want further help. Regards, Adai Skipper Seabold wrote: Hello all, I hope this question is appropriate for this ML. Basically, I am wondering if when you create a new variable, if the variable holds some information about how it was created. Let me explain, I have the following code to replicate an example in a textbook (Greene's Econometric Analysis), using the systemfit package. dta - read.table('http://pages.stern.nyu.edu/~wgreene/Text/Edition6/TableF5-1.txt', header = TRUE) attach(dta) library(systemfit) demand - realcons + realinvs + realgovt c.1 - realcons[-204] y.1 - demand[-204] yd - demand[-1] - y.1 eqConsump - realcons[-1] ~ demand[-1] + c.1 eqInvest - realinvs[-1] ~ tbilrate[-1] + yd system - list( Consumption = eqConsump, Investment = eqInvest) instruments - ~ realgovt[-1] + tbilrate[-1] + c.1 + y.1 # 2SLS greene2sls - systemfit( system, 2SLS, inst = instruments, methodResidCov = noDfCor ) When I do the 2SLS fit, it seems that even though I declared y.1 as an instrument that the estimator knows that yd was created using y1, so it (correctly) transforms yd to use the instrument in the final estimation. So I'm wondering if yd somehow carries knowledge of how it was created. Thanks, Skipper __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Why is package RandomFields not listed in the R 2.10.0 Packages list under Packages, Install package(s)...?
The package list was accessed October 28, 10:13 am MST using Windows XP and mirror USA (CA 1). Bill Morphet, Ph.D. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Selecting rows according to a column
Thanks very much! Gurpal Centrica Energy. On Wed, Oct 28, 2009 at 4:31 PM, William Dunlap wdun...@tibco.com wrote: -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erik Iverson Sent: Wednesday, October 28, 2009 9:22 AM To: Gurpal Kalsi; r-help@r-project.org Subject: Re: [R] Selecting rows according to a column Hello, Here's an idea: ifelse(z$c == a, z$a, z$b) If there may be many columns to select from (so the nested ifelse's become tedious) one might try z[,-3][cbind(seq_len(nrow(z)),z$c)] [1] 1 2 30 40 50 The initial [,-3] is there only so when the data.frame is converted to a matrix by [.data.frame's processing of a matrix subscript it becomes a numeric matrix, not a character matrix. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gurpal Kalsi Sent: Wednesday, October 28, 2009 11:15 AM To: r-help@r-project.org Subject: [R] Selecting rows according to a column Hi, With a data such as: z = data.frame(a = 1:5, b=10*a, c = c(a, a, b, b, b) ) * a b c* *1* 10 *a* *2* 20 *a* 3 *30* *b* 4 *40* *b* 5 *50* *b* Can anyone suggest a way to select [1, 2, 30, 40, 50], ie. using column c to specify which column is selected for each row. Many thanks G [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2: stat_bin ..count.. with geom_text when NA is present
Hadley, thanks - that was a permutation that I did not try (but should have thought of it). But... Now, when some observations are removed, you get the count on the plot (previously one did not), however, alas, a new problem: the value of .count.. includes the NA's or something similar. Revised function below; n = 50 appears at the bottom of the plot regardless of how many values there are... Hmmm JUST FIXED IT: added the df - na.omit(df) and the counts are correct! Thanks, Bryan res = runif(50, 0, 100) fac = rep(c(A, B), 50) df - data.frame(res = res, fac = as.factor(fac)) test - function(df, rem = TRUE) { if (rem) rem - runif(15, 1, 100); df$res[rem] - NA ; df - na.omit(df) p - ggplot(df, aes(fac, res)) + geom_point() p - p + geom_text(aes(x = fac, y = min(res, na.rm = TRUE) - 0.1 * diff(range(res, na.rm = TRUE)), label = paste(n = , ..count.. , sep = )), color = black, size = 4.0, stat = bin) print(p) } On 10/28/09 10:49 AM, hadley wickham h.wick...@gmail.com wrote: Hi Bryan, Thanks for the reproducible example. The problem is actually in your code, not mine ;) You probably want: y = min(res, na.rm = TRUE) - 0.1 * diff(range(res, na.rm = TRUE)) Hadley (drop = TRUE solves a difference problem - it controls whether or not to remove bins with zero count) On Fri, Oct 23, 2009 at 6:34 PM, Bryan Hanson han...@depauw.edu wrote: .. Adding to my original post... OK, here's a little function which demonstrates the behavior I described. Try it with rem = FALSE to see the annotation, then TRUE to see the annotations disappear. What's going on here? Thanks, Bryan res = runif(50, 0, 100) fac = rep(c(A, B), 50) df - data.frame(res = res, fac = as.factor(fac)) test - function(df, rem = TRUE) { if (rem) rem - runif(15, 1, 100); df$res[rem] - NA p - ggplot(df, aes(fac, res)) + geom_point() p - p + geom_text(aes(x = fac, y = min(res) - 0.1 * diff(range(res)), label = paste(n = , ..count.. , sep = )), color = black, size = 4.0, stat = bin) print(p) } On 10/23/09 1:19 PM, Bryan Hanson han...@depauw.edu wrote: One for the ggplot2 gurus... I have a function which makes a plot just fine if the response vector (res in the example; fac1 is a factor) has no NA in it. It plots the data, then makes a little annotation at the bottom with the data counts using: p - p + geom_text(aes(x = fac1, y = min(res) - 0.1 * diff(range(res)), label = paste(n = , ..count.. , sep = )), color = black, size = 4.0, stat = bin) If there are NA in the res vector, I get warnings from stat_summary and geom_point about removing rows; these arise from an earlier part of the function and the points and error bars all plot. However, the count annotation does not appear on the plot when there are NA in res. Looking at the ggplot2 web site, there is a drop parameter for stat_bin I inserted drop = TRUE several places in the snippet above and the function did not complain but still did not plot the counts. I looked at the function bin{ggplot2} which apparently does the work. There are some programming tricks there I'm not really familiar with, but generally it looks like it na.rm or na.omit's in several places, while the drop = TRUE is carried out as the last step. So, any suggestions about why the counts don't appear on my plot? I suppose I can always clean the data first, but it would be much more practical to do that in the background during the preparation of the plot. Thanks as always, Bryan * Bryan Hanson Acting Chair Professor of Chemistry Biochemistry DePauw University, Greencastle IN USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guidehtml and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating a sparse matrix from a file
Hi Martin, Unfortunately, the error is coming on the data set that I have right now. I was successfully able to display any field in the matrix and even the whole matrix when I tried the example code provided by you. However, it is failing on the dataset I am working on.I can share the file with you if that helps. Kindly let me know. Also, please find the sessioninfo() output below: sessionInfo() R version 2.9.2 (2009-08-24) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Matrix_0.999375-30 lattice_0.17-25 loaded via a namespace (and not attached): [1] grid_2.9.2 Thanks Pallavi On Wed, Oct 28, 2009 at 7:22 PM, Martin Maechler maech...@stat.math.ethz.ch wrote: PP == Pallavi P pallavip...@gmail.com on Wed, 28 Oct 2009 16:30:25 +0530 writes: PP Hi Martin, PP I followed your example on my set of data. Which has non zero values in PP 300k positions in 22638 X 80914 sparse matrix. I am able to load data into a PP field and was able to do some operations (essentially t(m) %*% m). However, PP when I tried to display the value in the resulted matrix. I am getting below PP error PP * PP Error in asMethod(object) : PP Cholmod error 'out of memory' at file:../Core/cholmod_memory.c, line 148* PP The sequence of commands I used are: uac=read.table('C:\\personal\\code\\data\\user_album_count.csv',sep=',' , PP header=T) library(Matrix) m-sparseMatrix(i=uac[,user],j=uac[,item],x=uac[,count]) cm-t(m) %*% m The above is less efficient than cm - crossprod(m) please use the latter {not just for sparse matrices; for all matrices in R !} PP upto this point, I was able to run, however when I tried to display cm[1,1], PP I got above error. Kindly let me know if there is anything wrong going on PP here. Interestingly, we had a recent thread on R-devel, which also made a point about excessive memory usage when accessing elements of a sparse matrix. I'd really like to investigate further; but can you ***PLEASE*** use reproducible code, i.e., similar to the one I used, rather than reading data from one of your files. Note that your matrix is still fine and should be able to work with it, even thoug it seems the operation a - cm[1,1] is currently implemented very sub-optimally. I'm busy for the rest of today with other duties, but am looking forward to receive **reproducible** code from you, by tonight. Also, please do not forget to also show the result of sessionInfo() ! Martin Maechler, PP Thanks PP Pallavi PP On Tue, Oct 27, 2009 at 8:34 PM, Martin Maechler maech...@stat.math.ethz.ch wrote: PP == Pallavi P pallavip...@gmail.com on Tue, 27 Oct 2009 18:13:22 +0530 writes: PP Hi Martin, PP Thanks for the help. Just to make sure I understand correctly. PP The below steps are for creating an example table similar to the one that I PP read from file. yes, exactly n - 22638 m - 80914 nnz - 30 # no idea if this is realistic for you set.seed(101) ex - cbind(i = sample(n,nnz, replace=TRUE), j = sample(m,nnz, replace=TRUE), x = round(100 * rnorm(nnz))) PP and I can understand the way sparseMatrix is initialized right now as M - sparseMatrix(i = ex[,i], j = ex[,j], x = ex[,x]) PP How ever, I couldn't understand the use of below commands. MM. - tcrossprod(M) # == MM' := M %*% t(M) M.1 - M %*% rep(1, ncol(M)) stopifnot(identical(drop(M.1), rowSums(M))) They were just for illustrative purposes, to show how and that you can work with the created sparse matrix 'M'. Regards, Martin Maechler, ETH Zurich PP Kindly let me know if I missed something. PP Thanks PP Pallavi PP Hi Martin,brbrI followed your example on my set of data. Which has non zero values in 300k positions in 22638 X 80914 sparse matrix. I am able to load data into a field and was able to do some operations (essentially t(m) %*% m). However, when I tried to display the value in the resulted matrix. I am getting below errorbr PP bbrError in asMethod(object) : br Cholmod error #39;out of memory#39; at file:../Core/cholmod_memory.c, line 148/bbrbrThe sequence of commands I used are:brbrgt;uac=read.table(#39;C:\\personal\\code\\data\\user_album_count.csv#39;,sep=#39;,#39; , header=T)br PP gt;library(Matrix)brgt;mlt;-sparseMatrix(i=uac[,quot;userquot;],j=uac[,quot;itemquot;],x=uac[,quot;countquot;])brgt;cmlt;-t(m) %*% mbrupto this point, I was able to run, however when I tried to display cm[1,1], I got above
[R] Is there a faster way to do it?
#Mdarts is a matrix 2343x788 #frequencia is a vector 2343x1 # 9 in Mdarts[fri,frj] stands for my missing values which i want to replace by the value in the vector frequencia Mdarts-t(matrix(scan(C:/GWS/CNB/dartg.txt),ncol=nindT,nrow=nm, byrow=T)) frequencia - matrix(scan(C:/GWS/CNB/freq.txt),ncol=1) for (fri in 1:nindT){ for (frj in 1:nm){ Mdarts[fri,frj] - if (Mdarts[fri,frj] == 9) frequencia[frj] else Mdarts[fri,frj] Mdarts[fri,frj] - Mdarts[fri,frj]/1-(frequencia[frj]^2) } } Is there a faster way to it? Maybe using any apply function? Thanks in advance -- View this message in context: http://www.nabble.com/Is-there-a-faster-way-to-do-it--tp26098223p26098223.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Need help locating the longest series of consecutive numbers in a matrix
Use 'rle': x - rle(sample[,2]) x Run Length Encoding lengths: int [1:9] 10 3 3 1 1 1 1 17 3 values : num [1:9] 0 1 0 1 0 1 0 1 0 which.max(x$lengths[x$values==1]) [1] 4 which.max(x$lengths * x$values) # makes use of the fact you are only using 0 1 [1] 8 cumsum(c(1, x$lengths)) [1] 1 11 14 17 18 19 20 21 38 41 cumsum(c(1, x$lengths))[8] # index of the start of the run [1] 21 x$lengths[8] # length of the run [1] 17 On Wed, Oct 28, 2009 at 12:27 PM, Staples, Angela Dawn adsta...@indiana.edu wrote: I need to determine the length of the longest series of consecutive numbers (1's to be specific) and the start time of that series. For example, in the following sample, the first column is time and the second column indicates the presence of the target behavior. I would like a function that would return 21 as the start time and 17 as the length. sample - matrix(data=c(1:40,rep(0,10),rep(1,3),rep(0,3),1,0,1,0,rep(1,17),0,0,0),40,2 ) I would appreciate any suggestions you have. Respectfully, ~ Angela __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.