[R] RGL and Windows 7
Hi! For saving 3d plots I make use of the rgl.snapshot command provided within the rgl-Package. So far there was no problem using Windows XP, but under Windows 7 the result is a black image, however in the png-format (see attachment http://r.789695.n4.nabble.com/file/n2844487/Koll_perf.png ). What can I do? (Reinstalling Windows XP is no alternative. :-) ) Thanks, Sven -- View this message in context: http://r.789695.n4.nabble.com/RGL-and-Windows-7-tp2844487p2844487.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] R-Square for Robust Regression Model
May I know how to find the R-squared for robust regression model? Thank you. Hock Ann [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Converting a dataframe column from string to datetime
Hi, I have a dataframe column of the form v-c(Fri Feb 05 20:00:01.43000 2010,Fri Feb 05 20:00:02.274000 2010,Fri Feb 05 20:00:02.274000 2010,Fri Feb 05 20:00:06.34000 2010) I need to convert this to datetime form. I did the following.. lapply(v,function(x){strptime(x, %a %b %d %H:%M:%OS %Y)}) This gives me a list that looks like this... [[1]] [1] 2010-02-05 20:00:01.43 [[2]] [1] 2010-02-05 20:00:02.274 [[3]] [1] 2010-02-05 20:00:02.274 [[4]] [1] 2010-02-05 20:00:06.34 However, when I do an unlist...I gets converted to something like this... sec minhourmday monyearwdayyday isdst sec minhourmday monyearwdayyday isdst sec 1.430 0.000 20.000 5.000 1.000 110.000 5.000 35.000 0.000 2.274 0.000 20.000 5.000 1.000 110.000 5.000 35.000 0.000 2.274 minhourmday monyearwdayyday isdst sec min hourmday monyearwdayyday isdst 0.000 20.000 5.000 1.000 110.000 5.000 35.000 0.000 6.340 0.000 20.000 5.000 1.000 110.000 5.000 I want it to become a dataframe column except for a change in the datatype to datetime...how can I achieve this? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [Help]:How to use loop to achieve this aim?
try:ch -- for(i in 1:22) { chrn - paste(chr,i,sep=) chrn=MEDIPS.readAlignedSeqences(BSgenome=hg19, file=chrn,numrows= ) chrn=MEDIPS.genomeVector(data=chrn, bin_size=50,extend=250) ... ... write.table(frameschrn.frame500.step250, file=frames.chrn.meth.txt, sep=\T, quote=F, col.names=T, row.names=F) } -- View this message in context: http://r.789695.n4.nabble.com/Help-How-to-use-loop-to-achieve-this-aim-tp2819894p2861236.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 2.11.1 crashes
Hello Steve, You'll need to give more information for people to help you. 1) Is this the first time you installed R? Or was it a working R version that suddenly started having this problem? 2) Did you try uninstalling this version, downloading a new version, installing it - and seeing what happens? 3) Do you have an office firewall ? (what type?) In the installation process, you can set the type of help file you get. maybe that would resolve your issue (although I have a feeling you need to reinstall R and it would work - it shouldn't need internet for help). Best, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Thu, Sep 30, 2010 at 4:41 PM, Steve Su s...@maths.uwa.edu.au wrote: Dear R community, I was using R 2.11.1 without internet connection on Windows XP and whenever I type ?mean for example, R would freeze and crash out... Is this something that can be fixed? I would like to use the internel help file if possible... Thanks. ### Assistant Professor Steve Su School of Mathematics and Statistics Faculty of Engineering, Computing and Mathematics M019, 35 Stirling Highway Crawley, 6009, WA, Australia Phone:+6164883369 http://www.uwa.edu.au/people/steve.su CRICOS Provider Code: 00126G [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting a dataframe column from string to datetime
Is it okay with you? Reduce(rbind, lapply(lapply(v,function(x){strptime(x, %a %b %d %H:%M:%OS %Y)}), as.character)) -- View this message in context: http://r.789695.n4.nabble.com/Converting-a-dataframe-column-from-string-to-datetime-tp2853709p2869793.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] barplots with 2 different scales
On 10/01/2010 09:19 AM, Jeremy Claisse wrote: Is there a way to create barplots with pairs of bars plotted on 2 different scales (i.e some bars would be plotted according to the scale on the y-axis on the left and other bars plotted according to a different scale on the right axis)? Hi Jeremy, You can do this with the twoord.plot function in the plotrix package. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting a dataframe column from string to datetime
I think you want to use as.POSIXct to get the date value: v-c(Fri Feb 05 20:00:01.43000 2010,Fri Feb 05 20:00:02.274000 2010,Fri Feb 05 20:00:02.274000 2010,Fri Feb 05 20:00:06.34000 2010) x - as.POSIXct(v, format= %a %b %d %H:%M:%OS %Y) x [1] 2010-02-05 20:00:01 EST 2010-02-05 20:00:02 EST [3] 2010-02-05 20:00:02 EST 2010-02-05 20:00:06 EST str(x) POSIXct[1:4], format: 2010-02-05 20:00:01 2010-02-05 20:00:02 ... On Fri, Oct 1, 2010 at 1:59 AM, raje...@cse.iitm.ac.in raje...@cse.iitm.ac.in wrote: Hi, I have a dataframe column of the form v-c(Fri Feb 05 20:00:01.43000 2010,Fri Feb 05 20:00:02.274000 2010,Fri Feb 05 20:00:02.274000 2010,Fri Feb 05 20:00:06.34000 2010) I need to convert this to datetime form. I did the following.. lapply(v,function(x){strptime(x, %a %b %d %H:%M:%OS %Y)}) This gives me a list that looks like this... [[1]] [1] 2010-02-05 20:00:01.43 [[2]] [1] 2010-02-05 20:00:02.274 [[3]] [1] 2010-02-05 20:00:02.274 [[4]] [1] 2010-02-05 20:00:06.34 However, when I do an unlist...I gets converted to something like this... sec min hour mday mon year wday yday isdst sec min hour mday mon year wday yday isdst sec 1.430 0.000 20.000 5.000 1.000 110.000 5.000 35.000 0.000 2.274 0.000 20.000 5.000 1.000 110.000 5.000 35.000 0.000 2.274 min hour mday mon year wday yday isdst sec min hour mday mon year wday yday isdst 0.000 20.000 5.000 1.000 110.000 5.000 35.000 0.000 6.340 0.000 20.000 5.000 1.000 110.000 5.000 I want it to become a dataframe column except for a change in the datatype to datetime...how can I achieve this? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Inserting a plot into another
On 10/01/2010 01:01 AM, Filoche wrote: Hi everyone. I would like to know if it was possible to insert a plot into another one. For example I have a plot and I would like to add a smaller plot in the top right corner. Hi Phil, Take a look at the subplot function in TeachingDemos. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Issues loading rtiff 1.4.1 with R 2.6.2 on Windows
Dear R-users, I successfully installed rtiff on by R installation, but when I tried to load it, I got: local({pkg - select.list(sort(.packages(all.available = TRUE))) + if(nchar(pkg)) library(pkg, character.only=TRUE)}) Error in dyn.load(file, ...) : unable to load shared library 'C:/PROGRA~1/R/R-26~1.2/library/rtiff/libs/rtiff.dll': LoadLibrary failure: Das angegebene Modul wurde nicht gefunden. When running nm from MinGW on C:\Program Files\R\R-2.6.2\library\rtiff\libs\rtiff.dll, it tells me no symbols :-/ So I tried to compile the dll from the sources and did this: gcc -shared -o rtiff.dll rtiff.c -ltiff -lr -IC:\Program Files\GnuWin32\include -IC:\Program Files\R\R-2.6.2\include -LC:\Program Files\GnuWin32\lib -LC:\MinGW\lib -LC:\Program Files\R\R-2.6.2\modules -LC:\Program Files\R\R-2.6.2\bin This indeed creates a dll witch exports 614 symbols. Also my dll is 29KB, the original one just 9 Kb... However, R still throws the same error... Is the infamous space in the Path to R a problem? Thanks a lot for any hint on this! P. S: It seems that the author had issues with compilation (ages ago): http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg54165.html Cheers, Daniel -- Daniel Oderbolz Paul Scherrer Institut CH-5232 Villigen Laboratory of Atmospheric Chemistry, Gasphase and Aerosol Chemistry Group OFLA/007 Tel: +41 (0)56 310 2449 Fax: 4525 daniel.oderbolz [AT] psi.ch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Irregular time series plot
Hi, I am new to R and trying to plot a time series data with irregular interval. I was wondering how to read a data of the following format and plot it ? Time 00:00:00 00:05:00 00:10:00 00:15:00 00:20:00 00:30:00 01:00:00 01:30:00 02:00:00 Value 3.15.67 17.21 36.98 73.14 61.58 13.65 6.49 6.27 Your help will be greatly appreciated. Thanks, Vasanth [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Interpreting the example given by Frank Harrell in the predict.lrm {Design} help
Dear list, I am relatively new to ordinal models and have been working through the example given by Frank Harrell in the predict.lrm {Design} help All of this makes sense to me, except for the responses, i,e how do i interpret them? i would be extremely grateful if someone could explain the results? First i establish the date and model - y - factor(sample(1:3, 400, TRUE), 1:3, c('good','better','best')) x1 - runif(400) x2 - runif(400) f - lrm(y ~ rcs(x1,4)*x2, x=TRUE) Get 0.95 confidence limits for Prob[better or best # How do i interpret this on the y scale i.e good,better,best? L - predict(f, se.fit=TRUE) #omitted kint= so use 1st intercept plogis(with(L, linear.predictors + 1.96*cbind(-se.fit,se.fit))) se.fit 1 0.6430994 0.8305201 2 0.5812662 0.7919122 3 0.5692593 0.7976906 4 0.5600308 0.7278637 5 0.6845250 0.8819143 6 0.5518848 0.7228657 7 0.5876031 0.7717215 8 0.6291766 0.8354423 9 0.5839353 0.8333790 10 0.5631326 0.8314051 Get Prob(better) than all others - # Does this mean that for data point 1, y= best as it has the higher probability? predict(f, type=fitted.ind)[1:10,] y=good y=bettery=best 1 0.2517915 0.3469692 0.4012392 2 0.3031733 0.3554471 0.3413796 3 0.3046236 0.3555365 0.3398398 4 0.3514780 0.3546880 0.2938340 5 0.1989827 0.3251784 0.4758390 6 0.3581265 0.3540297 0.2878438 7 0.3130150 0.3559091 0.3310759 8 0.2541324 0.3476007 0.3982669 9 0.2740127 0.3519713 0.3740160 10 0.2839907 0.3535331 0.3624763 Establish data frame to use as newdata d - data.frame(x1=c(.1,.5),x2=c(.5,.15)) Predict newdata - Prob(Y=j) for new observation predict(f, d, type=fitted) # Does this mean that for data point 1, y= better as it has the higher probability? y=better y=best 1 0.6800290 0.3239935 2 0.5846743 0.2409657 # Prob(Y=j) # Again - Does this mean that for data point 1, y= better as it has the higher probability? predict(f, d, type=fitted.ind) y=good y=bettery=best 1 0.3199710 0.3560355 0.3239935 2 0.4153257 0.3437086 0.2409657 predict mean(y) using codes 1,2,3 # How do i interpret this on the y scale i.e good,better,best? predict(f, d, type='mean', codes=TRUE) 12 2.004022 1.825640 Thanks for any advice it is greatly appreciated John [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Irregular time series plot
Hi List, I am some what new to R-world. I am trying to plot some vector data, each vector has a direction and magnitude, the data is taken from an array of points, some of the coverage area overlap, some do not. Due nature of the grid there are some points that lack data. Can any body recommend an r-package to produce an image of the entire grid, such that its possible to say the value at this point (x,y) is direction A and magnitude B. I can understand how to apply methods to scalar data, but its the vector aspect of the data that is proving awkard. Thanks in advance for any suggestions __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Format of Output of Residuals
Hi: CW.lm - lm(weight ~ Diet, ChickWeight) resid.CW.lm - resid(CW.lm) as.data.frame(resid(CW.lm))[1:10, ] # (nope) [1] -60.645455 -51.645455 -43.645455 -38.645455 -26.645455 -9.645455 [7] 3.354545 22.354545 46.354545 68.354545 # convert residuals to one column matrix, then convert to data frame: as.data.frame(matrix(resid(CW.lm), ncol = 1)) V1 1-60.6454545 2-51.6454545 3-43.6454545 4-38.6454545 5-26.6454545 ... HTH, Dennis On Thu, Sep 30, 2010 at 9:09 PM, Michael Just mgj...@gmail.com wrote: An excerpt from dataset ChickWeight: weight Time Chick Diet 1 420 11 2 512 11 3 594 11 I am interested in the residuals of the dataset. Specifically in saving them to another format. I have been creating text files with sink. CW.lm - lm(weight ~ Diet, ChickWeight) resid.CW.lm - resid(CW.lm) But when I call: resid.CW.lm The data appears like this (excerpt) : 12345 6 -60.6454545 -51.6454545 -43.6454545 -38.6454545 -26.6454545 -9.6454545 How can I get the data to be formatted like below in an output / sink friendly way? 1 -60.6454545 2 -51.6454545 3 -43.6454545 4 -38.6454545 5 -26.6454545 6 -9.6454545 Thank you kindly, Cheers, Mike __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Irregular time series plot
Sorry about this, I used your item as prototype to get the email address. Dave. Hi List, I am some what new to R-world. I am trying to plot some vector data, each vector has a direction and magnitude, the data is taken from an array of points, some of the coverage area overlap, some do not. Due nature of the grid there are some points that lack data. Can any body recommend an r-package to produce an image of the entire grid, such that its possible to say the value at this point (x,y) is direction A and magnitude B. I can understand how to apply methods to scalar data, but its the vector aspect of the data that is proving awkard. Thanks in advance for any suggestions __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of the Pinan Software __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] function which can apply a function by a grouping variable and also hand over an additional variable, e.g. a weight
Hi, I was wondering if there is an easy way to accomplish the following in R: Often I want to apply a function, e.g. weighted.quantile from the Hmisc package to grouped subsets of a data.frame (grouping variable) but then I also need to hand over the weights which seems not possible with summaryBy or aggregate or the like. Is there a function to do this? Currently I do this with loops but it is very slow. I would be very grateful for any hints. Thanks, Werner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpreting the example given by Frank Harrell in the predict.lrm {Design} help
John, Don't conclude that one category is the most probable when its probability of being equaled or exceeded is a maximum. The first category would always be the winner if that were the case. When you say y=best remember that you are dealing with a probability model. Nothing is forcing you to classify an observation, and unless the category's probability is high, this may be dangerous. You might do well to consider a more smooth approach such as using the generalized roc area (C-index) or its related rank correlation measure Dxy. Also there are odds ratios. Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Interpreting-the-example-given-by-Frank-Harrell-in-the-predict-lrm-Design-help-tp2883311p2891623.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpreting the example given by Frank Harrell in the predict.lrm {Design} help
Frank, Thats great thanks for the advice, i appreciate that brier score, AUC etc are a better method of validation and discrimination but when it comes to predictions of new data d - data.frame(x1=c(.1,.5),x2=c(.5,.15)) predict(f, d, type=fitted.ind) y=good y=bettery=best 1 0.3199710 0.3560355 0.3239935 2 0.4153257 0.3437086 0.2409657 predict mean(y) using codes 1,2,3 predict(f, d, type='mean', codes=TRUE) 12 2.004022 1.825640 How do i use this information to assign x1 and x2 into a category on the response scale (good,better,best?) Thanks John On 1 Oct 2010, at 12:14, Frank Harrell wrote: John, Don't conclude that one category is the most probable when its probability of being equaled or exceeded is a maximum. The first category would always be the winner if that were the case. When you say y=best remember that you are dealing with a probability model. Nothing is forcing you to classify an observation, and unless the category's probability is high, this may be dangerous. You might do well to consider a more smooth approach such as using the generalized roc area (C-index) or its related rank correlation measure Dxy. Also there are odds ratios. Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Interpreting-the-example-given-by-Frank-Harrell-in-the-predict-lrm-Design-help-tp2883311p2891623.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Issues loading rtiff 1.4.1 with R 2.6.2 on Windows
Probably there are not many people on this list left with such an ancient installation. Please try R-2.12.0 alpha. Uwe Ligges On 01.10.2010 11:49, Oderbolz Daniel wrote: Dear R-users, I successfully installed rtiff on by R installation, but when I tried to load it, I got: local({pkg- select.list(sort(.packages(all.available = TRUE))) + if(nchar(pkg)) library(pkg, character.only=TRUE)}) Error in dyn.load(file, ...) : unable to load shared library 'C:/PROGRA~1/R/R-26~1.2/library/rtiff/libs/rtiff.dll': LoadLibrary failure: Das angegebene Modul wurde nicht gefunden. When running nm from MinGW on C:\Program Files\R\R-2.6.2\library\rtiff\libs\rtiff.dll, it tells me no symbols :-/ So I tried to compile the dll from the sources and did this: gcc -shared -o rtiff.dll rtiff.c -ltiff -lr -IC:\Program Files\GnuWin32\include -IC:\Program Files\R\R-2.6.2\include -LC:\Program Files\GnuWin32\lib -LC:\MinGW\lib -LC:\Program Files\R\R-2.6.2\modules -LC:\Program Files\R\R-2.6.2\bin This indeed creates a dll witch exports 614 symbols. Also my dll is 29KB, the original one just 9 Kb... However, R still throws the same error... Is the infamous space in the Path to R a problem? Thanks a lot for any hint on this! P. S: It seems that the author had issues with compilation (ages ago): http://www.mail-archive.com/r-h...@stat.math.ethz.ch/msg54165.html Cheers, Daniel -- Daniel Oderbolz Paul Scherrer Institut CH-5232 Villigen Laboratory of Atmospheric Chemistry, Gasphase and Aerosol Chemistry Group OFLA/007 Tel: +41 (0)56 310 2449 Fax: 4525 daniel.oderbolz [AT] psi.ch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RGL and Windows 7
On 01/10/2010 2:12 AM, Sven Wagner wrote: Hi! For saving 3d plots I make use of the rgl.snapshot command provided within the rgl-Package. So far there was no problem using Windows XP, but under Windows 7 the result is a black image, however in the png-format (see attachment http://r.789695.n4.nabble.com/file/n2844487/Koll_perf.png ). What can I do? (Reinstalling Windows XP is no alternative. :-) ) You don't give any code to reproduce what you did, but the following just worked for me on Windows 7: example(plot3d) rgl.snapshot(c:/temp/test.png) The usual reasons rgl.snapshot fails are these: - Bugs in your graphics card or its driver. Try updating the driver. - The rgl graphics window being hidden at the time you call rgl.snapshot(). Some graphics drivers don't update the buffer if it's not visible, so rgl.snapshot() grabs junk. If you have the problem with my two lines above and neither suggestion above fixes it, then I don't know what's going on, and I wouldn't be very optimistic you'll be able to fix it. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] function which can apply a function by a grouping variable and also hand over an additional variable, e.g. a weight
You might want to check out the plyr package. Hadley On Fri, Oct 1, 2010 at 6:05 AM, Werner W. pensterfuz...@yahoo.de wrote: Hi, I was wondering if there is an easy way to accomplish the following in R: Often I want to apply a function, e.g. weighted.quantile from the Hmisc package to grouped subsets of a data.frame (grouping variable) but then I also need to hand over the weights which seems not possible with summaryBy or aggregate or the like. Is there a function to do this? Currently I do this with loops but it is very slow. I would be very grateful for any hints. Thanks, Werner __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fitting with error on data
On 27-Sep-10 08:55:13, Maayt wrote: As this forum proved to be very helpful, I got another question... I'd like to fit data points on which I have an error, dx and dy, on each x and y. What would be the common procedure to fit this data by a linear model taking into account uncertainty on each point? Would weighting each point by 1/sqrt(dx2+dy2) (and taking dx and dy as relative errors) in a lm() fit do the job? I would like to propagate uncertainty of the points into the uncertainty of the fit, would that be the case? Thanks for all the help -- It would seem that there has been no response yet to this query. This type of problem falls under various headers, typically [A] Fitting a linear functional relationship [B] Regression with errors in both variables For [A], it is envisaged that x and y are, in the real world, related by an exact lnear equation y = a + b*x or x = a' + b'y or A*x + B*y = C and that data (X1,X2,...), (Y1,Y2,...) are obtained by simultaneously measuring the exact values (x1,x2,...), (y1,y2,...) where measurement errors result in: Xi = xi + e.Xi Yi = yi + e.Yi where, for each i, e.X is (say) distributed as N(0,s.X^2) and e.Y as N(0,s.Y^2), where s.X and s.Y are the standard deviations of the errors of measurement in X and Y. Then it is a question of estimating a and b from the data. This can be done by Maximum Likelihood, which requires taking as parameters not only a and b, and s.X and s.Y, but also the unknown (only observed with error) exact values (x1,x2,...) and (y1,y2,...). This case will not fit into the standard lm() method of fitting. For [B], whereas in standard regression it is taken that the observed X values are used as they stand (i.e. taken as fixed), here it is accepted that they two are subject to error (similar to [A]). So, whereas (for given values of {Xi}, {Yi}) a standard lm(Y ~ X) will give an answer, the X-values on which the result depends will themselves be uncertain and this uncertainty has to be taken into account, in the sense that it is uncertain what values of X Y is being regressed on. The conceptual difference between [A] and [B] is that, in [A}, there is no directional aspect: x and y are simply being considered as related by y = a + b*x, or x = a' + b'*y, with no preference between either way of expressing it. The linear relationship can be used for any appropriate purpose. However, in [B] we are looking at a regression problem: y is being regressed on x: lm(Y ~ X), and the primary purpose is to predict the value of y that would result from a given value of x. So it is directional: x -- y. If we were interested in predicting x from y, then we would do it the other way round: lm(X ~ Y), so Y -- X, and the respective coefficients of the two different regression equations cannot be deduced from each other. So, in choosing between approach [A] and approach [B], you would need to consider what you want to use the results for. I think the Maximum Likelihood approach to [A] was first properly considered by D.V. Lindley in 1947: D. V. Lindley. Regression lines and the linear functional relationship. Suppl. J. Roy. Statist. Soc., 9:218-244, 1947. For this to work properly (i.e. be consistent in the technical sense), you need to know the ratio of the two standard errors (lambda = s.Y/s.X). From your statement of your problem, it looks as though you would know this ratio. The study of [B], regression with errors in both variables, goes back a very long way, and many approaches have been considered. These include several studies by J.B. Copas. Neither [A] nor [B] is, in general, a straightforward problem! A useful overview of approaches to both [A] and [B] can be found in the freely downloadable: An historical overview of regression with errors in both variables. J.W. Gillard (Cardiff University) http://www.cardiff.ac.uk/maths/resources/Gillard_Tech_Report.pdf Now, as to what may be available in R: I was a bit surprised to find that a full R site search on either of linear functional relationship errors in both variables yielded nothing relevant. It may be that using different search terms would find appropriate methods (such as considered by Gillard, or the Lindley approach for [A]), but I'm having difficulty thinking what such might be! So I hope that R-help readers who have used R for this category of problem can help! Ted. E-Mail: (Ted Harding) ted.hard...@wlandres.net Fax-to-email: +44 (0)870 094 0861 Date: 01-Oct-10 Time: 14:10:54 -- XFMail -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Accessing Element of a Table
I have the following structure: str(propn) table [1:2(1d)] 0.674 0.326 - attr(*, dimnames)=List of 1 ..$ label: chr [1:2] o x print(propn) label o x 0.6738347 0.3261653 How can I access the value of o and x I tried this but fail print(propn$label[,o]; - G.V. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpreting the example given by Frank Harrell in the predict.lrm {Design} help
Why assign them at all? Is this a forced choice at gunpoint problem? Remember what probabilities mean. Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Interpreting-the-example-given-by-Frank-Harrell-in-the-predict-lrm-Design-help-tp2883311p2909713.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RGL and Windows 7
Thanks, but your suggestions don't solve the problem. Though, the plot is storable via the rgl.postscript command, but this increases computation time and memory requirements. -- View this message in context: http://r.789695.n4.nabble.com/RGL-and-Windows-7-tp2844487p2910131.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] RGL and Windows 7
On 01/10/2010 9:53 AM, Sven Wagner wrote: Thanks, but your suggestions don't solve the problem. Though, the plot is storable via the rgl.postscript command, but this increases computation time and memory requirements. rgl.postscript is limited in the kinds of scenes it can render, so check carefully whether you have a faithful copy of the image. If you do, it will probably be much better quality than the bitmap that rgl.snapshot produces. Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Accessing Element of a Table
On 2010-10-01 7:43, Gundala Viswanath wrote: I have the following structure: str(propn) table [1:2(1d)] 0.674 0.326 - attr(*, dimnames)=List of 1 ..$ label: chr [1:2] o x print(propn) label o x 0.6738347 0.3261653 How can I access the value of o and x I tried this but fail print(propn$label[,o]; - G.V. Try propn[[o]] -Peter Ehlers __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fitting with error on data
There is the lmodel2 package... http://cran.r-project.org/web/packages/lmodel2/vignettes/mod2user.pdf Geometric mean regression has been discussed on this list in the past, for example: https://stat.ethz.ch/pipermail/r-help/2005-June/072927.html I've used that approach with nls (rightly or wrongly I'm not sure :) http://lastresortsoftware.blogspot.com/2010/08/meeting-in-middle-or-fudging-model-ii.html Hope this helps Michael On 1 October 2010 23:11, Ted Harding ted.hard...@wlandres.net wrote: On 27-Sep-10 08:55:13, Maayt wrote: As this forum proved to be very helpful, I got another question... I'd like to fit data points on which I have an error, dx and dy, on each x and y. What would be the common procedure to fit this data by a linear model taking into account uncertainty on each point? Would weighting each point by 1/sqrt(dx2+dy2) (and taking dx and dy as relative errors) in a lm() fit do the job? I would like to propagate uncertainty of the points into the uncertainty of the fit, would that be the case? Thanks for all the help -- It would seem that there has been no response yet to this query. This type of problem falls under various headers, typically [A] Fitting a linear functional relationship [B] Regression with errors in both variables For [A], it is envisaged that x and y are, in the real world, related by an exact lnear equation y = a + b*x or x = a' + b'y or A*x + B*y = C and that data (X1,X2,...), (Y1,Y2,...) are obtained by simultaneously measuring the exact values (x1,x2,...), (y1,y2,...) where measurement errors result in: Xi = xi + e.Xi Yi = yi + e.Yi where, for each i, e.X is (say) distributed as N(0,s.X^2) and e.Y as N(0,s.Y^2), where s.X and s.Y are the standard deviations of the errors of measurement in X and Y. Then it is a question of estimating a and b from the data. This can be done by Maximum Likelihood, which requires taking as parameters not only a and b, and s.X and s.Y, but also the unknown (only observed with error) exact values (x1,x2,...) and (y1,y2,...). This case will not fit into the standard lm() method of fitting. For [B], whereas in standard regression it is taken that the observed X values are used as they stand (i.e. taken as fixed), here it is accepted that they two are subject to error (similar to [A]). So, whereas (for given values of {Xi}, {Yi}) a standard lm(Y ~ X) will give an answer, the X-values on which the result depends will themselves be uncertain and this uncertainty has to be taken into account, in the sense that it is uncertain what values of X Y is being regressed on. The conceptual difference between [A] and [B] is that, in [A}, there is no directional aspect: x and y are simply being considered as related by y = a + b*x, or x = a' + b'*y, with no preference between either way of expressing it. The linear relationship can be used for any appropriate purpose. However, in [B] we are looking at a regression problem: y is being regressed on x: lm(Y ~ X), and the primary purpose is to predict the value of y that would result from a given value of x. So it is directional: x -- y. If we were interested in predicting x from y, then we would do it the other way round: lm(X ~ Y), so Y -- X, and the respective coefficients of the two different regression equations cannot be deduced from each other. So, in choosing between approach [A] and approach [B], you would need to consider what you want to use the results for. I think the Maximum Likelihood approach to [A] was first properly considered by D.V. Lindley in 1947: D. V. Lindley. Regression lines and the linear functional relationship. Suppl. J. Roy. Statist. Soc., 9:218-244, 1947. For this to work properly (i.e. be consistent in the technical sense), you need to know the ratio of the two standard errors (lambda = s.Y/s.X). From your statement of your problem, it looks as though you would know this ratio. The study of [B], regression with errors in both variables, goes back a very long way, and many approaches have been considered. These include several studies by J.B. Copas. Neither [A] nor [B] is, in general, a straightforward problem! A useful overview of approaches to both [A] and [B] can be found in the freely downloadable: An historical overview of regression with errors in both variables. J.W. Gillard (Cardiff University) http://www.cardiff.ac.uk/maths/resources/Gillard_Tech_Report.pdf Now, as to what may be available in R: I was a bit surprised to find that a full R site search on either of linear functional relationship errors in both variables yielded nothing relevant. It may be that using different search terms would find appropriate methods (such as considered by Gillard, or the Lindley approach for [A]), but I'm having difficulty thinking what such might be! So I hope that R-help readers who have used R for this category of problem can help! Ted.
[R] Fwd: Interpreting the example given by Frank Harrell in the predict.lrm {Design} help
Frank and list, The reason I am trying to assign them is because I have a data set where i have arrived at the most likely model that describes the data and now I have another dataset where I know the factors but not the response. Therefore, surely I need to assign the predicted values to a response in order to say something like: Based on the model I believe unknown 1 is good, where as unknown 2 is very good etc? Maybe I am missing something or using the wrong approach but I thought the main purpose of using the predict function on new data was to predict the response? John On 1 Oct 2010, at 14:51, Frank Harrell f.harr...@vanderbilt.edu wrote: Why assign them at all? Is this a forced choice at gunpoint problem? Remember what probabilities mean. Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Interpreting-the-example-given-by-Frank-Harrell-in-the-predict-lrm-Design-help-tp2883311p2909713.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotting wind rose data (Karl Ropkins)
David, Following on from Jim Lemon's suggest that polar plots might be more what you need, there are both wind rose and polar plot functions in the openair package that might be of use (particularly windRose and polarFreq). They will not do everthing you are after without some careful conditioning or extra work with latticeExtra, but could get you some of the way there. Karl Ropkins, Hi List, I am trying to create a spatial representation of some wind data. I have the season, frequency, strength and direction of the wind from 10 different locations, the coverage of the area that I am interested in is not 100% there are small gaps in my coverage due to the location of the weather stations. I am trying to create a series of wind maps e.g. the Prevailing Winds, the maximum seasonal wind, etc. Could any body recommend any R-packages that would cover this type problem/issue? Hi David, While there are several packages that include plotting routines for wind roses, it looks to me as though you want to define a small number of vectors representing prevailing wind, etc., possible overlaying these on a plot. That might be a job for a circular plotting routine (e.g. polar.plot) rather than a wind rose. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Question about Reduce
Hello! In the example below the Reduce() function by default assigns a to be the last accumulated value and b to be the current value in x. I could not find this documented anywhere as the default settings for the Reduce() function. Does any sort of documentation for this behavior exist? x - c(0,0,0,0,0,1,0,0,0,5,0,0,0,7,0,0,0,8,5,10) Reduce(function(a,b) b + (a * 0.5),x,accumulate=T,init=0) [1] 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.500 0.250 [10] 0.125 5.0625000 2.5312500 1.2656250 0.6328125 7.3164062 3.6582031 1.8291016 0.9145508 [19] 8.4572754 9.2286377 14.6143188 Thanks a lot! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Scatterplot matrix - Pearson linear correlation and Density Ellipse
On 2010-09-30 15:42, ashz wrote: Hi, I have modified a known script to generate a scatterplot matrix: panel.cor = function(x, y, digits=2, prefix=Rho=, cex.cor) { usr = par(usr); on.exit(par(usr)) par(usr = c(0, 1, 0, 1)) r = abs(cor(x, y, use=pairwise.complete.obs, method = pearson)) txt = format(c(r, 0.123456789), digits=digits)[1] txt = paste(prefix, txt, sep=) if(missing(cex.cor)) cex.cor = 0.8/strwidth(txt) text(0.5, 0.5, txt, cex = cex.cor) } pairs(ap[8:11], lower.panel=panel.smooth, upper.panel=panel.cor) My question is how I can change the lower.panel to show both the pearson linear correlation and Density Ellipse? Have a look at pairs.panels() in pkg:psych. -Peter Ehlers Thanks a lot. As Hz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Need to incorporate the use of na.rm into custom function
Hi, Take a matrix with missing values: X = matrix(rnorm(10), ncol = 5) X[2,4]=NA X [,1] [,2] [,3] [,4] [,5] [1,] -0.1566427 -0.7382232 -1.0564624 -0.8412139 0.9370319 [2,] -1.0289865 -0.8452054 -0.1349459 NA -0.1749113 I want to apply a custom function over the rows such that the NAs are ignored in a similar fashion as to how the following works. means-apply(X,1,mean,na.rm=TRUE) Custom function: liptak-function (x,df) 2*(pnorm(abs(sum(x*df)/sqrt(sum(df^2))),lower.tail=FALSE)) I want to be able to do the following: rslt-apply(X,1,liptak,na.rm=TRUE) Can someone point me in the right direction on how to incorporate the use of na.rm into my function? Scott sessionInfo() R version 2.11.0 (2010-04-22) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.11.0 Scott A. Ochsner, PhD NURSA Bioinformatics Baylor College of Medicine One Baylor Plaza Mail Stop: BCM-130 Houston, TX 77030 Voice: (713) 798-6227 Fax: (713) 790-1275 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Need to incorporate the use of na.rm into custom function
You can use na.omit on x after it is passed into your apply function if na.rm == T, or simply pass your na.rm to functions that use it, such as sum. Hope that helps, Jeff. On Fri, Oct 1, 2010 at 11:07 AM, Ochsner, Scott A sochs...@bcm.edu wrote: Hi, Take a matrix with missing values: X = matrix(rnorm(10), ncol = 5) X[2,4]=NA X [,1] [,2] [,3] [,4] [,5] [1,] -0.1566427 -0.7382232 -1.0564624 -0.8412139 0.9370319 [2,] -1.0289865 -0.8452054 -0.1349459 NA -0.1749113 I want to apply a custom function over the rows such that the NAs are ignored in a similar fashion as to how the following works. means-apply(X,1,mean,na.rm=TRUE) Custom function: liptak-function (x,df) 2*(pnorm(abs(sum(x*df)/sqrt(sum(df^2))),lower.tail=FALSE)) I want to be able to do the following: rslt-apply(X,1,liptak,na.rm=TRUE) Can someone point me in the right direction on how to incorporate the use of na.rm into my function? Scott sessionInfo() R version 2.11.0 (2010-04-22) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.11.0 Scott A. Ochsner, PhD NURSA Bioinformatics Baylor College of Medicine One Baylor Plaza Mail Stop: BCM-130 Houston, TX 77030 Voice: (713) 798-6227 Fax: (713) 790-1275 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Creating R objects in Java
How do you call R methods from Java? I want to create a GUI using Swing in Jaa that calls R methods in Java. -- View this message in context: http://r.789695.n4.nabble.com/Creating-R-objects-in-Java-tp2904497p2904497.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] colored rasterImage()
Doh! Of course! Thanks for this. I convinced myself that the input image to rasterImage() had to be scaled 0-1. I think I started down that path by trying the following with as.raster() ... m - matrix(data = rep(seq(0,3, length = nx), ny), ncol = nx, nrow = ny, byrow = TRUE) r - as.raster(m) Error in rgb(tx, tx, tx, max = max) : color intensity 1.0303, not in [0,1] And my next step was to follow the examples for rasterImage() which use 0-1. I'm glad to be straightened out. Thanks, Ben On Oct 1, 2010, at 12:26 AM, Michael Sumner wrote: Use the matrix of colours directly: nx - 100 ny - 100 m - matrix(data = rep(seq(0,1, length = nx), ny), ncol = nx, nrow = ny, byrow = TRUE) plot(1:nx, 1:ny, type = n) my.color - matrix(data = (rainbow(100))[m*100], ncol = nx, nrow = ny, byrow = TRUE) rasterImage(my.color, 1, 1, nx, ny) Also, you might want to check out image.SpatialGridDataFrame in package sp that provides a wrapper around rasterImage for SpatialGrids. I'm not aware of other examples, but I have not looked hard since the first release of rasterImage. library(sp) sp:::image.SpatialGridDataFrame Cheers, Mike. On Fri, Oct 1, 2010 at 12:50 PM, Ben Tupper ben.bigh...@gmail.com wrote: Hello, I have been exploring the possibility to transition some code that currently uses image() to use the new rasterImage(). To date, I haven't been able to specify a color look-up strategy that works. For example... nx - 100 ny - 100 m - matrix(data = rep(seq(0,1, length = nx), ny), ncol = nx, nrow = ny, byrow = TRUE) plot(1:nx, 1:ny, type = n) my.color - matrix(data = (rainbow(100))[m*100], ncol = nx, nrow = ny, byrow = TRUE) rasterImage(m, 1, 1, nx, ny, col = my.color) This yields a greyscale image. Is it possible to create colored images using rasterImage, and, if so, what is the correct way to generate a colored image using rasterImage? Also, is there a vignette or tutorial on using the new rasterImage() and related functions? Thanks! Ben Tupper Bigelow Laboratory for Ocean Science www.bigelow.org R.Version() $platform [1] i386-apple-darwin9.8.0 $arch [1] i386 $os [1] darwin9.8.0 $system [1] i386, darwin9.8.0 $status [1] $major [1] 2 $minor [1] 11.1 $year [1] 2010 $month [1] 05 $day [1] 31 $`svn rev` [1] 52157 $language [1] R $version.string [1] R version 2.11.1 (2010-05-31) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Michael Sumner Institute for Marine and Antarctic Studies, University of Tasmania Hobart, Australia e-mail: mdsum...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Small p-value good or bad?
Dear R-community, I have a short question: How do I interpret the result of a likelihood ratio test correctly? I am fitting a parametric survival model (with aftreg {eha}) and the output tells me the overall p-value of my model is 0.001. My simple question is: Does the result mean my model fits the data well OR does it mean my model DOES NOT fit the data well? Some side information how the p-value is calculated: logtest - -2 * (x$loglik[1] - x$loglik[2]) pvalue - 1-pchisq(logtest,df) with x$loglik[1] = -274 x$loglik[2] = -235 df = 25 I know the answer would probably be read the manual but I found different opinions on the web and want to make sure I am interpreting it correctly. Thanks Thomas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help regarding the package installation
hii everyone! Recently i have started working with R and it would be nice if anyone can help me with this. I am vista user (32 bit). I wanted to install package in my parent directory i.e .Library. whenever I try to install nnet (package) it is showing me the following error: install.packages(C:\\Users\\nn223\\Downloads\\nnet_7.3-1.zip,lib=.Library) Warning in install.packages(C:\\Users\\nn223\\Downloads\\nnet_7.3-1.zip, : 'lib = C:/PROGRA~1/R/R-211~1.1/library' is not writable Error in install.packages(C:\\Users\\nn223\\Downloads\\nnet_7.3-1.zip, : unable to install packages or install.packages(nnet,lib=.Library) Error in install.packages(nnet, lib = .Library) : object 'nnet' not found Please let me know if I am doing anything wrong. thank you -- View this message in context: http://r.789695.n4.nabble.com/help-regarding-the-package-installation-tp2894726p2894726.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Inserting a plot into another
hi I'll take a look at it. - [url=http://moviesonlineworld.com]watch free movies online[/url] -- View this message in context: http://r.789695.n4.nabble.com/Inserting-a-plot-into-another-tp2720936p2877931.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] help regarding the package installation
hii everyone! Recently i have started working with R and it would be nice if anyone can help me with this. I am vista user (32 bit). I wanted to install package in my parent directory i.e .Library. whenever I try to install nnet (package) it is showing me the following error: install.packages(C:\\Users\\nn223\\Downloads\\nnet_7.3-1.zip,lib=.Library) Warning in install.packages(C:\\Users\\nn223\\Downloads\\nnet_7.3-1.zip, : 'lib = C:/PROGRA~1/R/R-211~1.1/library' is not writable Error in install.packages(C:\\Users\\nn223\\Downloads\\nnet_7.3-1.zip, : unable to install packages or install.packages(nnet,lib=.Library) Error in install.packages(nnet, lib = .Library) : object 'nnet' not found Please let me know if I am doing anything wrong. thank you -- View this message in context: http://r.789695.n4.nabble.com/help-regarding-the-package-installation-tp2909825p2909825.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Looping through different arguments
If for example I have garchFit(~garch(1,1) but I want to loop through all the different combinations of ARMA/GARCH/APARCH. Another model could be ~arma(2,1)+apaarch(1,1). How do I transition between garch(1,1) and arma(2,1)+apaarch(1,1) using a for loop. -- View this message in context: http://r.789695.n4.nabble.com/Looping-through-different-arguments-tp2907035p2907035.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpreting the example given by Frank Harrell in the predict.lrm {Design} help
The reason I am trying to assign them is because I have a data set where i have arrived at the most likely model that describes the data and now I have another dataset where I know the factors but not the response. Therefore, surely I need to assign the predicted values to a response in order to say something like: Based on the model I believe unknown 1 is good, where as unknown 2 is very good etc? Maybe I am missing something or using the wrong approach but I thought the main purpose of using the predict function on new data was to predict the response? Peter On 1 Oct 2010, at 14:51, Frank Harrell f.harr...@vanderbilt.edu wrote: Why assign them at all? Is this a forced choice at gunpoint problem? Remember what probabilities mean. Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Interpreting-the-example-given-by-Frank-Harrell-in-the-predict-lrm-Design-help-tp2883311p2909713.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 'all subsets' fitting algorithm for Bayesian approach
Hi R experts I am just wondering if something is already available (or easily adaptable) to do the following. I am planning to build linear models for all possible combinations of terms, so for example if the terms are sent into a function as this string X1 + X2 + X3 + X4 + X1:X2 I would want to build models for all possible combinations of these 5 terms, e.g. m1 - lm( y ~ X1 + X3 ) and capture at least the residual sum of squares and total number of model parameters from each model produced. This will become part of a Bayesian approach to infer actual model probabilities when specialist prior knowledge is also introduced into the problem. At a high level this particular problem requires something like: 1) the term 'string' to be broken down into it's elements which are separated by + and, I suppose, stored in a list for easier manipulation 2) a matrix with 2^5 rows and 5 columns to be formed with a 0 present if the term is not included and 1 if it is. Then a model will be fitted to represent every row of this matrix and the key statistics stored in vectors of length 2^5 For N terms of course the number of models will be 2^N. Is there anything available already? This is a very similar problem to all subsets regression. My skill at manipulating strings in R is very limited; can anyone recommend some links or available functions which would make the separations and constructions required easy to achieve? Thanks in advance to all Michael Hopkins Algorithm and Statistical Modelling Expert Upstream 23 Old Bond Street London W1S 4PZ Mob +44 0782 578 7220 DL +44 0207 290 1326 Fax +44 0207 290 1321 hopk...@upstreamsystems.com www.upstreamsystems.com IMPORTANT NOTICE The information in this e-mail and any attached files is...{{dropped:22}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Converting a dataframe column from string to datetime
Youre working too hard. Use this: tms - as.POSIXct(strptime(v, %a %b %d %H:%M:%OS %Y)) Take note of the fact that there are two types of datetime objects: POSIXct and POSIXlt. Your unlist() gave what seemed a strange result because you used on an lt object. Had you given it a ct object it would have made sense. To see, try lapply(v,function(x){as.POSIXct(strptime(x, %a %b %d %H:%M:%OS %Y))}) But using lapply() was more complicated than necessary. -Don On 9/30/10 10:59 PM, raje...@cse.iitm.ac.in raje...@cse.iitm.ac.in wrote: Hi, I have a dataframe column of the form v-c(Fri Feb 05 20:00:01.43000 2010,Fri Feb 05 20:00:02.274000 2010,Fri Feb 05 20:00:02.274000 2010,Fri Feb 05 20:00:06.34000 2010) I need to convert this to datetime form. I did the following.. lapply(v,function(x){strptime(x, %a %b %d %H:%M:%OS %Y)}) This gives me a list that looks like this... [[1]] [1] 2010-02-05 20:00:01.43 [[2]] [1] 2010-02-05 20:00:02.274 [[3]] [1] 2010-02-05 20:00:02.274 [[4]] [1] 2010-02-05 20:00:06.34 However, when I do an unlist...I gets converted to something like this... sec minhourmday monyearwdayyday isdst sec minhour mday monyearwdayyday isdst sec 1.430 0.000 20.000 5.000 1.000 110.000 5.000 35.000 0.000 2.274 0.000 20.000 5.000 1.000 110.000 5.000 35.000 0.000 2.274 minhourmday monyearwdayyday isdst sec minhour mday monyearwdayyday isdst 0.000 20.000 5.000 1.000 110.000 5.000 35.000 0.000 6.340 0.000 20.000 5.000 1.000 110.000 5.000 I want it to become a dataframe column except for a change in the datatype to datetime...how can I achieve this? [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://BLOCKEDstat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://BLOCKEDwww.BLOCKEDR-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory 925 423-1062 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 2.11.1 crashes
Tal Galili tal.galili at gmail.com writes: You'll need to give more information for people to help you. 1) Is this the first time you installed R? Or was it a working R version that suddenly started having this problem? 2) Did you try uninstalling this version, downloading a new version, installing it - and seeing what happens? 3) Do you have an office firewall ? (what type?) He said that he had no internet connection, so the firewall must be irrelevant? In the installation process, you can set the type of help file you get. maybe that would resolve your issue (although I have a feeling you need to reinstall R and it would work - it shouldn't need internet for help). [snip] On Thu, Sep 30, 2010 at 4:41 PM, Steve Su ssu at maths.uwa.edu.au wrote: I was using R 2.11.1 without internet connection on Windows XP and whenever I type ?mean for example, R would freeze and crash out... Is this something that can be fixed? I would like to use the internel help file if possible... Does the system give any warning/error messages at all, or does R just terminate without a trace? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help regarding the package installation
On 01/10/2010 7:39 AM, Neeti wrote: hii everyone! Recently i have started working with R and it would be nice if anyone can help me with this. I am vista user (32 bit). I wanted to install package in my parent directory i.e .Library. whenever I try to install nnet (package) it is showing me the following error: install.packages(C:\\Users\\nn223\\Downloads\\nnet_7.3-1.zip,lib=.Library) Warning in install.packages(C:\\Users\\nn223\\Downloads\\nnet_7.3-1.zip, : 'lib = C:/PROGRA~1/R/R-211~1.1/library' is not writable That means just what it says: you're trying to install the package into a directory, but the administrator of your machine (you?) hasn't given R permission to make changes to that directory. If you are the administrator, you might get that to work using Run as administrator, which is an option in Windows when you right click on the R icon. If you're not the administrator, chances are you'll need to find someplace else (where you have write permission) to install that package. Error in install.packages(C:\\Users\\nn223\\Downloads\\nnet_7.3-1.zip, : unable to install packages or install.packages(nnet,lib=.Library) Error in install.packages(nnet, lib = .Library) : object 'nnet' not found That's because you don't have any object named nnet. Some functions (e.g. library()) guess that you mean nnet when you type nnet, but install.packages doesn't. So you should try install.packages(nnet) Duncan Murdoch Please let me know if I am doing anything wrong. thank you __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Need to incorporate the use of na.rm into custom function
Jeff, Thanks for the help. I should have thought of passing na.rm to sum. This worked nicely. Scott Scott A. Ochsner, PhD One Baylor Plaza BCM130, Houston, TX 77030 Voice: (713) 798-6227 Fax: (713) 790-1275 -Original Message- From: jsp...@gmail.com [mailto:jsp...@gmail.com] On Behalf Of Jeffrey Spies Sent: Friday, October 01, 2010 10:13 AM To: Ochsner, Scott A Cc: r-help@r-project.org Subject: Re: [R] Need to incorporate the use of na.rm into custom function You can use na.omit on x after it is passed into your apply function if na.rm == T, or simply pass your na.rm to functions that use it, such as sum. Hope that helps, Jeff. On Fri, Oct 1, 2010 at 11:07 AM, Ochsner, Scott A sochs...@bcm.edu wrote: Hi, Take a matrix with missing values: X = matrix(rnorm(10), ncol = 5) X[2,4]=NA X [,1] [,2] [,3] [,4] [,5] [1,] -0.1566427 -0.7382232 -1.0564624 -0.8412139 0.9370319 [2,] -1.0289865 -0.8452054 -0.1349459 NA -0.1749113 I want to apply a custom function over the rows such that the NAs are ignored in a similar fashion as to how the following works. means-apply(X,1,mean,na.rm=TRUE) Custom function: liptak-function (x,df) 2*(pnorm(abs(sum(x*df)/sqrt(sum(df^2))),lower.tail=FALSE)) I want to be able to do the following: rslt-apply(X,1,liptak,na.rm=TRUE) Can someone point me in the right direction on how to incorporate the use of na.rm into my function? Scott sessionInfo() R version 2.11.0 (2010-04-22) i386-pc-mingw32 locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] tools_2.11.0 Scott A. Ochsner, PhD NURSA Bioinformatics Baylor College of Medicine One Baylor Plaza Mail Stop: BCM-130 Houston, TX 77030 Voice: (713) 798-6227 Fax: (713) 790-1275 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Creating R objects in Java
On 10/1/10 9:18 AM, lord12 wrote: How do you call R methods from Java? I want to create a GUI using Swing in Jaa that calls R methods in Java. Look in the documentation for the rJava package -- Abhijit Dasgupta, PhD Director and Principal Statistician ARAASTAT Ph: 301.385.3067 E: adasgu...@araastat.com W: http://www.araastat.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help regarding the package installation
Thank you so much... it is working fine -- View this message in context: http://r.789695.n4.nabble.com/help-regarding-the-package-installation-tp2894726p2925020.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R-Square for Robust Regression Model
The usual way, I suppose: (1 - RSS (model with only a constant)/RSS(full model)). However, it's not particularly meaningful to do this, because points are weighted differently depending on the model. This means that the usual interpretation as the proportion of unexplained variation is wrong; and none of the standard distributional properties hold either. Bottom line: Reconsider your request. Familiar linear model concepts and statistical results do NOT hold for robust regression, which is a kind of nonlinear regression, actually. Corrections and further clarifications by experts would be welcome. -- Bert On Thu, Sep 30, 2010 at 10:56 PM, Hock Ann Lim lim...@yahoo.com wrote: May I know how to find the R-squared for robust regression model? Thank you. Hock Ann [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] mhtplot?
Hello All: I was wondering why many plot options are not working with mhtplot. I could not find much info about this function on the web too. Any comments, any detailed manual ... Thanks, MJK [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question about Reduce
On Fri, 1 Oct 2010, Dimitri Liakhovitski wrote: Hello! In the example below the Reduce() function by default assigns a to be the last accumulated value and b to be the current value in x. I could not find this documented anywhere as the default settings for the Reduce() function. Does any sort of documentation for this behavior exist? Yes. Under 'Details' on the Reduce help page: ... a left reduce computes l_1 = f(v_1, v_2), l_2 = f(l_1, v_3), etc... HTH, Chuck x - c(0,0,0,0,0,1,0,0,0,5,0,0,0,7,0,0,0,8,5,10) Reduce(function(a,b) b + (a * 0.5),x,accumulate=T,init=0) [1] 0.000 0.000 0.000 0.000 0.000 0.000 1.000 0.500 0.250 [10] 0.125 5.0625000 2.5312500 1.2656250 0.6328125 7.3164062 3.6582031 1.8291016 0.9145508 [19] 8.4572754 9.2286377 14.6143188 Thanks a lot! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] add a new column to data frame
Hi, I am wondering if anyone can propose a simple/best way to do the following: Let's say I have a data frame dat - cbind(expand.grid(mode=c('right','left'),time=0:3,id=c('p1','p2','p3')),y=c(3,5,rep(4,6),6,2,rep(3,6),4,4,rep(2,6))) dat mode time id y 1 right0 p1 3 2 left0 p1 5 3 right1 p1 4 4 left1 p1 4 5 right2 p1 4 6 left2 p1 4 7 right0 p2 6 8 left0 p2 2 9 right1 p2 3 10 left1 p2 3 11 right2 p2 3 12 left2 p2 3 13 right0 p3 4 14 left0 p3 4 15 right1 p3 2 16 left1 p3 2 17 right2 p3 2 18 left2 p3 2 Now I want to add a new column type to this data frame with values of either left or right for each id based on the following logic: For each id, the value of type column is the value of mode for which the value of y is the maximum of y based on time=0. For example for id=p1, the value of type is left because for the 2 y values (3 5) based on time=0, mode=left has the bigger y value (5). But if the 2 y values are the same for mode, then let type=right. In the end the new data frame is: mode time id y type 1 right0 p1 3 left 2 left0 p1 5 left 3 right1 p1 4 left 4 left1 p1 4 left 5 right2 p1 4 left 6 left2 p1 4 left 7 right0 p2 6 right 8 left0 p2 2 right 9 right1 p2 3 right 10 left1 p2 3 right 11 right2 p2 3 right 12 left2 p2 3 right 13 right0 p3 4 right 14 left0 p3 4 right 15 right1 p3 2 right 16 left1 p3 2 right 17 right2 p3 2 right 18 left2 p3 2 right Any suggestions would be appreciated. John [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'all subsets' fitting algorithm for Bayesian approach
u... You are reinventing the wheel. In fact, several wheels: the statistical literature already has several different approaches worked out for this. For example, George Box and David Steinberg did one about 20 years ago, and it has been incorporated as one of the options in the JMP DOE model choice procedure. So do your homework and save yourself some effort. Maybe even all your effort. -- Bert On Fri, Oct 1, 2010 at 7:02 AM, Michael Hopkins hopk...@upstreamsystems.com wrote: Hi R experts I am just wondering if something is already available (or easily adaptable) to do the following. I am planning to build linear models for all possible combinations of terms, so for example if the terms are sent into a function as this string X1 + X2 + X3 + X4 + X1:X2 I would want to build models for all possible combinations of these 5 terms, e.g. m1 - lm( y ~ X1 + X3 ) and capture at least the residual sum of squares and total number of model parameters from each model produced. This will become part of a Bayesian approach to infer actual model probabilities when specialist prior knowledge is also introduced into the problem. At a high level this particular problem requires something like: 1) the term 'string' to be broken down into it's elements which are separated by + and, I suppose, stored in a list for easier manipulation 2) a matrix with 2^5 rows and 5 columns to be formed with a 0 present if the term is not included and 1 if it is. Then a model will be fitted to represent every row of this matrix and the key statistics stored in vectors of length 2^5 For N terms of course the number of models will be 2^N. Is there anything available already? This is a very similar problem to all subsets regression. My skill at manipulating strings in R is very limited; can anyone recommend some links or available functions which would make the separations and constructions required easy to achieve? Thanks in advance to all Michael Hopkins Algorithm and Statistical Modelling Expert Upstream 23 Old Bond Street London W1S 4PZ Mob +44 0782 578 7220 DL +44 0207 290 1326 Fax +44 0207 290 1321 hopk...@upstreamsystems.com www.upstreamsystems.com IMPORTANT NOTICE The information in this e-mail and any attached files is...{{dropped:22}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Bert Gunter Genentech Nonclinical Biostatistics 467-7374 http://devo.gene.com/groups/devo/depts/ncb/home.shtml __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Facets in ggplot2
Hello, I'm trying to introduce myself to ggplot2. I'm using syntax from the help file, but pasting in my own data. I don't understand the error message I'm getting. Can anyone clue me in? A Google search of this error statement didn't return anything I could recognize as useful. Thanks, Paul str(d.AD) 'data.frame': 9 obs. of 3 variables: $ treatment: Factor w/ 3 levels 1,2,3: 1 1 1 2 2 2 3 3 3 $ outcome : Factor w/ 3 levels 1,2,3: 1 2 3 1 2 3 1 2 3 $ counts : num 18 17 15 20 10 20 25 13 12 qplot(d.AD$outcome,d.AD$counts,data=d.AD, facets=.~ d.AD$treatment) Error in `[.data.frame`(plot$data, , setdiff(cond, names(df)), drop = FALSE) : undefined columns selected Paul Prew ⪠Statistician 651-795-5942 ⪠fax 651-204-7504 Ecolab Research Center ⪠Mail Stop ESC-F4412-A 655 Lone Oak Drive ⪠Eagan, MN 55121-1560 CONFIDENTIALITY NOTICE: This e-mail communication and any attachments may contain proprietary and privileged information for the use of the designated recipients named above. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to Install R Commander?
Hi, I am trying to install R commander. I used the command: install.packages(Rcmdr, dependencies = TRUE) It gives me this: Warning in install.packages(Rcmdr, dependencies = TRUE) : argument 'lib' is missing: using 'C:\Users\Karimi\Documents/R/win-library/2.11' trying URL 'http://cran.opensourceresources.org/bin/windows/contrib/2.11/Rcmdr_1.6-0.zip' Content type 'application/zip' length 2636395 bytes (2.5 Mb) opened URL downloaded 2.5 Mb package 'Rcmdr' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Users\Karimi\AppData\Local\Temp\RtmpJPbedc\downloaded_packages then I type: library(Rcmdr) Loading required package: tcltk Loading Tcl/Tk interface ...Error : .onLoad failed in loadNamespace() for 'tcltk', details: call: NULL error: Tcl/Tk support files were not installed Error: package 'tcltk' could not be loaded I tried installing tcltk but I could not do it :( It wouldn't let me. Help please??? Thanks :) -- View this message in context: http://r.789695.n4.nabble.com/How-to-Install-R-Commander-tp2937204p2937204.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Facets in ggplot2
Try this, qplot(outcome, counts, data=d.AD, facets=.~ treatment) HTH, baptiste __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] cleaning up a vector
I calculated a large vector. Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous. I ended up wih some Infs and NaNs in the vector. I would like to filter out the Inf and NaN values and only keep the values in my vector that range from 1 to 20. Is there a way to filter out Infs and NaNs in R and end up with a clean vector? Mike __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cleaning up a vector
Try this: x[is.finite(x)] On Fri, Oct 1, 2010 at 2:51 PM, mlar...@rsmas.miami.edu wrote: I calculated a large vector. Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous. I ended up wih some Infs and NaNs in the vector. I would like to filter out the Inf and NaN values and only keep the values in my vector that range from 1 to 20. Is there a way to filter out Infs and NaNs in R and end up with a clean vector? Mike __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] add a new column to data frame
Here are two ways: dat0 = subset(dat,time==0) one = as.data.frame(as.table(by(dat0,dat0$id, function(x)as.character(x$mode)[which.max(x$y)]))) names(one) = c('id','type') merge(dat,one) two = sapply(split(dat0,dat0$id), function(x)as.character(x$mode)[which.max(x$y)]) merge(dat,data.frame(id=names(two),type=two)) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Fri, 1 Oct 2010, array chip wrote: Hi, I am wondering if anyone can propose a simple/best way to do the following: Let's say I have a data frame dat - cbind(expand.grid(mode=c('right','left'),time=0:3,id=c('p1','p2','p3')),y=c(3,5,rep(4,6),6,2,rep(3,6),4,4,rep(2,6))) dat mode time id y 1 right0 p1 3 2 left0 p1 5 3 right1 p1 4 4 left1 p1 4 5 right2 p1 4 6 left2 p1 4 7 right0 p2 6 8 left0 p2 2 9 right1 p2 3 10 left1 p2 3 11 right2 p2 3 12 left2 p2 3 13 right0 p3 4 14 left0 p3 4 15 right1 p3 2 16 left1 p3 2 17 right2 p3 2 18 left2 p3 2 Now I want to add a new column type to this data frame with values of either left or right for each id based on the following logic: For each id, the value of type column is the value of mode for which the value of y is the maximum of y based on time=0. For example for id=p1, the value of type is left because for the 2 y values (3 5) based on time=0, mode=left has the bigger y value (5). But if the 2 y values are the same for mode, then let type=right. In the end the new data frame is: mode time id y type 1 right0 p1 3 left 2 left0 p1 5 left 3 right1 p1 4 left 4 left1 p1 4 left 5 right2 p1 4 left 6 left2 p1 4 left 7 right0 p2 6 right 8 left0 p2 2 right 9 right1 p2 3 right 10 left1 p2 3 right 11 right2 p2 3 right 12 left2 p2 3 right 13 right0 p3 4 right 14 left0 p3 4 right 15 right1 p3 2 right 16 left1 p3 2 right 17 right2 p3 2 right 18 left2 p3 2 right Any suggestions would be appreciated. John [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cleaning up a vector
Mike, Small, reproducible examples are always useful for the rest of the us. x - c(0, NA, NaN, 1 , 10, 20, 21, Inf) x[!is.na(x) x =1 x= 20] Is that what you're looking for? mlar...@rsmas.miami.edu wrote: I calculated a large vector. Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous. I ended up wih some Infs and NaNs in the vector. I would like to filter out the Inf and NaN values and only keep the values in my vector that range from 1 to 20. Is there a way to filter out Infs and NaNs in R and end up with a clean vector? Mike __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cleaning up a vector
On Fri, Oct 1, 2010 at 10:51 AM, mlar...@rsmas.miami.edu wrote: I calculated a large vector. Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous. I ended up wih some Infs and NaNs in the vector. I would like to filter out the Inf and NaN values and only keep the values in my vector that range from 1 to 20. Is there a way to filter out Infs and NaNs in R and end up with a clean vector? Two steps, starting from vector x x1 = x[is.finite(x)]; x2 = x1[(x1 = 20) (x1 = 1)]; From what you say, x2 is the result you want. Just be aware that dropping values will change the indexing. Peter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to Install R Commander?
Reinstall R and select the option for tcltk support in the installer. Uwe Ligges On 01.10.2010 19:42, kreamysaverz wrote: Hi, I am trying to install R commander. I used the command: install.packages(Rcmdr, dependencies = TRUE) It gives me this: Warning in install.packages(Rcmdr, dependencies = TRUE) : argument 'lib' is missing: using 'C:\Users\Karimi\Documents/R/win-library/2.11' trying URL 'http://cran.opensourceresources.org/bin/windows/contrib/2.11/Rcmdr_1.6-0.zip' Content type 'application/zip' length 2636395 bytes (2.5 Mb) opened URL downloaded 2.5 Mb package 'Rcmdr' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Users\Karimi\AppData\Local\Temp\RtmpJPbedc\downloaded_packages then I type: library(Rcmdr) Loading required package: tcltk Loading Tcl/Tk interface ...Error : .onLoad failed in loadNamespace() for 'tcltk', details: call: NULL error: Tcl/Tk support files were not installed Error: package 'tcltk' could not be loaded I tried installing tcltk but I could not do it :( It wouldn't let me. Help please??? Thanks :) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cleaning up a vector
On Oct 1, 2010, at 12:51 PM, mlar...@rsmas.miami.edu wrote: I calculated a large vector. Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous. I ended up wih some Infs and NaNs in the vector. I would like to filter out the Inf and NaN values and only keep the values in my vector that range from 1 to 20. Is there a way to filter out Infs and NaNs in R and end up with a clean vector? Mike set.seed(1) x - sample(c(0:25, NaN, Inf, -Inf), 50, replace = TRUE) x [1]7 10 16 NaN5 NaN Inf 19 18155 19 [14] 11 22 14 20 -Inf 11 22 Inf6 1837 11 [27]0 11 259 13 17 145 23 19 233 20 [40] 11 23 18 22 16 15 220 13 21 20 x[is.finite(x) x = 1 x = 20] [1] 7 10 16 5 19 18 1 5 5 19 11 14 20 11 6 18 3 7 11 11 9 13 [23] 17 14 5 19 3 20 11 18 16 15 13 20 See ?is.finite HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cleaning up a vector
Complementing: findInterval(x[is.finite(x)], 1:20) On Fri, Oct 1, 2010 at 2:55 PM, Henrique Dallazuanna www...@gmail.comwrote: Try this: x[is.finite(x)] On Fri, Oct 1, 2010 at 2:51 PM, mlar...@rsmas.miami.edu wrote: I calculated a large vector. Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous. I ended up wih some Infs and NaNs in the vector. I would like to filter out the Inf and NaN values and only keep the values in my vector that range from 1 to 20. Is there a way to filter out Infs and NaNs in R and end up with a clean vector? Mike __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] add a new column to data frame
Thank you Phil. The only problem with the code is when the 2 y values are equal, it should default to right. Your code would default to the first maximum. But it's ok, I see the logic here and can figure it out. I wondered whether there is some one-line thing that can do this, I guess not possible. Thank you John From: Phil Spector spec...@stat.berkeley.edu Cc: r-help@r-project.org Sent: Fri, October 1, 2010 10:58:55 AM Subject: Re: [R] add a new column to data frame Here are two ways: dat0 = subset(dat,time==0) one = as.data.frame(as.table(by(dat0,dat0$id, function(x)as.character(x$mode)[which.max(x$y)]))) names(one) = c('id','type') merge(dat,one) two = sapply(split(dat0,dat0$id), function(x)as.character(x$mode)[which.max(x$y)]) merge(dat,data.frame(id=names(two),type=two)) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Fri, 1 Oct 2010, array chip wrote: Hi, I am wondering if anyone can propose a simple/best way to do the following: Let's say I have a data frame dat - cbind(expand.grid(mode=c('right','left'),time=0:3,id=c('p1','p2','p3')),y=c(3,5,rep(4,6),6,2,rep(3,6),4,4,rep(2,6))) ) dat mode time id y 1 right0 p1 3 2 left0 p1 5 3 right1 p1 4 4 left1 p1 4 5 right2 p1 4 6 left2 p1 4 7 right0 p2 6 8 left0 p2 2 9 right1 p2 3 10 left1 p2 3 11 right2 p2 3 12 left2 p2 3 13 right0 p3 4 14 left0 p3 4 15 right1 p3 2 16 left1 p3 2 17 right2 p3 2 18 left2 p3 2 Now I want to add a new column type to this data frame with values of either left or right for each id based on the following logic: For each id, the value of type column is the value of mode for which the value of y is the maximum of y based on time=0. For example for id=p1, the value of type is left because for the 2 y values (3 5) based on time=0, mode=left has the bigger y value (5). But if the 2 y values are the same for mode, then let type=right. In the end the new data frame is: mode time id y type 1 right0 p1 3 left 2 left0 p1 5 left 3 right1 p1 4 left 4 left1 p1 4 left 5 right2 p1 4 left 6 left2 p1 4 left 7 right0 p2 6 right 8 left0 p2 2 right 9 right1 p2 3 right 10 left1 p2 3 right 11 right2 p2 3 right 12 left2 p2 3 right 13 right0 p3 4 right 14 left0 p3 4 right 15 right1 p3 2 right 16 left1 p3 2 right 17 right2 p3 2 right 18 left2 p3 2 right Any suggestions would be appreciated. John [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [Fwd: Re: cleaning up a vector]
It turns out I didn't have to filter out the 1-20 values. The code of x[is.finite(x)] did the trick. Thanks!!! Mike Original Message Subject: Re: [R] cleaning up a vector From:Henrique Dallazuanna www...@gmail.com Date:Fri, October 1, 2010 1:55 pm To: mlar...@rsmas.miami.edu Cc: r-help@r-project.org -- Try this: x[is.finite(x)] On Fri, Oct 1, 2010 at 2:51 PM, mlar...@rsmas.miami.edu wrote: I calculated a large vector. Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous. I ended up wih some Infs and NaNs in the vector. I would like to filter out the Inf and NaN values and only keep the values in my vector that range from 1 to 20. Is there a way to filter out Infs and NaNs in R and end up with a clean vector? Mike __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O Try this: x[is.finite(x)] On Fri, Oct 1, 2010 at 2:51 PM, [1]mlar...@rsmas.miami.edu wrote: I calculated a large vector. Unfortunately, I have some measurement error in my data and some of the values in the vector are erroneous. I ended up wih some Infs and NaNs in the vector. I would like to filter out the Inf and NaN values and only keep the values in my vector that range from 1 to 20. Is there a way to filter out Infs and NaNs in R and end up with a clean vector? Mike __ [2]r-h...@r-project.org mailing list [3]https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide [4]http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O References 1. mailto:mlar...@rsmas.miami.edu 2. mailto:R-help@r-project.org 3. https://stat.ethz.ch/mailman/listinfo/r-help 4. http://www.R-project.org/posting-guide.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to avoid NaN in optim()
You do not have to worry about re-defining your function to handle the constraints on parameters. You can let the optimizer worry about it. lik - function(nO, nA, nB, nAB){ loglik - function(par) { p=par[1] q=par[2] r - 1 - p - q -(2 * nO * log (r) + nA * log (p^2 + 2 * p * r) + nB * log (q^2 + 2 * q * r) + nAB * (log(2) +log(p) +log(q))) } } library(BB) # constraints: x[1] 0; x[2] 0; x[1] + x[2] 1 Amat - matrix(c(1,0,0,1,-1,-1), 3, 2, byrow=TRUE) b - c(0, 0, -1) c1 - runif(1) p0 - c(c1, max(0.01, 0.99-c1)) spg(p0, lik ( 176,182,60,17) , project=projectLinear, projectArgs=list(A=Amat, b=b, meq=0)) Hope this helps, Ravi. -Original Message- From: Ravi Varadhan [mailto:rvarad...@jhmi.edu] Sent: Thursday, September 30, 2010 3:09 PM To: Ravi Varadhan Cc: arindam fadikar; r-help@r-project.org Subject: Re: [R] how to avoid NaN in optim() Here is how you do it: library(BB) Amat - matrix(c(1,0,0,1,-1,-1), 3, 2, byrow=TRUE) b - c(0, 0, -1) p0 - c(0.5, 0.4) spg(p0, lik ( 176,182 , 60 ,17) , project=projectLinear, projectArgs=list(A=Amat, b=b, meq=0)) Hope this helps, Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Ravi Varadhan rvarad...@jhmi.edu Date: Thursday, September 30, 2010 3:04 pm Subject: Re: [R] how to avoid NaN in optim() To: Ravi Varadhan rvarad...@jhmi.edu Cc: arindam fadikar arindam.fadi...@gmail.com, r-help@r-project.org You also need the constrain that par[1] + par[2] 1 in order to avoid NaNs. You can do this using the `projectLinear' argument in `spg'. library(BB) ?spg Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: Ravi Varadhan rvarad...@jhmi.edu Date: Thursday, September 30, 2010 2:54 pm Subject: Re: [R] how to avoid NaN in optim() To: arindam fadikar arindam.fadi...@gmail.com Cc: r-help@r-project.org Change the `else NA' to `else Inf' in your loglik function and then run the following: library(BB) p0 - runif(2) spg(p0, lik (176,182 , 60 ,17) , lower=0, upper=1) This will give you correct results. Ravi. Ravi Varadhan, Ph.D. Assistant Professor, Division of Geriatric Medicine and Gerontology School of Medicine Johns Hopkins University Ph. (410) 502-2619 email: rvarad...@jhmi.edu - Original Message - From: arindam fadikar arindam.fadi...@gmail.com Date: Thursday, September 30, 2010 2:17 pm Subject: [R] how to avoid NaN in optim() To: r-help@r-project.org hi , lik - function(nO, nA, nB, nAB){ loglik - function(par) { p=par[1] q=par[2] r - 1 - p - q if (c(p,q,r) rep(0,3) c(p,q,r) rep(1,3) ) { -(2 * nO * log (r) + nA * log (p^2 + 2 * p * r) + nB * log (q^2 + 2 * q * r) + nAB * (log(2) +log(p) +log(q))) } else NA } loglik } i want to maximize this likelihood function over the range (0,0,0) to (1,1,1). so i tried optim ( c(0.3,0.3), lik ( 176,182 , 60 ,17) , method = CG) and obtained the following : optim(c(0.3,0.3), fn, method=CG) $par [1] 0.26444187 0.09316946 $value [1] 492.5353 $counts function gradient 130 19 $convergence [1] 0 $message NULL Warning messages: 1: In log(q^2 + 2 * q * r) : NaNs produced 2: In log(q) : NaNs produced 3: In log(q^2 + 2 * q * r) : NaNs produced 4: In log(q) : NaNs produced please help ... -- Arindam Fadikar M.Stat Indian Statistical Institute. New Delhi, India [[alternative HTML version deleted]] __ R-help@r-project.org mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list PLEASE do read the posting guide and
Re: [R] add a new column to data frame
Try this: merge(dat, factor(with(dat[!dat$time,], tapply(y, id, function(x)ifelse(all(mean(x) == x), 1, which.max(x, labels = c('right', 'left')), by.x = 'id', by.y = 0) On Fri, Oct 1, 2010 at 3:15 PM, array chip arrayprof...@yahoo.com wrote: Thank you Phil. The only problem with the code is when the 2 y values are equal, it should default to right. Your code would default to the first maximum. But it's ok, I see the logic here and can figure it out. I wondered whether there is some one-line thing that can do this, I guess not possible. Thank you John From: Phil Spector spec...@stat.berkeley.edu Cc: r-help@r-project.org Sent: Fri, October 1, 2010 10:58:55 AM Subject: Re: [R] add a new column to data frame Here are two ways: dat0 = subset(dat,time==0) one = as.data.frame(as.table(by(dat0,dat0$id, function(x)as.character(x$mode)[which.max(x$y)]))) names(one) = c('id','type') merge(dat,one) two = sapply(split(dat0,dat0$id), function(x)as.character(x$mode)[which.max(x$y)]) merge(dat,data.frame(id=names(two),type=two)) - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Fri, 1 Oct 2010, array chip wrote: Hi, I am wondering if anyone can propose a simple/best way to do the following: Let's say I have a data frame dat - cbind(expand.grid(mode=c('right','left'),time=0:3,id=c('p1','p2','p3')),y=c(3,5,rep(4,6),6,2,rep(3,6),4,4,rep(2,6))) ) dat mode time id y 1 right0 p1 3 2 left0 p1 5 3 right1 p1 4 4 left1 p1 4 5 right2 p1 4 6 left2 p1 4 7 right0 p2 6 8 left0 p2 2 9 right1 p2 3 10 left1 p2 3 11 right2 p2 3 12 left2 p2 3 13 right0 p3 4 14 left0 p3 4 15 right1 p3 2 16 left1 p3 2 17 right2 p3 2 18 left2 p3 2 Now I want to add a new column type to this data frame with values of either left or right for each id based on the following logic: For each id, the value of type column is the value of mode for which the value of y is the maximum of y based on time=0. For example for id=p1, the value of type is left because for the 2 y values (3 5) based on time=0, mode=left has the bigger y value (5). But if the 2 y values are the same for mode, then let type=right. In the end the new data frame is: mode time id y type 1 right0 p1 3 left 2 left0 p1 5 left 3 right1 p1 4 left 4 left1 p1 4 left 5 right2 p1 4 left 6 left2 p1 4 left 7 right0 p2 6 right 8 left0 p2 2 right 9 right1 p2 3 right 10 left1 p2 3 right 11 right2 p2 3 right 12 left2 p2 3 right 13 right0 p3 4 right 14 left0 p3 4 right 15 right1 p3 2 right 16 left1 p3 2 right 17 right2 p3 2 right 18 left2 p3 2 right Any suggestions would be appreciated. John [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Small p-value good or bad?
T. Smithson pillepop2003 at yahoo.de writes: Dear R-community, I have a short question: How do I interpret the result of a likelihood ratio test correctly? I am fitting a parametric survival model (with aftreg {eha}) and the output tells me the overall p-value of my model is 0.001. My simple question is: Does the result mean my model fits the data well OR does it mean my model DOES NOT fit the data well? Some side information how the p-value is calculated: logtest - -2 * (x$loglik[1] - x$loglik[2]) pvalue - 1-pchisq(logtest,df) with x$loglik[1] = -274 x$loglik[2] = -235 df = 25 I know the answer would probably be read the manual but I found different opinions on the web and want to make sure I am interpreting it correctly. Well, the problem is the lack of context. What TFM says about 'loglik' is: loglik: Vector of length two; first component is the value at the initial parameter values, the second componet is the maximized value. The test being done here is asking whether the -2*L (deviance) is significantly lower (corresponding to an improvement in model fit) for the fitted parameters (maximized likelihood, or minimized deviance) than for the initial parameter values. The problem is that I don't know without looking farther what the initial parameters correspond to. **If** aftreg starts from a set of parameter values that correspond to a simpler/nested model (e.g. all parameters for the effects of covariates set to zero), *then* this p-value represents a p-value for the null hypothesis that the fitted model is not a better fit to the data than the simpler/nested model, in which case a small p-value would allow you to reject the null hypothesis that the effects of all covariates are equal to zero. In this case, the df should correspond to the increase in the number of parameters required to fit the more complex model. However, this is just guessing on the basis of a fairly standard procedure for this sort of test. If this is indeed the context, then the procedure is not giving you any information about whether the model fits the data well (i.e., a goodness-of-fit test): it is telling you that the more complex model fits the data *better* than the simpler model. If there are a variety of opinions on the web, by definition either some of them are wrong *or* they are describing different contexts (more likely). __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Pass Arguments to R with an LSF submit
I'm trying to run R in batch mode on an LSF managed cluster. In simple settings, I can do it just fine. The trouble I'm having is when I try to pass arguments to the batch job. For example, bsub R CMD BATCH --args 1 3 commandfile.R LSF doesn't like the , and it doesn't run. I'm hoping one you can help me submit a job to an LSF cluster that allows me to pass arguments to R. Thank you, -tgs [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] gridExtra question
Hi: I get a couple of warnings when trying to download gridExtra: install.packages(gridExtra,repos=http://R-Forge.R-project.org) Warning: unable to access index for repository http://R-Forge.R-project.org/bin/windows/contrib/2.10 Warning message: In getDependencies(pkgs, dependencies, available, lib) : package ‘gridextra’ is not available I would like to download the binary for windows Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gridExtra question
Well, a quick check of http://r-forge.r-project.org/bin/windows/contrib/ shows that there is no 2.10 directory, possibly because it's not very new, 2.12 is scheduled for release in 2 weeks. Felipe Carrillo wrote: Hi: I get a couple of warnings when trying to download gridExtra: install.packages(gridExtra,repos=http://R-Forge.R-project.org) Warning: unable to access index for repository http://R-Forge.R-project.org/bin/windows/contrib/2.10 Warning message: In getDependencies(pkgs, dependencies, available, lib) : package ‘gridextra’ is not available I would like to download the binary for windows Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gridExtra question
Forgot to mention you should be able to install from a CRAN mirror. Felipe Carrillo wrote: Hi: I get a couple of warnings when trying to download gridExtra: install.packages(gridExtra,repos=http://R-Forge.R-project.org) Warning: unable to access index for repository http://R-Forge.R-project.org/bin/windows/contrib/2.10 Warning message: In getDependencies(pkgs, dependencies, available, lib) : package ‘gridextra’ is not available I would like to download the binary for windows Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gridExtra question
Is there some reason you don't want the CRAN version? -Ista On Fri, Oct 1, 2010 at 3:08 PM, Felipe Carrillo mazatlanmex...@yahoo.comwrote: Hi: I get a couple of warnings when trying to download gridExtra: install.packages(gridExtra,repos=http://R-Forge.R-project.org) Warning: unable to access index for repository http://R-Forge.R-project.org/bin/windows/contrib/2.10 Warning message: In getDependencies(pkgs, dependencies, available, lib) : package gridextra is not available I would like to download the binary for windows Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gridExtra question
I must be blind, CRAN was my first try and didn't see it there. It is Friday and time to take a break I guess :-)  Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA From: Ista Zahn iz...@psych.rochester.edu To: Felipe Carrillo mazatlanmex...@yahoo.com Cc: r-h...@stat.math.ethz.ch Sent: Fri, October 1, 2010 12:22:22 PM Subject: Re: [R] gridExtra question Is there some reason you don't want the CRAN version? -Ista On Fri, Oct 1, 2010 at 3:08 PM, Felipe Carrillo mazatlanmex...@yahoo.com wrote:  Hi: I get a couple of warnings when trying to download gridExtra: install.packages(gridExtra,repos=http://R-Forge.R-project.org)  Warning: unable to access index for repository http://R-Forge.R-project.org/bin/windows/contrib/2.10 Warning message: In getDependencies(pkgs, dependencies, available, lib) :  package âgridextraâ is not available I would like to download the binary for windows Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] mhtplot?
Mohsen Jafarikia jafarikia at gmail.com writes: I was wondering why many plot options are not working with mhtplot. I could not find much info about this function on the web too. Any comments, any detailed manual ... I'm afraid this one gets the usual answers: 1. what does not work mean? (Please read the posting guide referenced at the bottom of every r-help message.) 2. install.packages(sos) library(sos) findFn(mhtplot) Once you have exhausted those options, 3. library(gap) ## you didn't tell us which package 'mhtplot' is in maintainer(gap) good luck, Ben Bolker __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Contrasts for MANOVA
Can anyone tell me how to run contrasts for MANOVA? Thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpreting the example given by Frank Harrell in the predict.lrm {Design} help
I have this discussion fairly often with doctors that I work with. The issue is that you can certainly predict from a model, but you can predict on different scales. Let's consider the simpler case of just 2 outcomes (disease yes/no): Let's say you have 4 patients that you want to predict their disease status using their symptoms and a model, on the probability scale patient A is predicted to have 5% chance of yes, patient B is 49%, patient C is 51% and patient D is 95% probability of yes. If we collapse this to just a prediction of yes/no then that means that we will treat A and B the same with a prediction of NO and patients C and D the same with a prediction of YES. But does it really make sense to treat B and C so differently (they are only 2 percentage points different) while treating them the same as A or D? If I were one of the patients I would want to know whether my probability of disease was 51% or 95%, not just a yes. With 3 groups wouldn't you want to know the difference between 33%, 33%, 34% and 2%, 8%, 90%? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of peterfran...@me.com Sent: Friday, October 01, 2010 8:23 AM To: Frank Harrell Cc: r-help@r-project.org Subject: Re: [R] Interpreting the example given by Frank Harrell in the predict.lrm {Design} help The reason I am trying to assign them is because I have a data set where i have arrived at the most likely model that describes the data and now I have another dataset where I know the factors but not the response. Therefore, surely I need to assign the predicted values to a response in order to say something like: Based on the model I believe unknown 1 is good, where as unknown 2 is very good etc? Maybe I am missing something or using the wrong approach but I thought the main purpose of using the predict function on new data was to predict the response? Peter On 1 Oct 2010, at 14:51, Frank Harrell f.harr...@vanderbilt.edu wrote: Why assign them at all? Is this a forced choice at gunpoint problem? Remember what probabilities mean. Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Interpreting-the-example-given-by-Frank- Harrell-in-the-predict-lrm-Design-help-tp2883311p2909713.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] gridExtra question
It looks like the list of packages is not refreshing on my pc because If I go to packages install packages I don't see it there next to 'gridBase' but I went to the CRAN website and there it is right next to 'gridBase'. I had to manually download the Windows binary from there, saved it to my desktop and then installed packages from local zip files Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA - Original Message From: Erik Iverson er...@ccbr.umn.edu To: Felipe Carrillo mazatlanmex...@yahoo.com Cc: r-h...@stat.math.ethz.ch Sent: Fri, October 1, 2010 12:19:42 PM Subject: Re: [R] gridExtra question Forgot to mention you should be able to install from a CRAN mirror. Felipe Carrillo wrote: Hi: I get a couple of warnings when trying to download gridExtra: install.packages(gridExtra,repos=http://R-Forge.R-project.org) Warning: unable to access index for repository http://R-Forge.R-project.org/bin/windows/contrib/2.10 Warning message: In getDependencies(pkgs, dependencies, available, lib) : package ‘gridextra’ is not available I would like to download the binary for windows Felipe D. Carrillo Supervisory Fishery Biologist Department of the Interior US Fish Wildlife Service California, USA __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to apply vector value function to a multidimensional array indexed by the remaining dimensions?
Hi, I am looking for some generalization of colSums and rowSums for general vector valued functions, and for arrays of more than 2 dimensions. So as a concrete example, suppose I have a 3 dimensional array, given by x = array(1:100,c(3,4,5)). and I want to sum the 3rd index of x to obain a 3 by 4 matrix. Using rowSums would return a vector of length 3 because it treats the last two indices as a single index. Besides summation, let's say if I define a vector valued function f-function(x){min(x[1],min(x[2],x[3]))}, and I want to apply f to the last index of x, meaning for each 1= i = 3, 1=j =4, I want to compute f(x[i,j,]), and then put them in a 3 by 4 matrix. How would I be able to do that without using a for loop? thanks. Sincerely, John -- View this message in context: http://r.789695.n4.nabble.com/How-to-apply-vector-value-function-to-a-multidimensional-array-indexed-by-the-remaining-dimensions-tp2937368p2937368.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to generate scatterplot - with a twist
Hi. I would like to make a scatterplot where all of the points are evenly spaced from each other - however, they are all the same size and occupy the entire graph. For example: x = rep(c(1:10), 10) y = rep(c(10:1), each = 10) plot(x, y, pch = 0) Gives me a scatter plot with 100 square points each evenly spaced between each other. But these points don't fill up the entire space and if I try to change the 'cex' value, the points on the edges get messed up. I was wondering if there was a way to fill up the entire space (all of the edges of the little squares are touching each other) and each individual square is the same size. Any help will be greatly appreciated! -- View this message in context: http://r.789695.n4.nabble.com/How-to-generate-scatterplot-with-a-twist-tp2923805p2923805.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [Help]:How to use loop to achieve this aim?
It doesn't work... where should change? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Help-How-to-use-loop-to-achieve-this-aim-tp2819894p2922193.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] writing an R code for a given model
Dear R help list, I am desperately looking for any reference explaining by examples how to write R codes in order to fit the parameters of a given model using maximum likelihood or any other criteria function. I know the general structure: First write a code for the maximum likelihood function and afterwards write a code to maximize it using optim and then invert the Hessian to get the standard errors and p-values. What I want is to find a document which gives in detail the R code to do so for some given examples such as linear mixed effect models, survival analysis etc ... where the likelihood has a closed form and when it doesn't have a closed form ... I will then follow the same structure to fit my own model. Best wishes, Abderrahim [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] writing an R code for a given model
Hi Abderrahim, I find this book particularly helpful: http://www.meb.ki.se/~yudpaw/likelihood/likelihood-index.htm Shige On Fri, Oct 1, 2010 at 12:15 PM, abderrahim youssef abderrahim1...@googlemail.com wrote: Dear R help list, I am desperately looking for any reference explaining by examples how to write R codes in order to fit the parameters of a given model using maximum likelihood or any other criteria function. I know the general structure: First write a code for the maximum likelihood function and afterwards write a code to maximize it using optim and then invert the Hessian to get the standard errors and p-values. What I want is to find a document which gives in detail the R code to do so for some given examples such as linear mixed effect models, survival analysis etc ... where the likelihood has a closed form and when it doesn't have a closed form ... I will then follow the same structure to fit my own model. Best wishes, Abderrahim [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] [Help]:How to use loop to achieve this aim?
Correcting Karena's solution: for(i in 1:22) { chrn - paste(chr,i,sep=) chrn=MEDIPS.readAlignedSeqences(BSgenome=hg19, file=chrn,numrows= ?) # no quotes around chrn chrn=MEDIPS.genomeVector(data=chrn, bin_size=50,extend=250) frames=? # I don't know how you get this variable ... out_file - paste(frames.chr, i, .meth.txt, sep=) # dynamic file name write.table(frames, file=out_file, sep=\t, quote=F, col.names=T, row.names=F) # use var you just made } Replace the ???s. Jeff. On Fri, Oct 1, 2010 at 11:27 AM, qcshare qcsh...@gmail.com wrote: It doesn't work... where should change? Thanks. -- View this message in context: http://r.789695.n4.nabble.com/Help-How-to-use-loop-to-achieve-this-aim-tp2819894p2922193.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to generate scatterplot - with a twist
On Oct 1, 2010, at 10:41 AM, thernubblet wrote: Hi. I would like to make a scatterplot where all of the points are evenly spaced from each other - however, they are all the same size and occupy the entire graph. For example: x = rep(c(1:10), 10) y = rep(c(10:1), each = 10) plot(x, y, pch = 0) Gives me a scatter plot with 100 square points each evenly spaced between each other. But these points don't fill up the entire space and if I try to change the 'cex' value, the points on the edges get messed up. I was wondering if there was a way to fill up the entire space (all of the edges of the little squares are touching each other) and each individual square is the same size. Any help will be greatly appreciated! Is this along the lines of what you might be looking for: x - 0.5:10.5 y - 0.5:10.5 plot(x, y, type = n, xaxs = i, yaxs = i) grid(10, 10, lty = solid, col = black) You can get the same effect (intersecting horizontal and vertical lines) by using ?abline and setting 'h' and 'v' to the values that you require: x - 0.5:10.5 y - 0.5:10.5 plot(x, y, type = n, xaxs = i, yaxs = i) abline(v = 0.5:10.5) abline(h = 0.5:10.5) See ?grid and also look at 'xaxs' in ?par. You can also add additional content to the existing plot by then using functions such as ?points, ?lines, ?segments, etc. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] can I add line breaks to the paste() function?
Thanks for the help. This solves my problem - I wanted to print out errors and warnings on separate lines with a single call. Thanks, David On Thu, Sep 30, 2010 at 3:42 PM, Jeremy Miles jeremy.mi...@gmail.com wrote: Try using cat instead. Then \n is the new line character. E.g. cat(1st line\n2nd line\n) Jeremy On 30 September 2010 13:30, David LeBauer dleba...@gmail.com wrote: Can I add a line break to the paste() function to return the following: 'this is the first line' 'this is the second line' instead of 'this is the first line this is the second line' ? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jeremy Miles Psychology Research Methods Wiki: www.researchmethodsinpsychology.com -- David LeBauer, PhD Energy Biosciences Institute University of Illinois Urbana-Champaign 1206 W. Gregory Drive Urbana, IL 61801, U.S.A. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] maximum likelihood problem
I am trying to figure out how to run maximum likelihood in R. Here is my situation: I have the following equation: equation-(1/LR-(exp(-k*T)*LM)*(1-exp(-k))) LR, T, and LM are vectors of data. I want to R to change the value of k to maximize the value of equation. My attempts at optim and optimize have been unsuccessful. Are these the recommended functions that I should use to maximize my equation? With optim I wanted the function to be maximized so I had to make the fnscale negative. Here is what I put: L-optim(k,equation,control=(fnscale=-1)) My result: Error: could not find function fn Here is what I put for optimize: L-optimise(equation,k,maximum=TRUE) My result: Error: 'xmin' not less than 'xmax' Any advise would be greatly appreciated. Mike __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to generate scatterplot - with a twist
If it is important to have points rather than just create the grid, then you could do something using the my.symbols function in the TeachingDemos package. One of the examples on the help page fills the plot with hexagons, the calculations for squares should be simpler. -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- project.org] On Behalf Of thernubblet Sent: Friday, October 01, 2010 9:41 AM To: r-help@r-project.org Subject: [R] How to generate scatterplot - with a twist Hi. I would like to make a scatterplot where all of the points are evenly spaced from each other - however, they are all the same size and occupy the entire graph. For example: x = rep(c(1:10), 10) y = rep(c(10:1), each = 10) plot(x, y, pch = 0) Gives me a scatter plot with 100 square points each evenly spaced between each other. But these points don't fill up the entire space and if I try to change the 'cex' value, the points on the edges get messed up. I was wondering if there was a way to fill up the entire space (all of the edges of the little squares are touching each other) and each individual square is the same size. Any help will be greatly appreciated! -- View this message in context: http://r.789695.n4.nabble.com/How-to- generate-scatterplot-with-a-twist-tp2923805p2923805.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting- guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] maximum likelihood problem
Do you want to do a nonlinear least-squares estimation (which is MLE if the errors are Gaussian)? If so, you have to define a function that takes the parameter (k) and data matrix (LR, T, LM), as arguments, and returns a scalar, which is the residual sum of squares. Then you can optimize (minimize) that function. Ravi. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of mlar...@rsmas.miami.edu Sent: Friday, October 01, 2010 4:40 PM To: r-help@r-project.org Subject: [R] maximum likelihood problem I am trying to figure out how to run maximum likelihood in R. Here is my situation: I have the following equation: equation-(1/LR-(exp(-k*T)*LM)*(1-exp(-k))) LR, T, and LM are vectors of data. I want to R to change the value of k to maximize the value of equation. My attempts at optim and optimize have been unsuccessful. Are these the recommended functions that I should use to maximize my equation? With optim I wanted the function to be maximized so I had to make the fnscale negative. Here is what I put: L-optim(k,equation,control=(fnscale=-1)) My result: Error: could not find function fn Here is what I put for optimize: L-optimise(equation,k,maximum=TRUE) My result: Error: 'xmin' not less than 'xmax' Any advise would be greatly appreciated. Mike __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] ff version 2.2.0
Dear R community, The next release of package ff is available on CRAN. With kind help of Brian Ripley it now supports the Win64 and Sun versions of R. It has three major functional enhancements: a) new fast in-memory sorting and ordering functions (single-threaded) b) ff now supports on-disk sorting and ordering of ff vectors and ffdf dataframes c) ff integer vectors now can be used as subscripts of ff vectors and ffdf dataframes a) is achieved by careful implementation of NA-handling and exploiting context information b) although permanently stored, sorting and ordering of ff objects can be faster than the standard routines in R c) applying an order to ff vectors and ffdf dataframes is substantially slower than in pure R because it involves disk-access AND sorting index positions (to avoid random access). There is still room for improvement, however, the current status should already be useful. I run some comparisons with SAS (see end of mail): - both could sort German census size (81e6 rows) on a 3GB notebook - ff sorts and orders faster on single columns - sorting big multicolumn-tables is faster in SAS Win64 binaries and version 2.2.1 supporting Sun should appear during the next days on CRAN. For the impatient: checkout from r-forge with revision 67 or higher. Non-Windows users: please note that you need to set appropriate values for options 'ffbatchbytes' and 'ffmaxbytes' yourself. Note that virtual window support is deprecated now because it leads to too complex code. Let us know if you urgently need this and why. Feedback, ideas and contributions appreciated. To those who offered code during the last months: please forgive us that integrating and documenting was not possible with this release. Jens Daniel P.S. NEWS CHANGES IN ff VERSION 2.2.0 NEW FEATURES o ff now supports the 64 bit Windows and Sun versions of R (thanks to Brian Ripley) o ff now supports sorting and ordering of ff vectors and dataframes (see ramsort, ffsort, ffdfsort, ramorder, fforder, ffdforder) o ff now supports ff vectors as subscripts of ff objects (currently positive integers only, booleans are planned) o New option 'ffmaxbytes' which allows certain ff procedures like sorting using larger limit of RAM than 'ffbatchbytes' in chunked processing. Such higher limit is useful for (single-R-process) sorting compared to some multi-R-process chunked processing. It is a good idea to reduce 'ffmaxbytes' on slaves or avoid ff sorting there completely. o New generic 'pagesize' with method 'pagesize.ff' which returns the current pagesize as defined on opening the ff object. USER VISIBLE CHANGES o [.ff now returns with the same vmode as the ff-object o Certain operations are faster now because we worked around unnecessary copying triggered by many of R's assignment functions. For example reading a factor from a (well-cached) file is now 20% faster and thus as fast as just creating this factor in-RAM using levels()- and class()- assignments. (consider this tuning temporary, hoping for a generic fix in base R) o ff() can now open files larger than .Machine$integer.max elements (but gives access only to the first .Machine$integer.max elements) o ff now has default pattern NULL translating to the pattern in 'filename' (and only to the previous default 'ff' if no filename is given) o ff now sets the pattern in synch with a requested 'filename' o clone.ff now always creates a file consistent with the previous pattern o clone.ff now always creates a finalizer consistent with the file location o clone.ffdf has a new argument 'nrow' which allows to create an empty copy with a different number of rows (currently requires 'initdata=NULL') o clone.default now deep-copies lists and atomic vectors DEPRECATED o virtual window support is deprecated. Let us know if you urgently need this and why. BUG FIXES o read.table.ffdf now also works if transFUN filters and returns less rows BUG FIXES at 2.1.4 o [-.ffdf no longer does calculate the number of elements in an ffdf which could led to an integer overflow BUG FIXES at 2.1.3 o ffsafe now always closes ffdf objects - also partially closed ones o ffsafe no longer passes arguments 'add' and 'move' to 'save' o ffsafe and friends now work around the fact that under windows getwd() can report the same path in upper and lower case versions. CHANGES IN bit VERSION 1.1.5 NEW FEATURES o new utility functions setattr() and setattributes() allow to set attributes by reference (unlike attr()- attributes()- without copying the object) o new utility unattr() returns copy of input with attributes removed USER VISIBLE CHANGES o certain
Re: [R] writing an R code for a given model
Shige Song shigesong at gmail.com writes: Hi Abderrahim, I find this book particularly helpful: http://www.meb.ki.se/~yudpaw/likelihood/likelihood-index.htm Shige On Fri, Oct 1, 2010 at 12:15 PM, abderrahim youssef abderrahim1302 at googlemail.com wrote: Dear R help list, I am desperately looking for any reference explaining by examples how to write R codes in order to fit the parameters of a given model using maximum likelihood or any other criteria function. I know the general structure: First write a code for the maximum likelihood function and afterwards write a code to maximize it using optim and then invert the Hessian to get the standard errors and p-values. What I want is to find a document which gives in detail the R code to do so for some given examples such as linear mixed effect models, survival analysis etc ... where the likelihood has a closed form and when it doesn't have a closed form ... I will then follow the same structure to fit my own model. You could take a look at the examples for the mle function in the 'stats4' package; maxLik in the maxLik package; or mle2 in the 'bbmle' package ('bbmle' also has a vignette). For what it's worth, likelihood estimation for mixed effects models is non-trivial -- it involves either numerical integration or clever analytical reduction to find a good approximation or (in the case of linear mixed effect models) avoid the numerical integration altogether. Not where I would start. (Parametric) survival analysis should be easier. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plm: lag() and diff() do not (always) recognize a gap in the time dimension
Hello! I came accross a strange behavior of the plm package. When using an unbalanced panel with years lag() and diff() do not recognize a break in the time dimension. It does, however, if there is only one more year after the break. This is strange, right? Consider the following example: library(plm) Loading required package: kinship Loading required package: survival Loading required package: splines Loading required package: nlme Loading required package: lattice [1] kinship is loaded Loading required package: Formula Loading required package: MASS Loading required package: sandwich Loading required package: zoo dat.raw - data.frame(id=c(b, b,b, c,c,c, d,d,d,d, d,d,d), t=c(1980,1981,1983,1982,1983,1985,1984,1985,1988,1989,1993,1994,1995), y=c(1,2,3,2,4,5,6,5,6,7,-2,1,3)) dat.raw - pdata.frame(dat.raw, index=c(id, t), drop.index=FALSE) dat.raw$l1-lag(dat.raw$y,1) dat.raw$l2-diff(dat.raw$y,1) dat.raw idt y l1 l2 b-1980 b 1980 1 NA NA b-1981 b 1981 2 1 1 b-1983 b 1983 3 NA NA c-1982 c 1982 2 NA NA c-1983 c 1983 4 2 2 c-1985 c 1985 5 NA NA d-1984 d 1984 6 NA NA d-1985 d 1985 5 6 -1 d-1988 d 1988 6 5 1 d-1989 d 1989 7 6 1 d-1993 d 1993 -2 7 -9 d-1994 d 1994 1 -2 3 d-1995 d 1995 3 1 2 Why do the last two entries in the third and sixth rows indicate NA, while row 11 does not seem to recognize the gap? Would you have a solution to this problem for me? My dataset is huge and I cannot edit it manually. Thank you! Christian __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to apply vector value function to a multidimensional array indexed by the remaining dimensions?
On Fri, 1 Oct 2010, yunjiangster wrote: Hi, I am looking for some generalization of colSums and rowSums for general vector valued functions, and for arrays of more than 2 dimensions. So as a concrete example, suppose I have a 3 dimensional array, given by x = array(1:100,c(3,4,5)). and I want to sum the 3rd index of x to obain a 3 by 4 matrix. Using rowSums would return a vector of length 3 because it treats the last two indices as a single index. see the help page for colSums, esp. the 'dims' arg Besides summation, let's say if I define a vector valued function f-function(x){min(x[1],min(x[2],x[3]))}, and I want to apply f to the last index of x, meaning for each 1= i = 3, 1=j =4, I want to compute f(x[i,j,]), and then put them in a 3 by 4 matrix. How would I be able to do that without using a for loop? ?apply thanks. Sincerely, John -- View this message in context: http://r.789695.n4.nabble.com/How-to-apply-vector-value-function-to-a-multidimensional-array-indexed-by-the-remaining-dimensions-tp2937368p2937368.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Charles C. Berry(858) 534-2098 Dept of Family/Preventive Medicine E mailto:cbe...@tajo.ucsd.edu UC San Diego http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Interpreting the example given by Frank Harrell in the predict.lrm {Design} help
Well put Greg. The job of the statistician is to produce good estimates (probabilities in this case). Those cannot be translated into action without subject-specific utility functions. Classification during the analysis or publication stage is not necessary. Frank - Frank Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/Interpreting-the-example-given-by-Frank-Harrell-in-the-predict-lrm-Design-help-tp2883311p2951976.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How many R packages are not free?
Hello Everyone, Just finished reading A Handbook of Statistical Analyses using R by Everitt and Hothorn. I'll begin by saying that I quite liked the book. It's both little and mighty in the sense that it's very compact but contains a tremendous amount of useful material. The last chapter of the book deals with cluster analysis. There's a package used in this chapter (I believe that it's called mclust) that charges an annual fee to non-academics. I did a little digging and found out that the annual cost for some one like me would be $100 but it would cost more for people in large companies. This isn't exactly outrageous but got me to wondering how many other packages might not be free. I searched online but didn't find much. Does anyone have any information about this? Thanks, Paul [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] element wise conditional assignment in r
Hi, I am looking for a one-liner code for the following situation say I have a vector r of 0 and 1's, and another vector v of equal length. I want to assign v[i]-1 to v[i] if r[i]=1, for all i. How would I do that using mapply or any other batch processing keywords? thanks. John -- View this message in context: http://r.789695.n4.nabble.com/element-wise-conditional-assignment-in-r-tp2951963p2951963.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Suppressing printing in the function
Hello! I wrote a function that returns a data frame. Nowhere in the function do I say print(my.data.frame), but when I run the function - the data frame is printed on the console. Is there any way to suppress it? Thank you! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Suppressing printing in the function
?invisible - Phil Spector Statistical Computing Facility Department of Statistics UC Berkeley spec...@stat.berkeley.edu On Fri, 1 Oct 2010, Dimitri Liakhovitski wrote: Hello! I wrote a function that returns a data frame. Nowhere in the function do I say print(my.data.frame), but when I run the function - the data frame is printed on the console. Is there any way to suppress it? Thank you! -- Dimitri Liakhovitski Ninah Consulting www.ninah.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.