[R] Appending zoo objects
Hi everybody, How do we append (note: it's not merging) two zoo objects with the same column names? Thanks, Shubha [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error message when building a package
Please update your Xcode tools. According to http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html 2.2 or later is needed, and 2.4.1 is current. On Tue, 30 Jan 2007, C. Lillian Yau wrote: > I'm trying to build a package. The machine is PowerPC G4 with Mac OS 10.4.8, > and I'm using R2.4.1. > > I get "R CMD build roots" working, and it created roots.tar.gz. But I get > the following message when I run "R CMD INSTALL -l ../myrlibrary > roots.tar.gz" > > == > * Installing *source* package 'roots' ... > ** libs > ** arch - ppc > gcc-4.0 -arch ppc -std=gnu99 > -I/Library/Frameworks/R.framework/Resources/include > -I/Library/Frameworks/R.framework/Resources/include/ppc > -I/usr/local/include-fPIC -g -O2 -c fifrt.c -o fifrt.o > gfortran-4.0 -arch ppc -fPIC -g -O2 -c fthrt.f -o fthrt.o > gcc-4.0 -arch ppc -std=gnu99 -dynamiclib -Wl,-macosx_version_min -Wl,10.3 > -undefined dynamic_lookup -single_module -multiply_defined suppress > -L/usr/local/lib -o roots.so fifrt.o fthrt.o -lgfortran -lgcc_s > -lSystemStubs -lmx -lSystem > -L/Library/Frameworks/R.framework/Resources/lib/ppc -lR -dylib_file > libRblas.dylib:/Library/Frameworks/R.framework/Resources/lib/ppc/libRblas.dy > lib > /usr/bin/libtool: unknown option character `m' in: -macosx_version_min [...] -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Adding lines to xYplot
Hi here is another approach based on Gabor Grothendieck's idea to add lines to existing lattice plot. # based on Gabor Grothendieck's code suggestion # adds straight lines to panels in lattice plots addLine<- function(...) { tcL <- trellis.currentLayout() for(i in 1:nrow(tcL)) for(j in 1:ncol(tcL)) if (tcL[i,j] > 0) { trellis.focus("panel", j, i, highlight = FALSE) panel.abline(...) trellis.unfocus() } } HTH Petr On 27 Jan 2007 at 20:13, Michael Kubovy wrote: To: "r-help@stat.math.ethz.ch list" From: Michael Kubovy <[EMAIL PROTECTED]> Date sent: Sat, 27 Jan 2007 20:13:15 -0500 Subject:[R] Adding lines to xYplot > I am using xYplot to plot data and CIs. How do I add several lines to > the figure? _ Professor Michael Kubovy > University of Virginia Department of Psychology USPS: P.O.Box > 400400Charlottesville, VA 22904-4400 Parcels:Room 102 > Gilmer Hall > McCormick RoadCharlottesville, VA 22903 > Office:B011+1-434-982-4729 > Lab:B019+1-434-982-4751 > Fax:+1-434-982-4766 > WWW:http://www.people.virginia.edu/~mk9y/ > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html and provide commented, > minimal, self-contained, reproducible code. Petr Pikal [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error message when building a package
I'm trying to build a package. The machine is PowerPC G4 with Mac OS 10.4.8, and I'm using R2.4.1. I get "R CMD build roots" working, and it created roots.tar.gz. But I get the following message when I run "R CMD INSTALL -l ../myrlibrary roots.tar.gz" == * Installing *source* package 'roots' ... ** libs ** arch - ppc gcc-4.0 -arch ppc -std=gnu99 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/ppc -I/usr/local/include-fPIC -g -O2 -c fifrt.c -o fifrt.o gfortran-4.0 -arch ppc -fPIC -g -O2 -c fthrt.f -o fthrt.o gcc-4.0 -arch ppc -std=gnu99 -dynamiclib -Wl,-macosx_version_min -Wl,10.3 -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o roots.so fifrt.o fthrt.o -lgfortran -lgcc_s -lSystemStubs -lmx -lSystem -L/Library/Frameworks/R.framework/Resources/lib/ppc -lR -dylib_file libRblas.dylib:/Library/Frameworks/R.framework/Resources/lib/ppc/libRblas.dy lib /usr/bin/libtool: unknown option character `m' in: -macosx_version_min Usage: /usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT] Usage: /usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table ] [-seg_addr_table_filename ] [-all_load] [-noall_load] make: *** [roots.so] Error 1 chmod: /../myrlibrary/roots/libs/ppc/*: No such file or directory ERROR: compilation failed for package 'roots' ** Removing '/../myrlibrary/roots' One thing I can see from above is the message "/usr/bin/libtool: unknown option character `m' in: -macosx_version_min", which I got when compiling other c programs to be called by R. How can I fix it or get around it? I appreciate your time and help very much. Lillian Yau __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] help with RandomForest classwt option
Hi Weiwei, thanks a lot for the detailed help!! I tried the option 2 in R. It works pretty well! You mention that you also implemented RF. Could you plz share your code with me? Thanks! Betty On 1/29/07, Weiwei Shi <[EMAIL PROTECTED]> wrote: > > Hi, Betty: > > 1. Fortan code ( > http://www.stat.berkeley.edu/~breiman/RandomForests/cc_examples/prog.f) > > if(jclasswt.eq.0) then > do j=1,nclass > classwt(j)=1 > enddo > endif > if(jclasswt.eq.1) then > c fill in classwt(j) for each j: > c classwt(1)=1. > c classwt(2)=10. > > You need to set the jclasswt = 1 ( you can find by "search" through the > codes). > then "uncomment" the last two lines. Here you go with classwt in > fortran. You can use this classwt for extremely-imbalanced > classification problem. Down-sampling is one possible choice for that > too but it is not directly implemented in rf. Check the following > paper, and it might help. > http://oz.berkeley.edu/users/chenchao/666.pdf > > 2. as to the wrapper function, the idea is that you can create a set > of samples by applying some sampling probilities to implement > down-sampling. Then build a rf model for each sample; > suppose you call rf in this way for each sample, > my.rf <- randomForest(...) > > then you can access the oob scores and prediction scores by > my.rf$votes or my.rf$test$votes respectively. > > then you can average those scores by yourself, it is just like a > simple meta-learning process but it does exactly what downsampling > plus rf does, though downsampling is not implemented. > > > 3. classwt and cutoff are used at different places. The former is used > at two places: calculating the gini criteria and calculating the final > vote from the leaf. While cutoff is only used in the final voting. So > cutoff won't change the splitting while classwt can. However, since > the current R's rf cannot do classwt, you can try to use cutoff to see > if it helps in your case. > > 4. The fourth option is you can use my implementation of rf; But I did > not write a manual for that; and it cannot show your splitting yet. > > HTH, > > weiwei > > > > > On 1/29/07, Betty Health <[EMAIL PROTECTED]> wrote: > > Thank you very much, Weiwei and Jim! > > > > Yeah, I did read the post by Andy, the contributor of this package. It > seems > > that classwt is not implemented yet. For Weiwei's options, I have a few > more > > questions. Thanks! > > > > "1. try to use rf in fortran by following the linky below > > http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm"; > > > > I read the Fortran code briefly. But I did not find the options for down > > sampling. So does that mean I need to do down sampling myself? Could > you > > explain a little more about "2. make a wrapper function to do the down > > sampling by yourself"? You mean I can do it in R or in Fortran? Some > links > > plz? I haven't done this before. > > > > Yeah, cut off did change for the final classification results. However > from > > what I tried, they did not influence how the nodes are split. So I would > go > > further in the above 2 options. > > > > Thank you again! > > > > Betty > > > > > > > > > > On 1/28/07, Weiwei Shi <[EMAIL PROTECTED]> wrote: > > > Dear Betty: > > > > > > I could suggest 3 options: > > > > > > 1. try to use rf in fortran by following the linky below > > > > > http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm > > > > > > 2. make a wrapper function to do the down sampling by yourself > > > > > > 3. try to use cutoff in randomForest, which might help in your > situation. > > > > > > HTH, > > > > > > weiwei > > > > > > On 1/28/07, Betty Health < [EMAIL PROTECTED]> wrote: > > > > Hello there, > > > > > > > > I am working on an extremely unbalanced two class classification > > problems. I > > > > wanna use "classwt" with "down sampling" together. By checking the > > rfNews() > > > > in R, it looks that classwt is not working yet. Then I looked at the > > > > software from Salford. I did not find the down sampling option. I > am > > > > wondering if you have any experience to deal with this problem. Do > you > > know > > > > any method or softwares can handle this problem? > > > > > > > > Thank you very much!! > > > > > > > > Betty > > > > > > > > [[alternative HTML version deleted]] > > > > > > > > __ > > > > R-help@stat.math.ethz.ch mailing list > > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > > > > > > > -- > > > Weiwei Shi, Ph.D > > > Research Scientist > > > GeneGO, Inc. > > > > > > "Did you always know?" > > > "No, I did not. But I believed..." > > > ---Matrix III > > > > > > > > > > -- > Weiwei Shi, Ph.D > Research Scientist
Re: [R] rbind-ing list
do.call(rbind, temp) On 1/29/07, jiho.han <[EMAIL PROTECTED]> wrote: > > hi, > > i have a list of data.frame that has same structure. i would like to know a > efficient way of rbind-ing it. > right now, i write: > > > n = length(temp) # 'temp' is a list of data.frames > temp2 = data.frame() > for (i in 1:n) temp2 = rbind( temp2, temp[[i]]) > return(temp2) > > > but this is not an efficient way since we keeping overwriting temp2. i > wonder if there's faster way. > > thanks > -- > View this message in context: > http://www.nabble.com/rbind-ing-list-tf3140137.html#a8703373 > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve? __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] rbind-ing list
hi, i have a list of data.frame that has same structure. i would like to know a efficient way of rbind-ing it. right now, i write: n = length(temp) # 'temp' is a list of data.frames temp2 = data.frame() for (i in 1:n) temp2 = rbind( temp2, temp[[i]]) return(temp2) but this is not an efficient way since we keeping overwriting temp2. i wonder if there's faster way. thanks -- View this message in context: http://www.nabble.com/rbind-ing-list-tf3140137.html#a8703373 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with RandomForest classwt option
The fifth option: actually it might be the easiest way: you "boost" your minority by like 10 fold (just repeat each minority record 10 times). Then run rf on the boosted sample. The learning process does not exactly behave like using classwt (setting classwt[2] = 10 will exactly gives weight=10 in gini calculation), but it is statistically similar. Be careful of oob error though. it won't give you a correct estimation of it since a sample can be used in training while its duplicates could be used in out-of-bag. But if you care about the splitting, this approach helps, IMHO. HTH, weiwei On 1/29/07, Betty Health <[EMAIL PROTECTED]> wrote: > Thank you very much, Weiwei and Jim! > > Yeah, I did read the post by Andy, the contributor of this package. It seems > that classwt is not implemented yet. For Weiwei's options, I have a few more > questions. Thanks! > > "1. try to use rf in fortran by following the linky below > http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm"; > > I read the Fortran code briefly. But I did not find the options for down > sampling. So does that mean I need to do down sampling myself? Could you > explain a little more about "2. make a wrapper function to do the down > sampling by yourself"? You mean I can do it in R or in Fortran? Some links > plz? I haven't done this before. > > Yeah, cut off did change for the final classification results. However from > what I tried, they did not influence how the nodes are split. So I would go > further in the above 2 options. > > Thank you again! > > Betty > > > > > On 1/28/07, Weiwei Shi <[EMAIL PROTECTED]> wrote: > > Dear Betty: > > > > I could suggest 3 options: > > > > 1. try to use rf in fortran by following the linky below > > > http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm > > > > 2. make a wrapper function to do the down sampling by yourself > > > > 3. try to use cutoff in randomForest, which might help in your situation. > > > > HTH, > > > > weiwei > > > > On 1/28/07, Betty Health < [EMAIL PROTECTED]> wrote: > > > Hello there, > > > > > > I am working on an extremely unbalanced two class classification > problems. I > > > wanna use "classwt" with "down sampling" together. By checking the > rfNews() > > > in R, it looks that classwt is not working yet. Then I looked at the > > > software from Salford. I did not find the down sampling option. I am > > > wondering if you have any experience to deal with this problem. Do you > know > > > any method or softwares can handle this problem? > > > > > > Thank you very much!! > > > > > > Betty > > > > > > [[alternative HTML version deleted]] > > > > > > __ > > > R-help@stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > > > -- > > Weiwei Shi, Ph.D > > Research Scientist > > GeneGO, Inc. > > > > "Did you always know?" > > "No, I did not. But I believed..." > > ---Matrix III > > > > -- Weiwei Shi, Ph.D Research Scientist GeneGO, Inc. "Did you always know?" "No, I did not. But I believed..." ---Matrix III __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] help with RandomForest classwt option
Hi, Betty: 1. Fortan code (http://www.stat.berkeley.edu/~breiman/RandomForests/cc_examples/prog.f) if(jclasswt.eq.0) then do j=1,nclass classwt(j)=1 enddo endif if(jclasswt.eq.1) then c fill in classwt(j) for each j: c classwt(1)=1. c classwt(2)=10. You need to set the jclasswt = 1 ( you can find by "search" through the codes). then "uncomment" the last two lines. Here you go with classwt in fortran. You can use this classwt for extremely-imbalanced classification problem. Down-sampling is one possible choice for that too but it is not directly implemented in rf. Check the following paper, and it might help. http://oz.berkeley.edu/users/chenchao/666.pdf 2. as to the wrapper function, the idea is that you can create a set of samples by applying some sampling probilities to implement down-sampling. Then build a rf model for each sample; suppose you call rf in this way for each sample, my.rf <- randomForest(...) then you can access the oob scores and prediction scores by my.rf$votes or my.rf$test$votes respectively. then you can average those scores by yourself, it is just like a simple meta-learning process but it does exactly what downsampling plus rf does, though downsampling is not implemented. 3. classwt and cutoff are used at different places. The former is used at two places: calculating the gini criteria and calculating the final vote from the leaf. While cutoff is only used in the final voting. So cutoff won't change the splitting while classwt can. However, since the current R's rf cannot do classwt, you can try to use cutoff to see if it helps in your case. 4. The fourth option is you can use my implementation of rf; But I did not write a manual for that; and it cannot show your splitting yet. HTH, weiwei On 1/29/07, Betty Health <[EMAIL PROTECTED]> wrote: > Thank you very much, Weiwei and Jim! > > Yeah, I did read the post by Andy, the contributor of this package. It seems > that classwt is not implemented yet. For Weiwei's options, I have a few more > questions. Thanks! > > "1. try to use rf in fortran by following the linky below > http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm"; > > I read the Fortran code briefly. But I did not find the options for down > sampling. So does that mean I need to do down sampling myself? Could you > explain a little more about "2. make a wrapper function to do the down > sampling by yourself"? You mean I can do it in R or in Fortran? Some links > plz? I haven't done this before. > > Yeah, cut off did change for the final classification results. However from > what I tried, they did not influence how the nodes are split. So I would go > further in the above 2 options. > > Thank you again! > > Betty > > > > > On 1/28/07, Weiwei Shi <[EMAIL PROTECTED]> wrote: > > Dear Betty: > > > > I could suggest 3 options: > > > > 1. try to use rf in fortran by following the linky below > > > http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm > > > > 2. make a wrapper function to do the down sampling by yourself > > > > 3. try to use cutoff in randomForest, which might help in your situation. > > > > HTH, > > > > weiwei > > > > On 1/28/07, Betty Health < [EMAIL PROTECTED]> wrote: > > > Hello there, > > > > > > I am working on an extremely unbalanced two class classification > problems. I > > > wanna use "classwt" with "down sampling" together. By checking the > rfNews() > > > in R, it looks that classwt is not working yet. Then I looked at the > > > software from Salford. I did not find the down sampling option. I am > > > wondering if you have any experience to deal with this problem. Do you > know > > > any method or softwares can handle this problem? > > > > > > Thank you very much!! > > > > > > Betty > > > > > > [[alternative HTML version deleted]] > > > > > > __ > > > R-help@stat.math.ethz.ch mailing list > > > https://stat.ethz.ch/mailman/listinfo/r-help > > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > > > -- > > Weiwei Shi, Ph.D > > Research Scientist > > GeneGO, Inc. > > > > "Did you always know?" > > "No, I did not. But I believed..." > > ---Matrix III > > > > -- Weiwei Shi, Ph.D Research Scientist GeneGO, Inc. "Did you always know?" "No, I did not. But I believed..." ---Matrix III __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] countour and poygon shading
If you look at the examples in ?xyplot.zoo in the zoo package there is an example of placing a rectangle behind a lattice plot. Maybe that applies here too? For classic graphics there is an example of displaying a rectangle behind a plot here: http://www.mayin.org/ajayshah/KB/R/html/g5.html On 1/29/07, J.M. Breiwick <[EMAIL PROTECTED]> wrote: > Hi, > > I have a contour plot and I want to shade a polygon (the area below a line) > but the polygon shading wipes out the contour lines. Does anybody know how > to shade the polygon and still see the contour lines? Thanks. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with RandomForest classwt option
Thank you very much, Weiwei and Jim! Yeah, I did read the post by Andy, the contributor of this package. It seems that classwt is not implemented yet. For Weiwei's options, I have a few more questions. Thanks! "1. try to use rf in fortran by following the linky below http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm"; I read the Fortran code briefly. But I did not find the options for down sampling. So does that mean I need to do down sampling myself? Could you explain a little more about "2. make a wrapper function to do the down sampling by yourself"? You mean I can do it in R or in Fortran? Some links plz? I haven't done this before. Yeah, cut off did change for the final classification results. However from what I tried, they did not influence how the nodes are split. So I would go further in the above 2 options. Thank you again! Betty On 1/28/07, Weiwei Shi <[EMAIL PROTECTED]> wrote: > > Dear Betty: > > I could suggest 3 options: > > 1. try to use rf in fortran by following the linky below > http://www.stat.berkeley.edu/~breiman/RandomForests/cc_software.htm > > 2. make a wrapper function to do the down sampling by yourself > > 3. try to use cutoff in randomForest, which might help in your situation. > > HTH, > > weiwei > > On 1/28/07, Betty Health <[EMAIL PROTECTED]> wrote: > > Hello there, > > > > I am working on an extremely unbalanced two class classification > problems. I > > wanna use "classwt" with "down sampling" together. By checking the > rfNews() > > in R, it looks that classwt is not working yet. Then I looked at the > > software from Salford. I did not find the down sampling option. I am > > wondering if you have any experience to deal with this problem. Do you > know > > any method or softwares can handle this problem? > > > > Thank you very much!! > > > > Betty > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > > -- > Weiwei Shi, Ph.D > Research Scientist > GeneGO, Inc. > > "Did you always know?" > "No, I did not. But I believed..." > ---Matrix III > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] countour and poygon shading
Hi, I have a contour plot and I want to shade a polygon (the area below a line) but the polygon shading wipes out the contour lines. Does anybody know how to shade the polygon and still see the contour lines? Thanks. Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] "Reversal" of Aggregation
Or equivalently: as.data.frame.table(mymatrix) On 1/29/07, Achim Zeileis <[EMAIL PROTECTED]> wrote: > > > On Mon, 29 Jan 2007, Roland Rau wrote: > > > Dear all, > > > > given I have a data.frame in a format like this > > > > mydf <- data.frame(age=rep(1:3,5), > >year=c(rep(1996,3), rep(1997,3), rep(1998,3), > > rep(1999,3), rep(2000,3)), > >income=1:15) > > mydf > > > > > > Now I convert it to some 2D-frequency table like this: > > mymatrix <- tapply(X=mydf$income, INDEX=list(mydf$age, mydf$year), > >FUN=sum) > > mymatrix > > > > > > My question is: > > How can I go the opposite way, i.e. from 'mymatrix' to 'mydf'? > > Is there an elegant way? > > You could do > as.data.frame(as.table(mymatrix)) > and then set appropriate column names. (The first two variables are also > coded as "factor"s which might or might not be what you want in this > example.) > > Z > > > > Thanks, > > Roland > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] CRAN will be down for 15 minutes
Dear R Community, Due to maintenance work CRAN will not be available at 30th January around 10 o'clock in the morning CET. Best regards, Stefan Theussl __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] "Reversal" of Aggregation
This is what I was hoping for! Thanks, Roland On 1/29/07, Achim Zeileis <[EMAIL PROTECTED]> wrote: > > > > On Mon, 29 Jan 2007, Roland Rau wrote: > > > Dear all, > > > > given I have a data.frame in a format like this > > > > mydf <- data.frame(age=rep(1:3,5), > >year=c(rep(1996,3), rep(1997,3), rep(1998,3), > > rep(1999,3), rep(2000,3)), > >income=1:15) > > mydf > > > > > > Now I convert it to some 2D-frequency table like this: > > mymatrix <- tapply(X=mydf$income, INDEX=list(mydf$age, mydf$year), > >FUN=sum) > > mymatrix > > > > > > My question is: > > How can I go the opposite way, i.e. from 'mymatrix' to 'mydf'? > > Is there an elegant way? > > You could do > as.data.frame(as.table(mymatrix)) > and then set appropriate column names. (The first two variables are also > coded as "factor"s which might or might not be what you want in this > example.) > > Z > > > > Thanks, > > Roland > > > > [[alternative HTML version deleted]] > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > > > [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] "Reversal" of Aggregation
On Mon, 29 Jan 2007, Roland Rau wrote: > Dear all, > > given I have a data.frame in a format like this > > mydf <- data.frame(age=rep(1:3,5), >year=c(rep(1996,3), rep(1997,3), rep(1998,3), > rep(1999,3), rep(2000,3)), >income=1:15) > mydf > > > Now I convert it to some 2D-frequency table like this: > mymatrix <- tapply(X=mydf$income, INDEX=list(mydf$age, mydf$year), >FUN=sum) > mymatrix > > > My question is: > How can I go the opposite way, i.e. from 'mymatrix' to 'mydf'? > Is there an elegant way? You could do as.data.frame(as.table(mymatrix)) and then set appropriate column names. (The first two variables are also coded as "factor"s which might or might not be what you want in this example.) Z > Thanks, > Roland > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with "readline" in compilatio of R for Solaris 11 (Nevada) in x86
Please consult the R-admin manual, as the INSTALL file asked you to. It explains this. On Mon, 29 Jan 2007, Octavio Tourinho wrote: > Dear friends, > In configuring R 2.4.1 for Solaris 11, using SunStudio 11 compilers, I > get the following error. > > checking readline/history.h usability... no > checking readline/history.h presence... no > checking for readline/history.h... no > checking readline/readline.h usability... no > checking readline/readline.h presence... no > checking for readline/readline.h... no > checking for rl_callback_read_char in -lreadline... no > checking for main in -lncurses... no > checking for main in -ltermcap... yes > checking for rl_callback_read_char in -lreadline... no > checking for history_truncate_file... no > configure: error: --with-readline=yes (default) and headers/libs are not > available > > I was not able to figure out what readline is about, whether it is > optional or not (at some point of the script it seems to be a flag which > can be true or false) and was therefore unable to debug it. > > Thanks for any help you can provide > > Octavio Tourinho > [EMAIL PROTECTED] > [EMAIL PROTECTED] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R for SAS & SPSS Users Document
Greetings, I am pleased to announce the availability of the document, "R for SAS and SPSS Users", at http://oit.utk.edu/scc/RforSAS&SPSSusers.doc . It presents an introductory view of R for people who already know SAS and/or SPSS. Included are 27 programs written in all three languages (i.e. 81 total) so that people can see how R works compared to the other two, task by task. I would appreciate it if folks with far more R expertise than I have could review it and provide advice on ways to improve programming examples or wording. The wording was challenging since the jargon used by the three packages differs so much. I'm sure there is much room for improvement. Cheers, Bob = Bob Muenchen (pronounced Min'-chen), Manager Statistical Consulting Center U of TN Office of Information Technology 200 Stokely Management Center, Knoxville, TN 37996-0520 Voice: (865) 974-5230 FAX: (865) 974-4810 Email: [EMAIL PROTECTED] Web: http://oit.utk.edu/scc, News: http://listserv.utk.edu/archives/statnews.html __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] "Reversal" of Aggregation
Dear all, given I have a data.frame in a format like this mydf <- data.frame(age=rep(1:3,5), year=c(rep(1996,3), rep(1997,3), rep(1998,3), rep(1999,3), rep(2000,3)), income=1:15) mydf Now I convert it to some 2D-frequency table like this: mymatrix <- tapply(X=mydf$income, INDEX=list(mydf$age, mydf$year), FUN=sum) mymatrix My question is: How can I go the opposite way, i.e. from 'mymatrix' to 'mydf'? Is there an elegant way? Thanks, Roland [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Bayesian States Space Modeling
If you are interested in linear Gaussian State Space models, then package dlm may be of interest. Giovanni > Date: Mon, 29 Jan 2007 20:50:49 +0530 > From: Shubha Vishwanath Karanth <[EMAIL PROTECTED]> > Sender: [EMAIL PROTECTED] > Precedence: list > Thread-topic: Bayesian States Space Modeling > Thread-index: AcdDuQ5nlhQW8jWNRcCUj+Tx1MEP8g== > > Hi R, > > > > What package of R can I use for Bayesian States Space Modeling? And any > other supporting packages? > > > > Thanks in advance, > > Shubha > > > > > > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- Giovanni Petris <[EMAIL PROTECTED]> Associate Professor Department of Mathematical Sciences University of Arkansas - Fayetteville, AR 72701 Ph: (479) 575-6324, 575-8630 (fax) http://definetti.uark.edu/~gpetris/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] [Fwd: Need to fit a regression line using orthogonal residuals]
Hi Jonothan, try the smatr package. I hope that this helps, Andrew On Mon, Jan 29, 2007 at 03:32:35PM -0500, Jonathon Kopecky wrote: > [Originally sent this to [EMAIL PROTECTED], but in case that's > the wrong list I'm re-posting. Apologies if this becomes a re-post] > Date: Mon, 29 Jan 2007 14:52:24 -0500 > From: Jonathon Kopecky <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: Need to fit a regression line using orthogonal residuals > > I'm trying to fit a simple linear regression of just Y ~ X, but both X > and Y are noisy. Thus instead of fitting a standard linear model > minimizing vertical residuals, I would like to minimize > orthogonal/perpendicular residuals. I have tried searching the > R-packages, but have not found anything that seems suitable. I'm not > sure what these types of residuals are typically called (they seem to > have many different names), so that may be my trouble. I do not want to > use Principal Components Analysis (as was answered to a previous > questioner a few years ago), I just want to minimize the combined noise > of my two variables. Is there a way for me to do this in R? > > Jonathon Kopecky > University of Michigan > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. -- Andrew Robinson Department of Mathematics and StatisticsTel: +61-3-8344-9763 University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599 http://www.ms.unimelb.edu.au/~andrewpr http://blogs.mbs.edu/fishing-in-the-bay/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] [Fwd: Need to fit a regression line using orthogonal residuals]
[Originally sent this to [EMAIL PROTECTED], but in case that's the wrong list I'm re-posting. Apologies if this becomes a re-post] --- Begin Message --- I'm trying to fit a simple linear regression of just Y ~ X, but both X and Y are noisy. Thus instead of fitting a standard linear model minimizing vertical residuals, I would like to minimize orthogonal/perpendicular residuals. I have tried searching the R-packages, but have not found anything that seems suitable. I'm not sure what these types of residuals are typically called (they seem to have many different names), so that may be my trouble. I do not want to use Principal Components Analysis (as was answered to a previous questioner a few years ago), I just want to minimize the combined noise of my two variables. Is there a way for me to do this in R? Jonathon Kopecky University of Michigan --- End Message --- __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Loop with string variable AND customizable "summary" output
On Mon, 2007-01-29 at 14:30 -0500, Gabor Grothendieck wrote: > Note that the nlme solution seems to give the same coefficients > but appears to use a single error term rather than one error > term per level of the conditioning variable and that would change various > other statistics relative to the other solutions should that matter. > > > summary(lmList(uptake ~ conc | Treatment, CO2)) > Call: > Model: uptake ~ conc | Treatment >Data: CO2 > > Coefficients: >(Intercept) >Estimate Std. Error t value Pr(>|t|) > nonchilled 22.019162.46416 8.935769 1.174616e-13 > chilled16.981422.46416 6.891361 1.146556e-09 >conc > Estimate Std. Error t value Pr(>|t|) > nonchilled 0.01982458 0.004692544 4.224699 6.292679e-05 > chilled0.01563659 0.004692544 3.332221 1.306259e-03 > > Residual standard error: 8.945667 on 80 degrees of freedom Gabor, Thanks for noting that. There is a solution using 'pool = FALSE': > summary(lmList(uptake ~ conc | Treatment, CO2, pool = FALSE)) Call: Model: uptake ~ conc | Treatment Data: CO2 Coefficients: (Intercept) Estimate Std. Error t value Pr(>|t|) nonchilled 22.01916 2.148475 10.248740 9.463480e-13 chilled16.98142 2.743761 6.189103 2.562416e-07 conc Estimate Std. Error t value Pr(>|t|) nonchilled 0.01982458 0.004091379 4.845452 1.934996e-05 chilled0.01563659 0.005224992 2.992653 4.721873e-03 I suppose that, while subtle, this could make this approach error prone for those who (like me in this case) miss it... Then of course, we get down to the format of the output, etc. :-) Thanks Gabor, Marc __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] overlay xyplot on contourplot in lattice in R
On 1/29/07, Kathy-Andrée Laplante-Albert <[EMAIL PROTECTED]> wrote: > > > Hi everybody, > > I want to do a contourplot in lattice with my raw data overlaid on it(xyplot) > which seemed to be a very easy thing to do. > > I've tried it in many ways, but I haven't succeeded at obtaining it. > > let's say x, y, and z as the variables that comes from the data frame ''ex'': > > therefore my countourplot is as followed : > > contourplot(z ~ x * y, cuts=550) > > I would like then to overalay on it xx and yy (same variables as x and y but > in > another data frame let's say ''example'') > > xyplot(example$xx, example$yy) > > How can I do it? > > It seems I could do it with the panel.contourplot and panel.xyplot options, > but > until now I haven't suceeded. I found this command that maybe could help me : > > > # contourplot > contourplot(elev ~ longitude * latitude, data = interpgrid, >panel = function(x, y, subscripts, ...) { > panel.contourplot(x, y, subscripts, ...) > panel.xyplot(ortann$longitude, ortann$latitude) >} ) This looks like something that should work. Could you explain why it "doesn't seem to work out"? -Deepayan > however, doesn't seem to work out, and I do not know what should I write for > subscripts. I do not understand the explanation in R. > > Is anyone could help me? > > Thanks a lot in advance! > > I use R, version 2.4.0. > > Kathy-Andrée Laplante-Albert > Étudiante à la maîtrise > Groupe de Recherche sur les Écosystèmes Aquatiques > Université du Québec à Trois-Rivières > C.P. 500, Trois-Rivières (Québec) Canada > > - > Courriel expédié via https://courriel.uqtr.ca > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] extra panel arguments to plot.nmGroupedData {nlme}
On 1/28/07, Dylan Beaudette <[EMAIL PROTECTED]> wrote: > Greetings, > > > I have a groupedData (nmGroupedData) object created with the following syntax: > > Soil <- groupedData( > ksat ~ conc | soil_id/sar/rep, > data=soil.data, > labels=list(x='Solution Concentration', y='Saturated Hydraulic > Conductivity'), > units=list(x='(cmol_c)', y='(cm/s)') > ) > > > the original data represents longitudinal observations in the form of: > 'data.frame': 1197 obs. of 5 variables: > $ soil_id: Factor w/ 19 levels "Arbuckle","Campbell",..: 16 16 16 16 > 16 16 16 16 16 16 ... > $ sar: int 12 12 12 12 12 12 12 6 6 6 ... > $ conc : num 500 100 50 10 5 1 0.003 500 100 50 ... > $ rep: Factor w/ 3 levels "C1","C2","C3": 1 1 1 1 1 1 1 1 1 1 ... > $ ksat : num 0.000214 0.000207 0.000198 0.000160 0.000108 ... > > the default plotting behaviour of this groupedData object works as expected: > plot( > Soil, > collapse=1, inner=~sar, aspect='fill', > scales=list( x=list(log=TRUE), y=list(log=TRUE)) > ) > > ... however, there is no way for me to alter the panels... > > for example, attempting to add a horizontal line with a call to > panel.abline= ... : > plot( > Soil, > collapse=1, inner=~sar, aspect='fill', > scales=list( x=list(log=TRUE), y=list(log=TRUE)), > FUN=mean, > panel= function(x,y, subscripts, groups) { > panel.xyplot(x, y, type='o') > panel.abline(h=0.005, col='black', lty=2) > } > ) > > ... results in an identical plot. Trying to re-create the results of > plot.nmGroupedData with a direct call to xyplot() has thus far been > unsucsessful- as I cannot figure out how to specifiy the original > formula in a meaningful way to xyplot: ksat ~ conc | soil_id/sar/rep . You might try something like ksat ~ conc | soil_id:sar:rep (also see ?interaction for a version with more control) -Deepayan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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 to fit a regression line using orthogonal residuals
I'm trying to fit a simple linear regression of just Y ~ X, but both X and Y are noisy. Thus instead of fitting a standard linear model minimizing vertical residuals, I would like to minimize orthogonal/perpendicular residuals. I have tried searching the R-packages, but have not found anything that seems suitable. I'm not sure what these types of residuals are typically called (they seem to have many different names), so that may be my trouble. I do not want to use Principal Components Analysis (as was answered to a previous questioner a few years ago), I just want to minimize the combined noise of my two variables. Is there a way for me to do this in R? Jonathon Kopecky University of Michigan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Biostrings
qing wrote: > > > Dear All, > > I am a beginner in learning the package of Biostrings currently and for > practice doing an example. > > library(Biostrings); > dnaAlph<-new("BioPatternAlphabet",DNAAlphabet(),c(N="AGCT", > + B="CGT",D="AGT",H="ACT",K="GT",M="AC",R="AG",S="CG", > + V="ACG",W="AT",Y="CT")); > Error in getClass(Class, where = topenv(parent.frame())) : > "BioPatternAlphabet" is not a defined class Hi Qing, "BioPatternAlphabet" was a class defined in Biostrings 1 (Biostrings version 1.y.z). In Biostrings 2, the class system has changed and you don't need to create an instance of the DNA alphabet anymore: - To create a DNAString object, just do: > mydna <- DNAString("AGG-HCNTT") > mydna 9-letter "DNAString" object Value: AGG-HCNTT - To get the DNA alphabet, call alphabet() on a DNAString object: > alphabet(mydna) [1] "A" "C" "G" "T" "M" "R" "S" "V" "W" "Y" "H" "K" "D" "B" "N" "-" or, if you don't have a DNAString instance yet: > DNA_ALPHABET [1] "A" "C" "G" "T" "M" "R" "S" "V" "W" "Y" "H" "K" "D" "B" "N" "-" Note that the "DNA alphabet" is the "IUPAC Extended Genetic Alphabet". - To get the mapping between the DNA alphabet and the set of ambiguities associated to each "extended" letter: > IUPAC_CODE_MAP A C G T M R W S Y K V "A""C""G""T" "AC" "AG" "AT" "CG" "CT" "GT" "ACG" H D B N "ACT" "AGT" "CGT" "ACGT" - For more details, see: > ?DNAString Cheers, H. PS: As Ducan said, the Bioconductor mailing list is a more appropriate place to ask help about a Bioconductor package. > > I am running R 2.4.1, Wimdows XP, Biostrings_2.2.1 > Any help or suggestions that you can provide will be greatly appreciated. > > Qing > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Dynamic Variable
Hi all, I have a file with a dozen weather stations with a dozen weather variables. I am trying to get a percentile of each variable for each station. I imported the file into a data frame Data. To get the percentile for Temperature for Baxley weather station, I used the following 2 statements. > BaxleyList[1] <- data.frame(quantile(subset(Data, (Name=='Baxley' & Temp>-50), select=Temp),probs=seq(0,1,0.01),na.rm=T,names=T)) > colnames(BaxleyList)[1] <- 'Temp' With this success, I want to loop through the station list. But, I ran into problem in the variable name "BaxleyList". I tried the following: #StationNames > StationNameList <- unique(Data$Name) > for (i in 1:1) { ThisStation <- StationNameList[i] ThisStationList <- paste(ThisStation,'List',sep="") ThisStationList[1] <- data.frame(quantile(subset(Data, (Name==ThisStation & Temp>-50), select=Temp),probs=seq(0,1,0.01),na.rm=T,names=T)) colnames(ThisStationList)[1] <- 'Temp' } But, ThisStationList will not give me BaxleyList. Thank you for all your helps in advance! Daniel Chan Meteorologist Georgia Forestry Commission P O Box 819 Macon, GA 31202 Tel: 478-751-3508 Fax: 478-751-3465 [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] overlay xyplot on contourplot in lattice in R
Hi everybody, I want to do a contourplot in lattice with my raw data overlaid on it(xyplot) which seemed to be a very easy thing to do. I've tried it in many ways, but I haven't succeeded at obtaining it. let's say x, y, and z as the variables that comes from the data frame ''ex'': therefore my countourplot is as followed : contourplot(z ~ x * y, cuts=550) I would like then to overalay on it xx and yy (same variables as x and y but in another data frame let's say ''example'') xyplot(example$xx, example$yy) How can I do it? It seems I could do it with the panel.contourplot and panel.xyplot options, but until now I haven't suceeded. I found this command that maybe could help me : # contourplot contourplot(elev ~ longitude * latitude, data = interpgrid, panel = function(x, y, subscripts, ...) { panel.contourplot(x, y, subscripts, ...) panel.xyplot(ortann$longitude, ortann$latitude) } ) however, doesn't seem to work out, and I do not know what should I write for subscripts. I do not understand the explanation in R. Is anyone could help me? Thanks a lot in advance! I use R, version 2.4.0. Kathy-Andrée Laplante-Albert Étudiante à la maîtrise Groupe de Recherche sur les Écosystèmes Aquatiques Université du Québec à Trois-Rivières C.P. 500, Trois-Rivières (Québec) Canada - Courriel expédié via https://courriel.uqtr.ca __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Loop with string variable AND customizable "summary" output
Note that the nlme solution seems to give the same coefficients but appears to use a single error term rather than one error term per level of the conditioning variable and that would change various other statistics relative to the other solutions should that matter. > summary(lmList(uptake ~ conc | Treatment, CO2)) Call: Model: uptake ~ conc | Treatment Data: CO2 Coefficients: (Intercept) Estimate Std. Error t value Pr(>|t|) nonchilled 22.019162.46416 8.935769 1.174616e-13 chilled16.981422.46416 6.891361 1.146556e-09 conc Estimate Std. Error t value Pr(>|t|) nonchilled 0.01982458 0.004692544 4.224699 6.292679e-05 chilled0.01563659 0.004692544 3.332221 1.306259e-03 Residual standard error: 8.945667 on 80 degrees of freedom On 1/29/07, Marc Schwartz <[EMAIL PROTECTED]> wrote: > Or, to throw yet another couple of possibilities into the mix: > > lapply(split(YourDF, YourDF$country), > function(x) summary(lm(y ~ x, data = x)) > > and: > > library(nlme) > summary(lmList(y ~ x | country, YourDF)) > > > See ?split and help(lmList, package = nlme) > > HTH, > > Marc Schwartz > > On Mon, 2007-01-29 at 09:03 -0800, Bert Gunter wrote: > > Prior answers are certainly correct, but this is where lists and lapply > > shine: > > > > result<-lapply(list(UK,USA),function(z)summary(lm(y~x,data=z))) > > > > As in (nearly) all else, simplicity is a virtue. > > > > If you prefer to keep the data sources as a character vector,dataNames, > > > > result<-lapply(dataNames,function(z)summary(lm(y~x,data=get(z > > > > should work. > > > > Note: both of these are untested for the general case where they might be > > used within a function and may not find the right z unless you pay attention > > to scope, especially in the get() construction. > > > > > > Bert Gunter > > Genentech Nonclinical Statistics > > South San Francisco, CA 94404 > > > > > > -Original Message- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] > > Sent: Monday, January 29, 2007 8:23 AM > > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] > > Cc: r-help@stat.math.ethz.ch > > Subject: Re: [R] Loop with string variable AND customizable "summary" output > > > > Dear All, > > Thank you very much for your help! > > Carlo > > > > -Original Message- > > From: Wensui Liu [mailto:[EMAIL PROTECTED] > > Sent: Mon 29/01/2007 15:39 > > To: Rosa,C > > Cc: r-help@stat.math.ethz.ch > > Subject: Re: [R] Loop with string variable AND customizable "summary" output > > > > Carlo, > > > > try something like: > > > > for (i in c("UK","USA")) > > { > > summ<-summary(lm(y ~ x), subset = (country = i)) > > assign(paste('output', i, sep = ''), summ); > > } > > > > (note: it is untested, sorry). > > > > On 1/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Dear All, > > > > > > I am using R for my research and I have two questions about it: > > > > > > 1) is it possible to create a loop using a string, instead of a numeric > > vector? I have in mind a specific problem: > > > > > > Suppose you have 2 countries: UK, and USA, one dependent (y) and one > > independent variable (y) for each country (vale a dire: yUK, xUK, yUSA, > > xUSA) and you want to run automatically the following regressions: > > > > > > > > > > > > for (i in c("UK","USA")) > > > > > > output{i}<-summary(lm(y{i} ~ x{i})) > > > > > > > > > > > > In other words, at the end I would like to have two objects as output: > > "outputUK" and "outputUSA", which contain respectively the results of the > > first and second regression (yUK on xUK and yUSA on xUSA). > > > > > > > > > > > > 2) in STATA there is a very nice code ("outreg") to display nicely (and as > > the user wants to) your regression results. > > > > > > Is there anything similar in R / R contributed packages? More precisely, I > > am thinking of something that is close in spirit to "summary" but it is also > > customizable. For example, suppose you want different Signif. codes: 0 > > '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 or a different format display > > (i.e. without "t value" column) implemented automatically (without manually > > editing it every time). > > > > > > In alternative, if I was able to see it, I could modify the source code of > > the function "summary", but I am not able to see its (line by line) code. > > Any idea? > > > > > > Or may be a customizable regression output already exists? > > > > > > Thanks really a lot! > > > > > > Carlo > > > > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R
Re: [R] Cronbach's alpha
Dear all, on a practical level an alpha < 0 can be found, when a scale is constructed / evaluated consisting only a few items (say 5) and one of the items is coded in the wrong direction (values that should represent a high score wrongfully represent a low score). Rense On Jan 24, 2007, at 22:44 , Weiwei Shi wrote: > Hi, there: > > I read that article (thanks Chucks, etc to point that out). Now I > understand how those negatives are generated since my research subject > "should" have negative convariance but they "are" measuring the same > thing. So, I am confused about this "same" thing and about if it is > proper to go ahead to use this measurement. > > To clear my point , I describe my idea here a little bit. My idea is > to look for a way to assign a "statistic" or measurement to a set of > variables to see if they "act" cohesively or coherently for an event. > Instead of using simple correlation, which describes var/var > correlation; I wanted to get a "total correlation" so that I can > compare between setS of variables. Initially I "made" that word but > google helps me find that statistic exists! So I read into it and post > my original post on "total correlation". (Ben, you can find total > correlation from wiki). > > I was suggested to use this alpha since it measures a "one latent > construct", in which matches my idea about one event. I have a feeling > it is like factor analysis; however, the grouping of variables has > been fixed by domain knowledge. > > Sorry if it is off-list topic but I feel it is very interesting to > go ahead. > > Thanks, > > Weiwei > > > > On 1/24/07, Doran, Harold <[EMAIL PROTECTED]> wrote: >> Hi Dave >> >> We had a bit of an off list discussion on this. You're correct, it >> can >> be negative IF the covariance among individual items is negative >> AND if >> that covariance term is larger than the sum of the individual item >> variances. Both of these conditions would be needed to make alpha go >> negative. >> >> Psychometrically speaking, this introduces some question as to >> whether >> the items are measuring the same latent trait. That is, if there is a >> negative covariance among items, but those items are thought to >> measure >> a common trait, then (I'm scratching my head) I think we have a >> dimensionality issue. >> >> >> >>> -Original Message- >>> From: [EMAIL PROTECTED] >>> [mailto:[EMAIL PROTECTED] On Behalf Of Dave Atkins >>> Sent: Wednesday, January 24, 2007 4:08 PM >>> To: R-help@stat.math.ethz.ch >>> Subject: Re: [R] Cronbach's alpha >>> >>> >>> Harold & Weiwei-- >>> >>> Actually, alpha *can* go negative, which means that items are >>> reliably different as opposed to reliably similar. This >>> happens when the sum of the covariances among items is >>> negative. See the ATS site below for a more thorough explanation: >>> >>> http://www.ats.ucla.edu/STAT/SPSS/library/negalpha.htm >>> >>> Hope that helps. >>> >>> cheers, Dave >>> -- >>> Dave Atkins, PhD >>> Assistant Professor in Clinical Psychology Fuller Graduate >>> School of Psychology >>> Email: [EMAIL PROTECTED] >>> Phone: 626.584.5554 >>> >>> >>> Weiwei >>> >>> Something is wrong. Coefficient alpha is bounded between 0 and 1, so >>> negative values are outside the parameter space for a reliability >>> statistic. Recall that reliability is the ratio of "true >>> score" variance >>> to "total score variance". That is >>> >>> var(t)/ var(t) + var(e) >>> >>> If all variance is true score variance, then var(e)=0 and the >>> reliability is var(t)/var(t)=1. On the other hand, if all >>> variance is >>> measurement error, then var(t) = 0 and reliability is 0. >>> >>> Here is a function I wrote to compute alpha along with an >>> example. Maybe >>> try recomputing your statistic using this function and see if you >>> get >>> the same result. >>> >>> alpha <- function(columns){ >>> k <- ncol(columns) >>> colVars <- apply(columns, 2, var) >>> total <- var(apply(columns, 1, sum)) >>> a <- (total - sum(colVars)) / total * (k/(k-1)) >>> a >>> } >>> >>> data(LSAT, package='ltm') alpha(LSAT) >>> [1] 0.2949972 >>> >>> >>> Harold >>> -Original Message- From: r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of >>> Weiwei Shi Sent: Wednesday, January 24, 2007 1:17 PM To: R R Subject: [R] Cronbach's alpha Dear Listers: I used cronbach{psy} to evaluate the internal consistency and some set of variables gave me alpha=-1.1003, while other, alpha=-0.2; alpha=0.89; and so on. I am interested in knowing how to interpret 1. negative value 2. negative value less than -1. I also want to re-mention my previous question about how to evaluate the consistency of a set of variables and about the total correlation (my 2 cent to answer the question). Is there any function in R to do that? Thank you very much!
Re: [R] Loop with string variable AND customizable "summary" output
Or, to throw yet another couple of possibilities into the mix: lapply(split(YourDF, YourDF$country), function(x) summary(lm(y ~ x, data = x)) and: library(nlme) summary(lmList(y ~ x | country, YourDF)) See ?split and help(lmList, package = nlme) HTH, Marc Schwartz On Mon, 2007-01-29 at 09:03 -0800, Bert Gunter wrote: > Prior answers are certainly correct, but this is where lists and lapply > shine: > > result<-lapply(list(UK,USA),function(z)summary(lm(y~x,data=z))) > > As in (nearly) all else, simplicity is a virtue. > > If you prefer to keep the data sources as a character vector,dataNames, > > result<-lapply(dataNames,function(z)summary(lm(y~x,data=get(z > > should work. > > Note: both of these are untested for the general case where they might be > used within a function and may not find the right z unless you pay attention > to scope, especially in the get() construction. > > > Bert Gunter > Genentech Nonclinical Statistics > South San Francisco, CA 94404 > > > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] > Sent: Monday, January 29, 2007 8:23 AM > To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] > Cc: r-help@stat.math.ethz.ch > Subject: Re: [R] Loop with string variable AND customizable "summary" output > > Dear All, > Thank you very much for your help! > Carlo > > -Original Message- > From: Wensui Liu [mailto:[EMAIL PROTECTED] > Sent: Mon 29/01/2007 15:39 > To: Rosa,C > Cc: r-help@stat.math.ethz.ch > Subject: Re: [R] Loop with string variable AND customizable "summary" output > > Carlo, > > try something like: > > for (i in c("UK","USA")) > { > summ<-summary(lm(y ~ x), subset = (country = i)) > assign(paste('output', i, sep = ''), summ); > } > > (note: it is untested, sorry). > > On 1/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Dear All, > > > > I am using R for my research and I have two questions about it: > > > > 1) is it possible to create a loop using a string, instead of a numeric > vector? I have in mind a specific problem: > > > > Suppose you have 2 countries: UK, and USA, one dependent (y) and one > independent variable (y) for each country (vale a dire: yUK, xUK, yUSA, > xUSA) and you want to run automatically the following regressions: > > > > > > > > for (i in c("UK","USA")) > > > > output{i}<-summary(lm(y{i} ~ x{i})) > > > > > > > > In other words, at the end I would like to have two objects as output: > "outputUK" and "outputUSA", which contain respectively the results of the > first and second regression (yUK on xUK and yUSA on xUSA). > > > > > > > > 2) in STATA there is a very nice code ("outreg") to display nicely (and as > the user wants to) your regression results. > > > > Is there anything similar in R / R contributed packages? More precisely, I > am thinking of something that is close in spirit to "summary" but it is also > customizable. For example, suppose you want different Signif. codes: 0 > '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 or a different format display > (i.e. without "t value" column) implemented automatically (without manually > editing it every time). > > > > In alternative, if I was able to see it, I could modify the source code of > the function "summary", but I am not able to see its (line by line) code. > Any idea? > > > > Or may be a customizable regression output already exists? > > > > Thanks really a lot! > > > > Carlo > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Problem with "readline" in compilatio of R for Solaris 11 (Nevada) in x86
Dear friends, In configuring R 2.4.1 for Solaris 11, using SunStudio 11 compilers, I get the following error. checking readline/history.h usability... no checking readline/history.h presence... no checking for readline/history.h... no checking readline/readline.h usability... no checking readline/readline.h presence... no checking for readline/readline.h... no checking for rl_callback_read_char in -lreadline... no checking for main in -lncurses... no checking for main in -ltermcap... yes checking for rl_callback_read_char in -lreadline... no checking for history_truncate_file... no configure: error: --with-readline=yes (default) and headers/libs are not available I was not able to figure out what readline is about, whether it is optional or not (at some point of the script it seems to be a flag which can be true or false) and was therefore unable to debug it. Thanks for any help you can provide Octavio Tourinho [EMAIL PROTECTED] [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] Hmisc Version 3.1-2 uploaded to CRAN repository
Hmisc 3.1-2 has been uploaded to the CRAN incoming directory. Change log 3.2-1 1/25/2007: Hmisc function 'ecdf' has been renamed 'Ecdf' to deconflict it with the existing 'ecdf' function in base. Fixed Bug in format.df that would create numbers with many trailing zeros. Added arguments 'math.row.names' and 'math.col.names' to indicate that the row or col names should be wrapped in the latex math environment. Fixed problem with 'histbackback' function. -- Charles Dupont Computer System Analyst School of Medicine Department of Biostatistics Vanderbilt University ___ R-packages mailing list R-packages@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Loop with string variable AND customizable "summary" output
Prior answers are certainly correct, but this is where lists and lapply shine: result<-lapply(list(UK,USA),function(z)summary(lm(y~x,data=z))) As in (nearly) all else, simplicity is a virtue. If you prefer to keep the data sources as a character vector,dataNames, result<-lapply(dataNames,function(z)summary(lm(y~x,data=get(z should work. Note: both of these are untested for the general case where they might be used within a function and may not find the right z unless you pay attention to scope, especially in the get() construction. Bert Gunter Genentech Nonclinical Statistics South San Francisco, CA 94404 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Monday, January 29, 2007 8:23 AM To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Loop with string variable AND customizable "summary" output Dear All, Thank you very much for your help! Carlo -Original Message- From: Wensui Liu [mailto:[EMAIL PROTECTED] Sent: Mon 29/01/2007 15:39 To: Rosa,C Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Loop with string variable AND customizable "summary" output Carlo, try something like: for (i in c("UK","USA")) { summ<-summary(lm(y ~ x), subset = (country = i)) assign(paste('output', i, sep = ''), summ); } (note: it is untested, sorry). On 1/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Dear All, > > I am using R for my research and I have two questions about it: > > 1) is it possible to create a loop using a string, instead of a numeric vector? I have in mind a specific problem: > > Suppose you have 2 countries: UK, and USA, one dependent (y) and one independent variable (y) for each country (vale a dire: yUK, xUK, yUSA, xUSA) and you want to run automatically the following regressions: > > > > for (i in c("UK","USA")) > > output{i}<-summary(lm(y{i} ~ x{i})) > > > > In other words, at the end I would like to have two objects as output: "outputUK" and "outputUSA", which contain respectively the results of the first and second regression (yUK on xUK and yUSA on xUSA). > > > > 2) in STATA there is a very nice code ("outreg") to display nicely (and as the user wants to) your regression results. > > Is there anything similar in R / R contributed packages? More precisely, I am thinking of something that is close in spirit to "summary" but it is also customizable. For example, suppose you want different Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 or a different format display (i.e. without "t value" column) implemented automatically (without manually editing it every time). > > In alternative, if I was able to see it, I could modify the source code of the function "summary", but I am not able to see its (line by line) code. Any idea? > > Or may be a customizable regression output already exists? > > Thanks really a lot! > > Carlo > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- WenSui Liu A lousy statistician who happens to know a little programming (http://spaces.msn.com/statcompute/blog) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Multiple comparisons when interacction
In the model: lm.1 <- lm(variable ~ BLOC + TIL * YEAR , data=selvanera) I found TIL*YEAR interaction significant. Then I am trying to compare means of the different levels of TIL inside every YEAR using: mc.2 <- glht(lm.1, linfct = mcp(TIL*YEAR="Tukey")) summary(mc.2, test = univariate()) but it does not work. There is any way of doing this, like the SLICE option in PROC GLM (SAS)? Thanks a lot, Jorge -- ** Jorge Lampurlanés Castel Departament d'Enginyeria Agroforestal Escola Tècnica Superior d'Enginyeria Agrària Universitat de Lleida Avinguda Rovira Roure, 191 25198-LLEIDA SPAIN Tl.: +34 973 70 25 37 Fax.:+34 073 70 26 73 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotting results from tapply; using indexing to incorporate error bars
Mike, Using interaction.plot(): with(ex.dat, interaction.plot(x1, x2, response = y1, type = "b", pch = 21, col = c("red", "blue"), ylim = range(ex.dat$y1))) arrows(1:2, xbar + sem, 1:2, xbar - sem, col = rep(c("red", "blue"), each = 2), angle = 90, code = 3, length = .05) Note that you need to draw two pairs of error bars (4). By specifying only two colors in the call to arrows() as you do below, they will be recycled as: red, blue, red, blue This is defined in ?arrows: The graphical parameters 'col', 'lty' and 'lwd' can be vectors of length greater than one and will be recycled if necessary. What you actually want is: red, red, blue, blue which you get with: > rep(c("red", "blue"), each = 2) [1] "red" "red" "blue" "blue" Try the above and it should work. HTH, Marc On Mon, 2007-01-29 at 12:12 -0500, Michael Rennie wrote: > Hi, Mark > > Thanks for the examples- this is great, and has helped me understand alot > more what's going on in the plotting functions. > > Now that I'm trying to work error bars into this, I was curious if someone > might give me a hand indexing this properly so that I can format my error > bars to match the formatting of the grouping variables that match the lines > in the plot. > > Here's a re-worked example from my first submission where I calculate > standard errors for plotting on the figure, plot the error bars, and try to > index them to match the appropriate lines. The values appear to be in the > right place (I've turned on the "legend" option for the interaction plot to > help verify this), however, my attempts at matching the colours on the bars > to the colours on the lines fails miserably (as you'll see if you execute > the code below). Is there any way to assign my colours to match them in a > way that makes more sense? > > Thanks for your help so far, > > Mike > > y1<-rnorm(40, 2) > x1<-rep(1:2, each=20) > x2<-rep(1:2, each=10, times=2) > > ex.dat<-data.frame(cbind(y1,x1,x2)) > > ex.dat$x1<-factor(ex.dat$x1, labels=c("A", "B")) > ex.dat$x2<-factor(ex.dat$x2, labels=c("C", "D")) > > attach(ex.dat) > > xbar<-tapply(ex.dat$y1, ex.dat[,-1], mean) > xbar > s <- tapply(ex.dat$y1, ex.dat[,-1], sd) > n <- tapply(ex.dat$y1, ex.dat[,-1], length) > sem <- s/sqrt(n) > sem > > row.names(xbar) > xbar[,1] > > > > #from Marc Schwartz# > > #par(mfcol = c(1, 3)) > > > options(graphics.record = TRUE) > > #using plot > > with(ex.dat, plot(1:2, xbar[, 1], ylim = range(y1), >type = "b", col = "red", >lty = c("dashed", "solid"), >xaxt = "n", xlab = "x1", >ylab = "mean of y1")) > > > with(ex.dat, points(1:2, xbar[, 2], col = "blue", > type = "b")) > > > axis(1, at = 1:2, labels = c("A", "B")) > > > #using matplot > > matplot(1:2, xbar, col = c("red", "blue"), > pch = 21, type = "b", ylim = range(y1), > lty = c("dashed", "solid"), > xaxt = "n", xlab = "x1", > ylab = "mean of y1") > > > axis(1, at = 1:2, labels = c("A", "B")) > arrows(1:2,xbar+sem, 1:2,xbar-sem, col = c("red", "blue"), angle=90, > code=3, length=.1) > > #using interaction.plot > > with(ex.dat, interaction.plot(x1, x2, response = y1, >type = "b", pch = 21, >col = c("red", "blue"), >ylim = range(ex.dat$y1))) > > arrows(1:2,xbar+sem, 1:2,xbar-sem, col = c("red", "blue"), angle=90, > code=3, length=.05) > > #as you can see, though the values for standard errors match the > appropriate means, the assignment of colours does not. > > > > At 12:46 PM 26/01/2007, Marc Schwartz wrote: > >On Fri, 2007-01-26 at 11:50 -0500, Michael Rennie wrote: > > > Hi, there > > > > > > I'm trying to plot what is returned from a call to tapply, and can't > > figure > > > out how to do it. My guess is that it has something to do with the > > > inclusion of row names when you ask for the values you're interested in, > > > but if anyone has any ideas on how to get it to work, that would be > > > stellar. Here's some example code: > > > > > > y1<-rnorm(40, 2) > > > x1<-rep(1:2, each=20) > > > x2<-rep(1:2, each=10 times=2) > > > > > > ex.dat<-data.frame(cbind(y1,x1,x2)) > > > > > > ex.dat$x1<-factor(ex.dat$x1, labels=c("A", "B")) > > > ex.dat$x2<-factor(ex.dat$x2, labels=c("C", "D")) > > > > > > attach(ex.dat) > > > > > > xbar<-tapply(ex.dat$y1, ex.dat[,-1], mean) > > > xbar > > > > > > #values I'd like to plot: > > > row.names(xbar) #levels of x1 > > > xbar[,1] #mean response of y1 for group C (x2) across x1 > > > > > > #plot mean response y1 for group C against x1 (i.e., using x2 as a > > grouping > > > factor). > > > plot(row.names(xbar), xbar[,1], ylim=range[y1]) > > > > > > #This is where things break down. The error message states that I ne
Re: [R] how to create daily / weekly ts object?
Look at the 'fame' package I recently put up. You don't need to have the FAME database installed to use it. Among other things, the package defines a class tis (Time Indexed Series) that can handle weekly time series. "Wensui Liu" <[EMAIL PROTECTED]> writes: > Monthly and Quarterly ts obj. is easy to understand. But I couldn't > find an example in R manual how to create daily or weekly ts object. > Could you please shed some light on it? > I really appreciate it. -- Jeff __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotting results from tapply; using indexing to incorporate error bars
Hi, Mark Thanks for the examples- this is great, and has helped me understand alot more what's going on in the plotting functions. Now that I'm trying to work error bars into this, I was curious if someone might give me a hand indexing this properly so that I can format my error bars to match the formatting of the grouping variables that match the lines in the plot. Here's a re-worked example from my first submission where I calculate standard errors for plotting on the figure, plot the error bars, and try to index them to match the appropriate lines. The values appear to be in the right place (I've turned on the "legend" option for the interaction plot to help verify this), however, my attempts at matching the colours on the bars to the colours on the lines fails miserably (as you'll see if you execute the code below). Is there any way to assign my colours to match them in a way that makes more sense? Thanks for your help so far, Mike y1<-rnorm(40, 2) x1<-rep(1:2, each=20) x2<-rep(1:2, each=10, times=2) ex.dat<-data.frame(cbind(y1,x1,x2)) ex.dat$x1<-factor(ex.dat$x1, labels=c("A", "B")) ex.dat$x2<-factor(ex.dat$x2, labels=c("C", "D")) attach(ex.dat) xbar<-tapply(ex.dat$y1, ex.dat[,-1], mean) xbar s <- tapply(ex.dat$y1, ex.dat[,-1], sd) n <- tapply(ex.dat$y1, ex.dat[,-1], length) sem <- s/sqrt(n) sem row.names(xbar) xbar[,1] #from Marc Schwartz# #par(mfcol = c(1, 3)) options(graphics.record = TRUE) #using plot with(ex.dat, plot(1:2, xbar[, 1], ylim = range(y1), type = "b", col = "red", lty = c("dashed", "solid"), xaxt = "n", xlab = "x1", ylab = "mean of y1")) with(ex.dat, points(1:2, xbar[, 2], col = "blue", type = "b")) axis(1, at = 1:2, labels = c("A", "B")) #using matplot matplot(1:2, xbar, col = c("red", "blue"), pch = 21, type = "b", ylim = range(y1), lty = c("dashed", "solid"), xaxt = "n", xlab = "x1", ylab = "mean of y1") axis(1, at = 1:2, labels = c("A", "B")) arrows(1:2,xbar+sem, 1:2,xbar-sem, col = c("red", "blue"), angle=90, code=3, length=.1) #using interaction.plot with(ex.dat, interaction.plot(x1, x2, response = y1, type = "b", pch = 21, col = c("red", "blue"), ylim = range(ex.dat$y1))) arrows(1:2,xbar+sem, 1:2,xbar-sem, col = c("red", "blue"), angle=90, code=3, length=.05) #as you can see, though the values for standard errors match the appropriate means, the assignment of colours does not. At 12:46 PM 26/01/2007, Marc Schwartz wrote: >On Fri, 2007-01-26 at 11:50 -0500, Michael Rennie wrote: > > Hi, there > > > > I'm trying to plot what is returned from a call to tapply, and can't > figure > > out how to do it. My guess is that it has something to do with the > > inclusion of row names when you ask for the values you're interested in, > > but if anyone has any ideas on how to get it to work, that would be > > stellar. Here's some example code: > > > > y1<-rnorm(40, 2) > > x1<-rep(1:2, each=20) > > x2<-rep(1:2, each=10 times=2) > > > > ex.dat<-data.frame(cbind(y1,x1,x2)) > > > > ex.dat$x1<-factor(ex.dat$x1, labels=c("A", "B")) > > ex.dat$x2<-factor(ex.dat$x2, labels=c("C", "D")) > > > > attach(ex.dat) > > > > xbar<-tapply(ex.dat$y1, ex.dat[,-1], mean) > > xbar > > > > #values I'd like to plot: > > row.names(xbar) #levels of x1 > > xbar[,1] #mean response of y1 for group C (x2) across x1 > > > > #plot mean response y1 for group C against x1 (i.e., using x2 as a > grouping > > factor). > > plot(row.names(xbar), xbar[,1], ylim=range[y1]) > > > > #This is where things break down. The error message states that I need > > "finite xlim values" but I haven't assigned anything to xlim. If I just > > plot the data: > > > > plot(x1, y1) > > > > #This works fine. > > > > #And, I can get this to work: > > > > stripchart(xbar[1,]~row.names(xbar), vert=T) > > > > #However, I'd like to then add the values for the second set of means > > (i.e., mean values for group D against x1, or (xbar[,2])) to the plot. > > #I tried following up the previous command with: > > > > points(row.names(xbar), xbar[,2]) > > > > #But that returns an error as well (NAs introduced by coercion). > > > > > > > > Any suggestions? > > > > Cheers, > > > > Mike > > > > PS- some of you might suggest for me to use interaction.plot, since > this is > > essentially what I'm building here. True, but I can't get error bars using > > interaction.plot. I'm therefore trying to build my own version where I can > > specify the inclusion of error bars. Presumably the interaction.plot has > > figured out how to do what I'm attempting, so I have some faith that I am > > on the right track > >Michael, > >The problem is that when you are using the rownames for 'xbar', they are >a character vector: > > > str(rownames(xbar)) > chr [1:2] "A" "B > >When you attempt to use the s
Re: [R] Loop with string variable AND customizable "summary" output
And yet one more. This one does not use eval but uses do.call, quote and bquote instead: lapply(levels(CO2$Treatment), function(lev) do.call("lm", list(uptake ~ conc, quote(CO2), subset = bquote(Treatment == .(lev) On 1/29/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > In thinking about this a bit more here is an even shorter one yet it > does show the level in the Call output. See ?bquote > > lapply(levels(CO2$Treatment), function(lev) > eval(bquote(lm(uptake ~ conc, CO2, subset = Treatment == .(lev) > > > On 1/29/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > > Often you will find that if you arrange your data in a > > desirable way in the first place everything becomes > > easier. What you really want is a data frame such > > as the last three columns of the builtin data frame > > CO2 where Treatment corresponds to country and > > the two numeric variables correspond to your y and x. > > > > Then its easy: > > > > lapply(levels(CO2$Treatment), function(lev) > > lm(uptake ~ conc, CO2, subset = Treatment == lev)) > > > > The only problem with the above is that the Call: in the > > output does not really tell you which level of Treatment > > is being used since it literally shows > > "lm(uptake ~ conc, CO2, subset = Treatment == lev)" > > each time. To get around substitute the value of lev in. > > Because R uses delayed evaluation you also need to force the > > evaluation of lev prior to substituting it in: > > > > lapply(levels(CO2$Treatment), function(lev) { > > lev <- force(lev) > > eval(substitute(lm(uptake ~ conc, CO2, subset = Treatment == lev)), > > list(lev = lev)) > > }) > > > > > > Now if you really want to do it the way you specified originally > > try this. > > > > Suppose we use attach to grab the variables > > x1, x2, x3, x4, y1, y2, y3, y4 out of the builtin > > anscombe data frame for purposes of getting > > our hands on some sample data. In your case > > the variables would already be in the workspace > > so the attach is not needed. > > > > Then simply reconstruct the formula in fo. You > > could simply use lm(fo) but then the Call: in the > > output of lm would literally read lm(fo) so its > > better to use do.call: > > > > # next line gives the variables x1, x2, x3, x4, y1, y2, y3, y4 > > # from the builtin ancombe data set. > > # In your case such variables would already exist. > > attach(anscombe) > > lapply(1:4, function(i) { > > ynm <- paste("y", i, sep = "") > > xnm <- paste("x", i, sep = "") > > fo <- as.formula(paste(ynm, "~", xnm)) > > do.call("lm", list(fo)) > > }) > > detach(anscombe) > > > > Or if all the variables have the same length you could use > > a form such as ancombe in the first place: > > > > Actually this is not really a recommended way of > > proceeding. You would be better off putting all > > your variables in a data frame and using that. > > > > lapply(1:4, function(i) { > >fo <- as.formula(paste(names(anscombe)[i+4], "~", names(anscombe)[i])) > >do.call("lm", list(fo, data = quote(anscombe))) > > }) > > > > or > > > > lapply(1:4, function(i) { > >fo <- y ~ x > >fo[[2]] <- as.name(names(anscombe)[i+4]) > >fo[[3]] <- as.name(names(anscombe)[i]) > >do.call("lm", list(fo, data = quote(anscombe))) > > }) > > > > > > > > On 1/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > Dear All, > > > > > > I am using R for my research and I have two questions about it: > > > > > > 1) is it possible to create a loop using a string, instead of a numeric > > > vector? I have in mind a specific problem: > > > > > > Suppose you have 2 countries: UK, and USA, one dependent (y) and one > > > independent variable (y) for each country (vale a dire: yUK, xUK, yUSA, > > > xUSA) and you want to run automatically the following regressions: > > > > > > > > > > > > for (i in c("UK","USA")) > > > > > > output{i}<-summary(lm(y{i} ~ x{i})) > > > > > > > > > > > > In other words, at the end I would like to have two objects as output: > > > "outputUK" and "outputUSA", which contain respectively the results of the > > > first and second regression (yUK on xUK and yUSA on xUSA). > > > > > > > > > > > > 2) in STATA there is a very nice code ("outreg") to display nicely (and > > > as the user wants to) your regression results. > > > > > > Is there anything similar in R / R contributed packages? More precisely, > > > I am thinking of something that is close in spirit to "summary" but it is > > > also customizable. For example, suppose you want different Signif. codes: > > > 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 or a different format > > > display (i.e. without "t value" column) implemented automatically > > > (without manually editing it every time). > > > > > > In alternative, if I was able to see it, I could modify the source code > > > of the function "summary", but I am not able to see its (line by line) > > > code. Any idea? > > > > > > Or may be a customizable regression output already
Re: [R] lmer2 error under Mac OS X on PowerPC G5 but not on Dual-Core Intel Xeon
On Mon, 29 Jan 2007, Michael Kubovy wrote: > On Jan 28, 2007, at 9:39 PM, Benilton Carvalho wrote: > >> This seems to be due to the fact that you didn't have enough memory >> when running lmer2. >> >> I might be wrong, but I think Calloc tries to get contiguous >> memory, so this might the problem. >> >> If you are positive that you have enough memory, a gc() might help. Generally, it almost never helps. R will itself do a gc() before giving up on memory allocation, and R is not allocating memory with Calloc, the OS services are being used. Nothing is going to help allocating 3.6Gb on a 32-bit OS. (One case where it might help is doing a large allocation with Calloc after freeing a large R object, on OSes where gc() will actually give memory back to the pool Calloc uses.) What makes no sense is that it says using as.double gave an error message from Calloc. No known as.double method calls Calloc. This suggests that this is a symptom of memory corruption. > > I have 2 GB memory on this machine. Should be enough, no? > > > gc() > used (Mb) gc trigger (Mb) max used (Mb) > Ncells 1008175 27.01476915 39.5 1368491 36.6 > Vcells 540055 4.21031040 7.9 1031026 7.9 > > (fm1 <- lmer2(Reaction ~ Days + (Days|Subject), sleepstudy)) > Error in as.double(start) : Calloc could not allocate (903190944 of > 4) memory > > >> On Jan 28, 2007, at 8:35 PM, Michael Kubovy wrote: >> (fm1 <- lmer2(Reaction ~ Days + (Days|Subject), sleepstudy)) >>> Error in as.double(start) : Calloc could not allocate (888475968 of >>> 4) memory >>> * sessionInfo() >>> R version 2.4.1 (2006-12-18) >>> powerpc-apple-darwin8.8.0 >>> >>> locale: >>> C >>> >>> attached base packages: >>> [1] "grid" "datasets" "stats" "graphics" "grDevices" >>> "utils" "methods" >>> [8] "base" >>> >>> other attached packages: >>> lme4 Matrix xtable latticeExtra lattice >>> gridBase MASS >>> "0.9975-11" "0.9975-8" "1.4-3" "0.1-4""0.14-16" >>> "0.4-3" "7.2-31" >>> JGR iplots JavaGDrJava >>> "1.4-15" "1.0-5" "0.3-5" "0.4-13" >>> * >>> lmer runs the example w/o a problem >>> >>> I just tried to run it on on Intel-based MacPro, and lmer2 ran >>> without a hitch. > _ > Professor Michael Kubovy > University of Virginia > Department of Psychology > USPS: P.O.Box 400400Charlottesville, VA 22904-4400 > Parcels:Room 102Gilmer Hall > McCormick RoadCharlottesville, VA 22903 > Office:B011+1-434-982-4729 > Lab:B019+1-434-982-4751 > Fax:+1-434-982-4766 > WWW:http://www.people.virginia.edu/~mk9y/ > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/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, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Loop with string variable AND customizable "summary" output
In thinking about this a bit more here is an even shorter one yet it does show the level in the Call output. See ?bquote lapply(levels(CO2$Treatment), function(lev) eval(bquote(lm(uptake ~ conc, CO2, subset = Treatment == .(lev) On 1/29/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > Often you will find that if you arrange your data in a > desirable way in the first place everything becomes > easier. What you really want is a data frame such > as the last three columns of the builtin data frame > CO2 where Treatment corresponds to country and > the two numeric variables correspond to your y and x. > > Then its easy: > > lapply(levels(CO2$Treatment), function(lev) > lm(uptake ~ conc, CO2, subset = Treatment == lev)) > > The only problem with the above is that the Call: in the > output does not really tell you which level of Treatment > is being used since it literally shows > "lm(uptake ~ conc, CO2, subset = Treatment == lev)" > each time. To get around substitute the value of lev in. > Because R uses delayed evaluation you also need to force the > evaluation of lev prior to substituting it in: > > lapply(levels(CO2$Treatment), function(lev) { > lev <- force(lev) > eval(substitute(lm(uptake ~ conc, CO2, subset = Treatment == lev)), > list(lev = lev)) > }) > > > Now if you really want to do it the way you specified originally > try this. > > Suppose we use attach to grab the variables > x1, x2, x3, x4, y1, y2, y3, y4 out of the builtin > anscombe data frame for purposes of getting > our hands on some sample data. In your case > the variables would already be in the workspace > so the attach is not needed. > > Then simply reconstruct the formula in fo. You > could simply use lm(fo) but then the Call: in the > output of lm would literally read lm(fo) so its > better to use do.call: > > # next line gives the variables x1, x2, x3, x4, y1, y2, y3, y4 > # from the builtin ancombe data set. > # In your case such variables would already exist. > attach(anscombe) > lapply(1:4, function(i) { > ynm <- paste("y", i, sep = "") > xnm <- paste("x", i, sep = "") > fo <- as.formula(paste(ynm, "~", xnm)) > do.call("lm", list(fo)) > }) > detach(anscombe) > > Or if all the variables have the same length you could use > a form such as ancombe in the first place: > > Actually this is not really a recommended way of > proceeding. You would be better off putting all > your variables in a data frame and using that. > > lapply(1:4, function(i) { >fo <- as.formula(paste(names(anscombe)[i+4], "~", names(anscombe)[i])) >do.call("lm", list(fo, data = quote(anscombe))) > }) > > or > > lapply(1:4, function(i) { >fo <- y ~ x >fo[[2]] <- as.name(names(anscombe)[i+4]) >fo[[3]] <- as.name(names(anscombe)[i]) >do.call("lm", list(fo, data = quote(anscombe))) > }) > > > > On 1/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Dear All, > > > > I am using R for my research and I have two questions about it: > > > > 1) is it possible to create a loop using a string, instead of a numeric > > vector? I have in mind a specific problem: > > > > Suppose you have 2 countries: UK, and USA, one dependent (y) and one > > independent variable (y) for each country (vale a dire: yUK, xUK, yUSA, > > xUSA) and you want to run automatically the following regressions: > > > > > > > > for (i in c("UK","USA")) > > > > output{i}<-summary(lm(y{i} ~ x{i})) > > > > > > > > In other words, at the end I would like to have two objects as output: > > "outputUK" and "outputUSA", which contain respectively the results of the > > first and second regression (yUK on xUK and yUSA on xUSA). > > > > > > > > 2) in STATA there is a very nice code ("outreg") to display nicely (and as > > the user wants to) your regression results. > > > > Is there anything similar in R / R contributed packages? More precisely, I > > am thinking of something that is close in spirit to "summary" but it is > > also customizable. For example, suppose you want different Signif. codes: > > 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 or a different format > > display (i.e. without "t value" column) implemented automatically (without > > manually editing it every time). > > > > In alternative, if I was able to see it, I could modify the source code of > > the function "summary", but I am not able to see its (line by line) code. > > Any idea? > > > > Or may be a customizable regression output already exists? > > > > Thanks really a lot! > > > > Carlo > > > > __ > > R-help@stat.math.ethz.ch mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-pr
Re: [R] Loop with string variable AND customizable "summary" output
Often you will find that if you arrange your data in a desirable way in the first place everything becomes easier. What you really want is a data frame such as the last three columns of the builtin data frame CO2 where Treatment corresponds to country and the two numeric variables correspond to your y and x. Then its easy: lapply(levels(CO2$Treatment), function(lev) lm(uptake ~ conc, CO2, subset = Treatment == lev)) The only problem with the above is that the Call: in the output does not really tell you which level of Treatment is being used since it literally shows "lm(uptake ~ conc, CO2, subset = Treatment == lev)" each time. To get around substitute the value of lev in. Because R uses delayed evaluation you also need to force the evaluation of lev prior to substituting it in: lapply(levels(CO2$Treatment), function(lev) { lev <- force(lev) eval(substitute(lm(uptake ~ conc, CO2, subset = Treatment == lev)), list(lev = lev)) }) Now if you really want to do it the way you specified originally try this. Suppose we use attach to grab the variables x1, x2, x3, x4, y1, y2, y3, y4 out of the builtin anscombe data frame for purposes of getting our hands on some sample data. In your case the variables would already be in the workspace so the attach is not needed. Then simply reconstruct the formula in fo. You could simply use lm(fo) but then the Call: in the output of lm would literally read lm(fo) so its better to use do.call: # next line gives the variables x1, x2, x3, x4, y1, y2, y3, y4 # from the builtin ancombe data set. # In your case such variables would already exist. attach(anscombe) lapply(1:4, function(i) { ynm <- paste("y", i, sep = "") xnm <- paste("x", i, sep = "") fo <- as.formula(paste(ynm, "~", xnm)) do.call("lm", list(fo)) }) detach(anscombe) Or if all the variables have the same length you could use a form such as ancombe in the first place: Actually this is not really a recommended way of proceeding. You would be better off putting all your variables in a data frame and using that. lapply(1:4, function(i) { fo <- as.formula(paste(names(anscombe)[i+4], "~", names(anscombe)[i])) do.call("lm", list(fo, data = quote(anscombe))) }) or lapply(1:4, function(i) { fo <- y ~ x fo[[2]] <- as.name(names(anscombe)[i+4]) fo[[3]] <- as.name(names(anscombe)[i]) do.call("lm", list(fo, data = quote(anscombe))) }) On 1/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Dear All, > > I am using R for my research and I have two questions about it: > > 1) is it possible to create a loop using a string, instead of a numeric > vector? I have in mind a specific problem: > > Suppose you have 2 countries: UK, and USA, one dependent (y) and one > independent variable (y) for each country (vale a dire: yUK, xUK, yUSA, xUSA) > and you want to run automatically the following regressions: > > > > for (i in c("UK","USA")) > > output{i}<-summary(lm(y{i} ~ x{i})) > > > > In other words, at the end I would like to have two objects as output: > "outputUK" and "outputUSA", which contain respectively the results of the > first and second regression (yUK on xUK and yUSA on xUSA). > > > > 2) in STATA there is a very nice code ("outreg") to display nicely (and as > the user wants to) your regression results. > > Is there anything similar in R / R contributed packages? More precisely, I am > thinking of something that is close in spirit to "summary" but it is also > customizable. For example, suppose you want different Signif. codes: 0 '***' > 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 or a different format display (i.e. > without "t value" column) implemented automatically (without manually editing > it every time). > > In alternative, if I was able to see it, I could modify the source code of > the function "summary", but I am not able to see its (line by line) code. Any > idea? > > Or may be a customizable regression output already exists? > > Thanks really a lot! > > Carlo > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [R-SIG-Mac] lmer2 error under Mac OS X on PowerPC G5 but not on Dual-Core Intel Xeon
I'm not sure - what is the question here? It works for me on a both PowerPC G5 and Mac Pro (R 2.4.1 CRAN binary): > fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) > fm1 Linear mixed-effects model fit by REML Formula: Reaction ~ Days + (Days | Subject) Data: sleepstudy AIC BIC logLik MLdeviance REMLdeviance 1754 1770 -871.8 1752 1744 Random effects: Groups NameVariance Std.Dev. Corr Subject (Intercept) 610.835 24.7151 Days 35.056 5.9208 0.067 Residual 655.066 25.5943 number of obs: 180, groups: Subject, 18 Fixed effects: Estimate Std. Error t value (Intercept) 251.405 6.820 36.86 Days 10.467 1.5466.77 Correlation of Fixed Effects: (Intr) Days -0.137 > gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 966960 25.91368491 36.6 1265230 33.8 Vcells 523595 4.01031040 7.9 755843 5.8 > sessionInfo() R version 2.4.1 (2006-12-18) i386-apple-darwin8.8.1 locale: C attached base packages: [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" [7] "base" other attached packages: lme4 Matrix lattice "0.9975-11" "0.9975-8" "0.14-16" Cheers, Simon On Jan 29, 2007, at 10:40 AM, Benilton Carvalho wrote: > So, I decided to give it a try (and just now noticed that this is the > example in lmer2) > > I just gave it a try on a PPC G4 and it worked as expected. I'm > copying R-sig-mac (sorry for the crosspost) as the experts there > might give you a better suggestion. > >> fm1 <- lmer2(Reaction ~ Days + (Days|Subject), sleepstudy) >> fm1 > Linear mixed-effects model fit by REML > Formula: Reaction ~ Days + (Days | Subject) > Data: sleepstudy >AIC BIC logLik MLdeviance REMLdeviance > 1754 1770 -871.8 1752 1744 > Random effects: > Groups NameVariance Std.Dev. Corr > Subject (Intercept) 612.128 24.7412 >Days 35.049 5.9202 0.066 > Residual 654.970 25.5924 > Number of obs: 180, groups: Subject, 18 > > Fixed effects: > Estimate Std. Error t value > (Intercept) 251.405 6.825 36.84 > Days 10.467 1.5456.77 > > Correlation of Fixed Effects: > (Intr) > Days -0.137 >> sessionInfo() > R version 2.5.0 Under development (unstable) (2007-01-03 r40349) > powerpc-apple-darwin8.8.0 > > locale: > C > > attached base packages: > [1] "stats" "graphics" "grDevices" "utils" "datasets" > "methods" > [7] "base" > > other attached packages: > lme4 Matrix lattice > "0.9975-11" "0.9975-8" "0.14-16" > > > On Jan 29, 2007, at 7:40 AM, Michael Kubovy wrote: > >> On Jan 28, 2007, at 9:39 PM, Benilton Carvalho wrote: >> >>> This seems to be due to the fact that you didn't have enough >>> memory when running lmer2. >>> >>> I might be wrong, but I think Calloc tries to get contiguous >>> memory, so this might the problem. >>> >>> If you are positive that you have enough memory, a gc() might help. >> >> I have 2 GB memory on this machine. Should be enough, no? >> >>> gc() >> used (Mb) gc trigger (Mb) max used (Mb) >> Ncells 1008175 27.01476915 39.5 1368491 36.6 >> Vcells 540055 4.21031040 7.9 1031026 7.9 >>> (fm1 <- lmer2(Reaction ~ Days + (Days|Subject), sleepstudy)) >> Error in as.double(start) : Calloc could not allocate (903190944 of >> 4) memory >> >> >>> On Jan 28, 2007, at 8:35 PM, Michael Kubovy wrote: >>> > (fm1 <- lmer2(Reaction ~ Days + (Days|Subject), sleepstudy)) Error in as.double(start) : Calloc could not allocate (888475968 of 4) memory * > sessionInfo() R version 2.4.1 (2006-12-18) powerpc-apple-darwin8.8.0 locale: C attached base packages: [1] "grid" "datasets" "stats" "graphics" "grDevices" "utils" "methods" [8] "base" other attached packages: lme4 Matrix xtable latticeExtra lattice gridBase MASS "0.9975-11" "0.9975-8" "1.4-3" "0.1-4""0.14-16" "0.4-3" "7.2-31" JGR iplots JavaGDrJava "1.4-15" "1.0-5" "0.3-5" "0.4-13" * lmer runs the example w/o a problem I just tried to run it on on Intel-based MacPro, and lmer2 ran without a hitch. >> _ >> Professor Michael Kubovy >> University of Virginia >> Department of Psychology >> USPS: P.O.Box 400400Charlottesville, VA 22904-4400 >> Parcels:Room 102Gilmer Hall >> McCormick RoadCharlottesville, VA 22903 >> Office:B011+1-434-982-4729 >> Lab:B019+1-434-982-4751 >> Fax:+1-434-982-4766 >> WWW:http://www.people.virginia.edu/~mk9y/ >> > > ___ > R-SIG-Mac mailing list > R-SIG-Mac@stat.math.ethz.ch > https://stat.eth
[R] Fwd: Re: LSD multiple comparison test
I am returning this to the R-help list. Please keep followups on the list. Yes, it can be done. It is not currently easy because multcomp doesn't have the syntax yet. Making this easy is on Torsten's to-do list for the multcomp package. See the MMC.WoodEnergy example in the HH package. The current version on CRAN is HH_1.17. Please see the discussion of this example in R-help: https://stat.ethz.ch/pipermail/r-help/2007-January/123451.html Original message >Date: Mon, 29 Jan 2007 16:42:35 +0100 (CET) >From: "Jorge Lampurlanes Castel" <[EMAIL PROTECTED]> >Subject: Re: [R] LSD multiple comparison test >To: "Richard M. Heiberger" <[EMAIL PROTECTED]> > >Thank you very much for your useful advice. >I do not found LSD but I am using Tukey test instead. > >In the model: > > lm.1 <- lm(variable ~ BLOC + TIL * YEAR , data=selvanera) > > >I found TIL*YEAR interaction significant. Then I am trying to compare >means of the different levels of TIL inside every YEAR using: > > mc.2 <- glht(lm.1, linfct = mcp(TIL*YEAR="Tukey")) > summary(mc.2, test = univariate()) > >but it does not work. > >There is any way of doing it, like the SLICE option in PROC GLM (SAS)? > >Thanks a lot, > >Jorge > >> Look at the glht function in the multcomp package and the >> MMC functions in the HH package. >> >> Rich >> > > >-- >** >Jorge Lampurlanés Castel >Departament d'Enginyeria Agroforestal >Escola Tècnica Superior d'Enginyeria Agrària >Universitat de Lleida >Avinguda Rovira Roure, 191 >25198-LLEIDA >SPAIN > >Tl.: +34 973 70 25 37 >Fax.:+34 073 70 26 73 >e-mail: [EMAIL PROTECTED] >** > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Loop with string variable AND customizable "summary" output
Dear All, Thank you very much for your help! Carlo -Original Message- From: Wensui Liu [mailto:[EMAIL PROTECTED] Sent: Mon 29/01/2007 15:39 To: Rosa,C Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Loop with string variable AND customizable "summary" output Carlo, try something like: for (i in c("UK","USA")) { summ<-summary(lm(y ~ x), subset = (country = i)) assign(paste('output', i, sep = ''), summ); } (note: it is untested, sorry). On 1/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Dear All, > > I am using R for my research and I have two questions about it: > > 1) is it possible to create a loop using a string, instead of a numeric > vector? I have in mind a specific problem: > > Suppose you have 2 countries: UK, and USA, one dependent (y) and one > independent variable (y) for each country (vale a dire: yUK, xUK, yUSA, xUSA) > and you want to run automatically the following regressions: > > > > for (i in c("UK","USA")) > > output{i}<-summary(lm(y{i} ~ x{i})) > > > > In other words, at the end I would like to have two objects as output: > "outputUK" and "outputUSA", which contain respectively the results of the > first and second regression (yUK on xUK and yUSA on xUSA). > > > > 2) in STATA there is a very nice code ("outreg") to display nicely (and as > the user wants to) your regression results. > > Is there anything similar in R / R contributed packages? More precisely, I am > thinking of something that is close in spirit to "summary" but it is also > customizable. For example, suppose you want different Signif. codes: 0 '***' > 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 or a different format display (i.e. > without "t value" column) implemented automatically (without manually editing > it every time). > > In alternative, if I was able to see it, I could modify the source code of > the function "summary", but I am not able to see its (line by line) code. Any > idea? > > Or may be a customizable regression output already exists? > > Thanks really a lot! > > Carlo > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- WenSui Liu A lousy statistician who happens to know a little programming (http://spaces.msn.com/statcompute/blog) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] sorry, I forgot the tilde
Vladimir Eremeev wrote: > > That is > > C.Rosa wrote: >> >> for (i in c("UK","USA")) >> output{i}<-summary(lm(y{i} ~ x{i})) >> > > for (i in c("UK","USA")) { > lm.txt<-paste("output",i,"<-","lm(","y",i,"~","x",i,")",sep="") # 1. > produce a character string containing needed expression > eval(parse(text=lm.txt)) > # 2. parse and evaluate it > } > -- View this message in context: http://www.nabble.com/-R--Loop-with-string-variable-AND-customizable-%22summary%22-output-tf3136358.html#a8692073 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Loop with string variable AND customizable "summary" output
That is C.Rosa wrote: > > for (i in c("UK","USA")) > output{i}<-summary(lm(y{i} ~ x{i})) > for (i in c("UK","USA")) { lm.txt<-paste("output",i,"<-","lm(","y",i,"x",i,")",sep="") # 1. produce a character string containing needed expression eval(parse(text=lm.txt)) # 2. parse and evaluate it } -- View this message in context: http://www.nabble.com/-R--Loop-with-string-variable-AND-customizable-%22summary%22-output-tf3136358.html#a8692041 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Loop with string variable AND customizable "summary" output
C.Rosa wrote: > > Dear All, > > I am using R for my research and I have two questions about it: > > 1) is it possible to create a loop using a string, instead of a numeric > vector? I have in mind a specific problem: > > for (i in c("UK","USA")) > > output{i}<-summary(lm(y{i} ~ x{i})) > > In other words, at the end I would like to have two objects as output: > "outputUK" and "outputUSA", which contain respectively the results of the > first and second regression (yUK on xUK and yUSA on xUSA). > Consider R functions bquote, substitute, eval and parse. Several examples are given somewhere in RNews (http://cran.r-project.org/doc/Rnews/) Unfortunately I don't remember exactly which issue, one of list members sent me a link to the article several years ago, when I was studying similar question. C.Rosa wrote: > > 2) I am thinking of something that is close in spirit to "summary" but it > is also customizable. For example, suppose you want different Signif. > codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 or a different > format display (i.e. without "t value" column) implemented automatically > (without manually editing it every time). > > In alternative, if I was able to see it, I could modify the source code of > the function "summary", but I am not able to see its (line by line) code. > Any idea? > Stars and significance codes are printed with the symnum function. To customize the summary, explore the result returned by the lm. For example, str(outputUK) you will see, it is a list. Then you will be able to reference its elements with $ (say, outputUK$coeff) R is an object oriented language, and calls of the same function on different objects usually invoke different functions (if a class has a description of proper method). The R manuals contain very good description of this mechanism. Function methods gives you a list of all defined methods For example > methods(summary) > methods(print) If you are working with the lm results, you need to explore the function print.summary.lm > summary(outputUK) invokes summary.lm function, as outputUK is the object of class "lm". This function produces the object of class "summary.lm" Then this object is printed with the method print.summary.lm -- View this message in context: http://www.nabble.com/-R--Loop-with-string-variable-AND-customizable-%22summary%22-output-tf3136358.html#a8691620 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Loop with string variable AND customizable "summary" output
Carlo, try something like: for (i in c("UK","USA")) { summ<-summary(lm(y ~ x), subset = (country = i)) assign(paste('output', i, sep = ''), summ); } (note: it is untested, sorry). On 1/29/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Dear All, > > I am using R for my research and I have two questions about it: > > 1) is it possible to create a loop using a string, instead of a numeric > vector? I have in mind a specific problem: > > Suppose you have 2 countries: UK, and USA, one dependent (y) and one > independent variable (y) for each country (vale a dire: yUK, xUK, yUSA, xUSA) > and you want to run automatically the following regressions: > > > > for (i in c("UK","USA")) > > output{i}<-summary(lm(y{i} ~ x{i})) > > > > In other words, at the end I would like to have two objects as output: > "outputUK" and "outputUSA", which contain respectively the results of the > first and second regression (yUK on xUK and yUSA on xUSA). > > > > 2) in STATA there is a very nice code ("outreg") to display nicely (and as > the user wants to) your regression results. > > Is there anything similar in R / R contributed packages? More precisely, I am > thinking of something that is close in spirit to "summary" but it is also > customizable. For example, suppose you want different Signif. codes: 0 '***' > 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 or a different format display (i.e. > without "t value" column) implemented automatically (without manually editing > it every time). > > In alternative, if I was able to see it, I could modify the source code of > the function "summary", but I am not able to see its (line by line) code. Any > idea? > > Or may be a customizable regression output already exists? > > Thanks really a lot! > > Carlo > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- WenSui Liu A lousy statistician who happens to know a little programming (http://spaces.msn.com/statcompute/blog) __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] lmer2 error under Mac OS X on PowerPC G5 but not on Dual-Core Intel Xeon
So, I decided to give it a try (and just now noticed that this is the example in lmer2) I just gave it a try on a PPC G4 and it worked as expected. I'm copying R-sig-mac (sorry for the crosspost) as the experts there might give you a better suggestion. > fm1 <- lmer2(Reaction ~ Days + (Days|Subject), sleepstudy) > fm1 Linear mixed-effects model fit by REML Formula: Reaction ~ Days + (Days | Subject) Data: sleepstudy AIC BIC logLik MLdeviance REMLdeviance 1754 1770 -871.8 1752 1744 Random effects: Groups NameVariance Std.Dev. Corr Subject (Intercept) 612.128 24.7412 Days 35.049 5.9202 0.066 Residual 654.970 25.5924 Number of obs: 180, groups: Subject, 18 Fixed effects: Estimate Std. Error t value (Intercept) 251.405 6.825 36.84 Days 10.467 1.5456.77 Correlation of Fixed Effects: (Intr) Days -0.137 > sessionInfo() R version 2.5.0 Under development (unstable) (2007-01-03 r40349) powerpc-apple-darwin8.8.0 locale: C attached base packages: [1] "stats" "graphics" "grDevices" "utils" "datasets" "methods" [7] "base" other attached packages: lme4 Matrix lattice "0.9975-11" "0.9975-8" "0.14-16" On Jan 29, 2007, at 7:40 AM, Michael Kubovy wrote: > On Jan 28, 2007, at 9:39 PM, Benilton Carvalho wrote: > >> This seems to be due to the fact that you didn't have enough >> memory when running lmer2. >> >> I might be wrong, but I think Calloc tries to get contiguous >> memory, so this might the problem. >> >> If you are positive that you have enough memory, a gc() might help. > > I have 2 GB memory on this machine. Should be enough, no? > > > gc() > used (Mb) gc trigger (Mb) max used (Mb) > Ncells 1008175 27.01476915 39.5 1368491 36.6 > Vcells 540055 4.21031040 7.9 1031026 7.9 > > (fm1 <- lmer2(Reaction ~ Days + (Days|Subject), sleepstudy)) > Error in as.double(start) : Calloc could not allocate (903190944 of > 4) memory > > >> On Jan 28, 2007, at 8:35 PM, Michael Kubovy wrote: >> (fm1 <- lmer2(Reaction ~ Days + (Days|Subject), sleepstudy)) >>> Error in as.double(start) : Calloc could not allocate (888475968 of >>> 4) memory >>> * sessionInfo() >>> R version 2.4.1 (2006-12-18) >>> powerpc-apple-darwin8.8.0 >>> >>> locale: >>> C >>> >>> attached base packages: >>> [1] "grid" "datasets" "stats" "graphics" "grDevices" >>> "utils" "methods" >>> [8] "base" >>> >>> other attached packages: >>> lme4 Matrix xtable latticeExtra lattice >>> gridBase MASS >>> "0.9975-11" "0.9975-8" "1.4-3" "0.1-4""0.14-16" >>> "0.4-3" "7.2-31" >>> JGR iplots JavaGDrJava >>> "1.4-15" "1.0-5" "0.3-5" "0.4-13" >>> * >>> lmer runs the example w/o a problem >>> >>> I just tried to run it on on Intel-based MacPro, and lmer2 ran >>> without a hitch. > _ > Professor Michael Kubovy > University of Virginia > Department of Psychology > USPS: P.O.Box 400400Charlottesville, VA 22904-4400 > Parcels:Room 102Gilmer Hall > McCormick RoadCharlottesville, VA 22903 > Office:B011+1-434-982-4729 > Lab:B019+1-434-982-4751 > Fax:+1-434-982-4766 > WWW:http://www.people.virginia.edu/~mk9y/ > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Loop with string variable AND customizable "summary" output
On Mon, 29 Jan 2007 [EMAIL PROTECTED] wrote: > Dear All, > > I am using R for my research and I have two questions about it: > > 1) is it possible to create a loop using a string, instead of a numeric > vector? I have in mind a specific problem: > > Suppose you have 2 countries: UK, and USA, one dependent (y) and one > independent variable (y) for each country (vale a dire: yUK, xUK, yUSA, > xUSA) and you want to run automatically the following regressions: > > > > for (i in c("UK","USA")) > > output{i}<-summary(lm(y{i} ~ x{i})) > > > > In other words, at the end I would like to have two objects as output: > "outputUK" and "outputUSA", which contain respectively the results of > the first and second regression (yUK on xUK and yUSA on xUSA). > The input data could be reshaped as y, x, country, and subset= used in the lm() call. To assign to named objects see assign(), but consider using a named list instead, assigning to a list of the required length in turn, and giving the names from the defining vector. Then you'd get output$UK, etc. > > > 2) in STATA there is a very nice code ("outreg") to display nicely (and > as the user wants to) your regression results. > > Is there anything similar in R / R contributed packages? More precisely, > I am thinking of something that is close in spirit to "summary" but it > is also customizable. For example, suppose you want different Signif. > codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 or a different > format display (i.e. without "t value" column) implemented automatically > (without manually editing it every time). > > In alternative, if I was able to see it, I could modify the source code > of the function "summary", but I am not able to see its (line by line) > code. Any idea? Use a custom function on the output object from using the summary() method on the lm object (that is on the summary.lm object). Use str() to look at the summary.lm object to see what you want. > > Or may be a customizable regression output already exists? > > Thanks really a lot! > > Carlo > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Bayesian States Space Modeling
Hi R, What package of R can I use for Bayesian States Space Modeling? And any other supporting packages? Thanks in advance, Shubha [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Loop with string variable AND customizable "summary" output
Dear All, I am using R for my research and I have two questions about it: 1) is it possible to create a loop using a string, instead of a numeric vector? I have in mind a specific problem: Suppose you have 2 countries: UK, and USA, one dependent (y) and one independent variable (y) for each country (vale a dire: yUK, xUK, yUSA, xUSA) and you want to run automatically the following regressions: for (i in c("UK","USA")) output{i}<-summary(lm(y{i} ~ x{i})) In other words, at the end I would like to have two objects as output: "outputUK" and "outputUSA", which contain respectively the results of the first and second regression (yUK on xUK and yUSA on xUSA). 2) in STATA there is a very nice code ("outreg") to display nicely (and as the user wants to) your regression results. Is there anything similar in R / R contributed packages? More precisely, I am thinking of something that is close in spirit to "summary" but it is also customizable. For example, suppose you want different Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 or a different format display (i.e. without "t value" column) implemented automatically (without manually editing it every time). In alternative, if I was able to see it, I could modify the source code of the function "summary", but I am not able to see its (line by line) code. Any idea? Or may be a customizable regression output already exists? Thanks really a lot! Carlo __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to explore contents of R data file from command line?
On Mon, 29 Jan 2007, Vladimir Eremeev wrote: > Thank you, I have used this way already. > I would like to avoid copying files, as I have asked before. attach("inflow.RData") ls(2) ... detach(2) > > I have found one more solution in Windows. > > Just typing inflow.RData (the file name) in command line and pressing enter > runs Rgui, and it loads the file. > Then ls() and str() will give the insight of the file contents. > When exiting from R, one needs to say "No" to the R's question about saving > workspace image, as answering "Yes" deletes older .RData (default workspace > image). > > > Henrique Dallazuanna wrote: >> >> You can try copy the file into another location and in the R: >> >> load(file.choose()) >> ls() >> >> choose the file .RData >> >> On 29/01/07, Vladimir Eremeev <[EMAIL PROTECTED]> wrote: >>> Dear all, >>> >>> I have a directory with my research project, containing files >>> .RData >>> and >>> inflow.RData >>> >>> I am just curious, is there any way to explore contents of >>> inflow.RDatafrom >>> command line without affecting .RData and >>> without copying inflow.RData to >>> another location? >>> I can see names and character attributes (of something in the file) in a >>> 3rd >>> party raw file viewer. >> Henrique Dallazuanna >> > > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in merging
Please read the last line of every message to r-help. On 1/29/07, Shubha Vishwanath Karanth <[EMAIL PROTECTED]> wrote: > Hi R, > > > > The error I get if I try to merge the zoo objects, intra1, intra2, and > intra3 are as follows: > > > > > z=merge(intra1,intra2,intra3) > > Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array > extent > > > > Does this error mean that when merged, two columns have the same column > name and so we get this error and hence not able to merge? Need a > concurrence... > > > > Thanks in advance... > > Shubha > > >[[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to explore contents of R data file from command line?
Thank you, I have used this way already. I would like to avoid copying files, as I have asked before. I have found one more solution in Windows. Just typing inflow.RData (the file name) in command line and pressing enter runs Rgui, and it loads the file. Then ls() and str() will give the insight of the file contents. When exiting from R, one needs to say "No" to the R's question about saving workspace image, as answering "Yes" deletes older .RData (default workspace image). Henrique Dallazuanna wrote: > > You can try copy the file into another location and in the R: > > load(file.choose()) > ls() > > choose the file .RData > > On 29/01/07, Vladimir Eremeev <[EMAIL PROTECTED]> wrote: >> Dear all, >> >> I have a directory with my research project, containing files >> .RData >> and >> inflow.RData >> >> I am just curious, is there any way to explore contents of >> inflow.RDatafrom >> command line without affecting .RData and >> without copying inflow.RData to >> another location? >> I can see names and character attributes (of something in the file) in a >> 3rd >> party raw file viewer. > Henrique Dallazuanna > -- View this message in context: http://www.nabble.com/how-to-explore-contents-of-R-data-file-from-command-line--tf3135483.html#a8688767 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] lmer2 error under Mac OS X on PowerPC G5 but not on Dual-Core Intel Xeon
On Jan 28, 2007, at 9:39 PM, Benilton Carvalho wrote: > This seems to be due to the fact that you didn't have enough memory > when running lmer2. > > I might be wrong, but I think Calloc tries to get contiguous > memory, so this might the problem. > > If you are positive that you have enough memory, a gc() might help. I have 2 GB memory on this machine. Should be enough, no? > gc() used (Mb) gc trigger (Mb) max used (Mb) Ncells 1008175 27.01476915 39.5 1368491 36.6 Vcells 540055 4.21031040 7.9 1031026 7.9 > (fm1 <- lmer2(Reaction ~ Days + (Days|Subject), sleepstudy)) Error in as.double(start) : Calloc could not allocate (903190944 of 4) memory > On Jan 28, 2007, at 8:35 PM, Michael Kubovy wrote: > >>> (fm1 <- lmer2(Reaction ~ Days + (Days|Subject), sleepstudy)) >> Error in as.double(start) : Calloc could not allocate (888475968 of >> 4) memory >> * >>> sessionInfo() >> R version 2.4.1 (2006-12-18) >> powerpc-apple-darwin8.8.0 >> >> locale: >> C >> >> attached base packages: >> [1] "grid" "datasets" "stats" "graphics" "grDevices" >> "utils" "methods" >> [8] "base" >> >> other attached packages: >> lme4 Matrix xtable latticeExtra lattice >> gridBase MASS >> "0.9975-11" "0.9975-8" "1.4-3" "0.1-4""0.14-16" >> "0.4-3" "7.2-31" >> JGR iplots JavaGDrJava >> "1.4-15" "1.0-5" "0.3-5" "0.4-13" >> * >> lmer runs the example w/o a problem >> >> I just tried to run it on on Intel-based MacPro, and lmer2 ran >> without a hitch. _ Professor Michael Kubovy University of Virginia Department of Psychology USPS: P.O.Box 400400Charlottesville, VA 22904-4400 Parcels:Room 102Gilmer Hall McCormick RoadCharlottesville, VA 22903 Office:B011+1-434-982-4729 Lab:B019+1-434-982-4751 Fax:+1-434-982-4766 WWW:http://www.people.virginia.edu/~mk9y/ __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to explore contents of R data file from command line?
You can try copy the file into another location and in the R: load(file.choose()) ls() choose the file .RData On 29/01/07, Vladimir Eremeev <[EMAIL PROTECTED]> wrote: > > > Dear all, > > I have a directory with my research project, containing files > .RData > and > inflow.RData > > I am just curious, is there any way to explore contents of inflow.RDatafrom > command line without affecting .RData and without copying inflow.RData to > another location? > I can see names and character attributes (of something in the file) in a > 3rd > party raw file viewer. > > -- > View this message in context: > http://www.nabble.com/how-to-explore-contents-of-R-data-file-from-command-line--tf3135483.html#a8688071 > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Henrique Dallazuanna [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] how to explore contents of R data file from command line?
Dear all, I have a directory with my research project, containing files .RData and inflow.RData I am just curious, is there any way to explore contents of inflow.RData from command line without affecting .RData and without copying inflow.RData to another location? I can see names and character attributes (of something in the file) in a 3rd party raw file viewer. -- View this message in context: http://www.nabble.com/how-to-explore-contents-of-R-data-file-from-command-line--tf3135483.html#a8688071 Sent from the R help mailing list archive at Nabble.com. __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] replicating the odds ratio from a published study
At 21:13 28/01/2007, Bob Green wrote: >Michael, > >Thanks. Yes, clearly the volume number for the Schanda paper I cited is wrong. > >Where things are a bit perplexing, is that I used the same method as >Peter suggested on two papers by Eronen (referenced below). I can >reproduce in R a similar odds ratio to the first published paper e.g >OR = 9.7 (CI= 7.4-12.6) whereas I obtained quite different results >from the second published paper (Eronen 2) of OR = 10.0 (8.1-12.5). >One reason why I wanted to work out the calculations was so I could >analyse data from studies using the same method, for confirmation. > >Now the additional issue, is that Woodward, who is also the author >of an epidemiological text, says in a review that Eronen used >wrong formula in a 1995 paper and indicates that this comment >applies also to later studies - he stated the "they use methods >designed for use with binomial data when they really have Poisson >data. Consequently, they quote odds ratios when they really have >relative rates and their confidence intervals are >inaccurate". Eronen1 cites the formula that was used for OR. >Schanda sets out his table for odds ratio the same as Eronen1 There do seem to be difficulties in what they are doing as they have not observed all the non-homicides, they estimate how many they are and then estimate the number of people with a given diagnosis using prevalence estimates from another study. I think you are moving towards writing an article criticising the statistical methods used in this whole field which I think is going beyond the resources of R-help. >For the present purpose, my primary question is: as you have now >seen the Schanda paper, would you consider Schanda calculated odds >or relative risk? > >Also, when I tried the formula suggested by Peter (below) I obtained >an error - do you know what M might be or the source of the error? > >exp(log(41*2936210/920/20068)+qnorm(c(.025,.975))*sqrt(sum(1/M))) >Error in sum(1/M) : object "M" not found > > > > eronen1 <- as.table(matrix(c(58,852,13600-58,1947000-13600-852), > ncol = 2 , dimnames = list(group=c("scz", "nonscz"), who= > c("sample", "population" > > fisher.test(eronen1) > > >p-value < 2.2e-16 >alternative hypothesis: true odds ratio is not equal to 1 >95 percent confidence interval: > 7.309717 12.690087 >sample estimates: >odds ratio > 9.713458 > > > eronen2 > <- as.table(matrix(c(86,1302,13530-86,1933000-13530-1302), ncol = > 2 , dimnames = list(group=c("scz", "nonscz"), who= c("sample", > "population" > > fisher.test(eronen2) > >p-value < 2.2e-16 >alternative hypothesis: true odds ratio is not equal to 1 >95 percent confidence interval: > 7.481272 11.734136 >sample estimates: >odds ratio >9.42561 > >References > >Eronen, M. et al. (1996 - 1) Mental disorders and homicidal behavior >in Finland. Archives of General Psychiatry, 53, 497-501 > >Eronen, M et al (1996 - 2). Schizophrenia & homicidal >behavior. Schizophrenia Bulletin, 22, 83-89 > >Woodward, Mental disorder & homicide. Epidemiologia E Psichiatria >Sociale, 9, 171-189 > >Any comments are welcomed, > >Bob > >At 01:57 PM 28/01/2007 +, Michael Dewey wrote: >>At 22:01 26/01/2007, Peter Dalgaard wrote: >>>Bob Green wrote: Peetr & Michael, I now see my description may have confused the issue. I do want to compare odds ratios across studies - in the sense that I want to create a table with the respective odds ratio for each study. I do not need to statistically test two sets of odds ratios. What I want to do is ensure the method I use to compute an odds ratio is accurate and intended to check my method against published sources. The paper I selected by Schanda et al (2004). Homicide and major mental disorders. Acta Psychiatr Scand, 11:98-107 reports a total sample of 1087. Odds ratios are reported separately for men and women. There were 961 men all of whom were convicted of homicide. Of these 961 men, 41 were diagnosed with schizophrenia. The unadjusted odds ratio is for this group of 41 is cited as 6.52 (4.70-9.00). They also report the general population aged over 15 with schizophrenia =20,109 and the total population =2,957,239. >> >>Looking at the paper (which is in volume 110 by the way) suggests >>that Peter's reading of the situation is correct and that is what >>the authors have done. >> Any further clarification is much appreciated, >>>A fisher.test on the following matrix seems about right: >>> > matrix(c(41,920,20109-41,2957239-20109-920),2) >>> >>> [,1][,2] >>>[1,] 41 20068 >>>[2,] 920 2936210 >>> >>> > fisher.test(matrix(c(41,920,20109-41,2957239-20109-920),2)) >>> >>>Fisher's Exact Test for Count Data >>> >>>data: matrix(c(41, 920, 20109 - 41, 2957239 - 20109 - 920), 2) >>>p-value < 2.2e-16 >>>alternative hypothesis: true odds ratio is not equal to 1 >>>95 percent confidence interval: >>
Re: [R] Does R support grid or parallel computing?
Dear Xiaopeng, There is certainly support for, among others, MPI and PVM; check packages Rmpi, rpvm, snow, and papply, in CRAN. Best, R. On 1/29/07, xiaopeng hu <[EMAIL PROTECTED]> wrote: > Does R support grid or parallel computing? > > [[alternative HTML version deleted]] > > __ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > -- Ramon Diaz-Uriarte Statistical Computing Team Structural Biology and Biocomputing Programme Spanish National Cancer Centre (CNIO) http://ligarto.org/rdiaz __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] Does R support grid or parallel computing?
Does R support grid or parallel computing? [[alternative HTML version deleted]] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Adaptive kernel density estimation in a domain of R^2
Hello, Is there exist a R Package (or R Code) of nonparametric density estimation with adaptive methods (k-nearest neighbors,...) for multivariate data ? I have found the package "Locfit" but it is only for the univariate case. Thank you. -- Florent BONNEU LSP Université Paul Sabatier 118 route de Narbonne 31062 TOULOUSE CEDEX 9 Bureau 15 bât 1R1 Tél. 05 61 55 76 69 [EMAIL PROTECTED] __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] can not load my workspace any more
Hello everybody! I've been working now for quite a while with my R envoirment. However, today I tried to load it as usal, but I only get the error message Error in methods:::mlistMetaName(mi, ns) : the methods object name for 'plot' must include the name of the package that contains the generic function, but there is no generic function of this name This happens directly after I start R on the command line and leaves me again with my prompt such that I can not access my envoirment at the moment. I already tried to start off with a clean R envoirment and attach my envoirment with no sucsess. So how can I now access my envoirment??? Greetings, Sebastian Weber __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] CGIwithR and visible output of 'invisible(capture.output(library(...)))'
On 27 January 2007 at 16:19, Dirk Eddelbuettel wrote: | In any event, the bug here is with CGIwithR as it assumes that unzip is the | real thing. That may be true, but isn't guaranteed. Sorry, a correction: R2HTML is the one making the assumption about options("unzip") being "unzip", not CGIwithR. Thanks to Duncan TL for pointing this out in private mail. Dirk -- Hell, there are no rules here - we're trying to accomplish something. -- Thomas A. Edison __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] saving issue
I apologize if this isn't the right forum for this question. I'm a rookie R user trying to save a source file and i keep getting this error: 2007-01-27 18:02:12.195 R[175] *** -[NSBigMutableString writeToFile:options:error:]: selector not recognized [self = 0x68c8c20] 2007-01-27 18:02:12.211 R[175] Exception raised during posting of notification. Ignored. exception: *** -[NSBigMutableString writeToFile:options:error:]: selector not recognized [self = 0x68c8c20] I'm using a mac with osx 10.2. Any help would be greatly appreciated. Thanks, Brendan __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/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] %*% in Matrix objects
> "Jose" == Jose Quesada <[EMAIL PROTECTED]> > on Sat, 27 Jan 2007 23:42:34 +0100 writes: Jose> Hi Martin, Thanks for your detailed answer. Jose> x <- Matrix(1:12, 3,4, sparse = TRUE) >> I hope that you are aware of the fact that it's not >> efficient at all to store a dense matrix (it has *no* 0 >> entry) as a sparse one.. >> >> and your posting is indeed an incentive for the Matrix >> developers to improve that part ... ;-) >> Jose> Yes, the toy example is not sparse but the actual data Jose> is, and very large; I'm aware that coercing a dense Jose> matrix into the Sparse format is not leading to any Jose> saving (on the contrary). I'm talking about a real Jose> application with large sparse matrices; from now on, Jose> I'll post small examples using sparse matrices as well Jose> to avoid confusion. ok. Jose> so I tried Jose> x = matrix(1:12,3,4) Jose> x = as(x, "CsparseMatrix") Jose> xnorms = sqrt(colSums(x^2)) Jose> xnorms = as(xnorms, "CsparseMatrix") Jose> (xnormed = t(x) * (1/xnorms)) Jose> But now, instead of a warning I get Jose> "Error: Matrices must have same dimensions in t(x) * (1/xnorms)" >> yes. And the same happens with traditional matrices -- and well so: >> For arithmetic with matrices (traditional or "Matrices"), >> >> A o B (o in {"+", "*", "^", }) >> - >> >> does require that matrices A and B are ``conformable'', i.e., >> have exact same dimensions. >> >> Only when one of A or B is *not* a matrix, >> then the usual S-language recycling rules are applied, >> and that's what you were using in your first example >> ( * ) above. >> Jose> Right. So this means that the * operator is not Jose> overloaded in Matrix (that is, if I use it, I'll get Jose> my Matrix coherced to matrix. Is that correct? no. The "*" is overloaded (read on) Jose> Does this mean that there is no easy way to do element-by-element Jose> multiplication without leaving the sparse Matrix format? No. There is an easy way: If you multiply (or add or ..) two sparse matrices of matching dim(), the result will be sparse. Also if use a "scalar" (length-1 vector) with a Matrix, the result remains sparse (where appropriate) : > (x <- Matrix(c(0,1,0,0), 3,3)) 3 x 3 sparse Matrix of class "dtCMatrix" [1,] . . . [2,] 1 . . [3,] . 1 . Warning message: data length [4] is not a sub-multiple or multiple of the number of rows [3] in matrix > (2 * x) + t(x) 3 x 3 sparse Matrix of class "dgCMatrix" [1,] . 1 . [2,] 2 . 1 [3,] . 2 . > ((2 * x) + t(x)) * t(x) 3 x 3 sparse Matrix of class "dgCMatrix" [1,] . 1 . [2,] . . 1 [3,] . . . What you tried to do, * , will only result in a sparse matrix in the next version of the Matrix package. Jose> I suspect I'm facing the drop=T as before... >> why?? Jose> Because when I got a row out of a Matrix object, the Jose> resulting vector is not of class Matrix but numeric, Jose> and then ( * ) is applied. Jose> Last, I shouldn't consider myself the most standard Jose> user of the matrix package, since my lineal algebra is Jose> really basic. But in any case, you should know that Jose> your package is being enormously useful for me. Keep Jose> up the good work. And if I can help by posting my very Jose> basic questions, I'm glad to help. Ok, thanks for the flowers :-) Martin __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.