Re: [R] boxplot via plot command
Antje niederlein-rstat at yahoo.de writes: I've just discovered that the following code leads to boxplot (surprisingly to me). Can anybody explain to me why? Is this documented somewhere? I've never consider this option before. x - rnorm(300) l - c(rep(label1,100), rep(label2,50), rep(label3,150)) df - data.frame(as.factor(l), x) plot(df) Just to complete my response, the documentation for plot.data.frame indicates For a two-column data frame it plots the second column against the first by the most appropriate method for the first column. kk -- Ken Knoblauch Inserm U846 Institut Cellule Souche et Cerveau Département Neurosciences Intégratives 18 avenue du Doyen Lépine 69500 Bron France tel: +33 (0)4 72 91 34 77 fax: +33 (0)4 72 91 34 61 portable: +33 (0)6 84 10 64 10 http://www.sbri.fr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplot via plot command
Hi, thank you both for your response. I don't want to do anything like this - I just got some code like this from someone else and was wondering about the result. I would have used another approach to create a boxplot like this... Ciao, Antje [EMAIL PROTECTED] schrieb: hi: i'm not well versed in the OO mechanism behind R but you've created a dataframe with one column being factors so, when the plot command sees this, there must be code in the plot generic that decided that the best thing to use is a boxplot. I'm not sure what you want since you have 3 factors but below is a guess ? I split by the factor and then plot the values seperately with the colors denoting the factors ? if it's not what you want, then i would resend your question to the list explaining what you do want because there are others on this list that can probably help you more than i can. good luck. x - rnorm(300) l - c(rep(label1,100), rep(label2,50), rep(label3,150)) df - data.frame(l=as.factor(l), x) print(df) print(str(df)) temp - split(df,df$l) plot(temp[[1]]$x,ylim=c(min(temp[[1]]$x,temp[[2]]$x,temp[[3]]$x), max(temp[[1]]$x,temp[[2]]$x,temp[[3]]$x)),col=green) lines(temp[[2]]$x,type=p,col=blue) lines(temp[[3]]$x,type=p,col=red) On Tue, Dec 2, 2008 at 3:30 AM, Antje wrote: Hi folks, I've just discovered that the following code leads to boxplot (surprisingly to me). Can anybody explain to me why? Is this documented somewhere? I've never consider this option before. x - rnorm(300) l - c(rep(label1,100), rep(label2,50), rep(label3,150)) df - data.frame(as.factor(l), x) plot(df) Thank you! Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Projection Pursuit Classification
ArunPrasad wrote: Hi, Can anyone help me to understand why I am getting the error message like below? Tree.result - PP.Tree(LDA,iris[train,5],iris[train,1:4]) These are *Warning* messages rather than error messages. These warnings come from coding problems in the functions you are using (PP.Tree or those PP.Tree depends on), whatever PP.Tree() is Uwe Ligges Warning messages: 1: In if (LR.name != n.name) { : the condition has length 1 and only the first element will be used 2: In return(Alpha, C, IOindexL, IOindexR) : multi-argument returns are deprecated 3: In return(Tree.Struct, Alpha.Keep, C.Keep, rep, rep1, rep2) : multi-argument returns are deprecated 4: In if (LR.name != n.name) { : the condition has length 1 and only the first element will be used 5: In return(Alpha, C, IOindexL, IOindexR) : multi-argument returns are deprecated 6: In return(Tree.Struct, Alpha.Keep, C.Keep, rep, rep1, rep2) : multi-argument returns are deprecated 7: In return(Tree.Struct, Alpha.Keep, C.Keep, rep, rep1, rep2) : multi-argument returns are deprecated 8: In return(Tree.Struct, Alpha.Keep, C.Keep, rep, rep1, rep2) : multi-argument returns are deprecated 9: In return(Tree.Struct, Alpha.Keep, C.Keep, rep, rep1, rep2) : multi-argument returns are deprecated 10: In return(Tree.Struct, Alpha.Keep, C.Keep) : multi-argument returns are deprecated Thanks Arun __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rcmd build problem: gcc.exe no input files (R.2.8.0 on Win XP)
Building a package using R.2.8.0 on Windows XP gives problems when compiling C code: Trying to run 'rcmd build' on R.2.8.0 on Windows XP gives ... -- Making package gRbase adding build stamp to DESCRIPTION making DLL ... gcc -std=gnu99 -Ic:/Programs/R/current/include gcc.exe: no input files make[3]: *** [setops.o] Error 1 make[2]: *** [srcDynlib] Error 2 make[1]: *** [all] Error 2 make: *** [pkg-gRbase] Error 2 *** Installation of gRbase failed *** whereas running 'rcmd build' on R.2.7.1 I get ... -- Making package gRbase adding build stamp to DESCRIPTION making DLL ... gcc -std=gnu99 -Ic:/programs/R/prev/include -O3 -Wall -c setops.c -o setops.o gcc -std=gnu99 -Ic:/programs/R/prev/include -O3 -Wall -c triangmcwh.c -o triangmcwh.o windres --preprocessor=gcc -E -xc -DRC_INVOKED -I c:/programs/R/prev/include -i gRbase_res.rc -o gRbase_res.o gcc -std=gnu99 -shared -s -o gRbase.dll gRbase.def setops.o triangmcwh.o gRbase_res.o -Lc:/programs/R/prev/bin -Lc:/programs/R/prev/bin -lRlapack -Lc:/programs/R/prev/bin -lRblas -lgfortran-lR ... DLL made - so the old version works fine. Would anyone have an idea what goes wrong? Thanks Søren [[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] merge character strings
Hi, how can I do the following in R?: vec - c(a, b, c) magic. print(str) abc or even better: (a,b,c)? Cheers -- View this message in context: http://www.nabble.com/merge-character-strings-tp20790116p20790116.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] merge character strings
check at paste(), e.g., vec - c(a, b, c) paste(vec, collapse = ) I hope it helps. Best, Dimitris mentor_ wrote: Hi, how can I do the following in R?: vec - c(a, b, c) magic. print(str) abc Cheers -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Examples of advanced data visualization
Since SVG has a lot of elements, Firefox is still under development to support different elements in SVG; see: http://www.mozilla.org/projects/svg/status.html Currently animations won't work under Firefox 3.0.4, and all the rest can be viewed using Firefox 3.0.4. Regards, Yihui -- Yihui Xie [EMAIL PROTECTED] Phone: +86-(0)10-82509086 Fax: +86-(0)10-82509086 Mobile: +86-15810805877 Homepage: http://www.yihui.name School of Statistics, Room 1037, Mingde Main Building, Renmin University of China, Beijing, 100872, China On Mon, Dec 1, 2008 at 6:26 PM, Ted Harding [EMAIL PROTECTED] wrote: On 01-Dec-08 09:22:34, Gábor Csárdi wrote: On Mon, Dec 1, 2008 at 10:21 AM, Gábor Csárdi [EMAIL PROTECTED] wrote: On Mon, Dec 1, 2008 at 10:08 AM, Ted Harding [EMAIL PROTECTED] wrote: [...] I visited that URL (with the extra t!), and got a message from my browser (Iceweasel on Debian Etch, which is Firefox under another name) that additional plugins (unspecified) were needed to display the material. When I clicked on the Install Missing Plugins button, the result was No suitable plugins found Unknown Plugin (text/svg+xml) Any suggestions for further progress? Ted, what is your browser version? If 2.x, then I'm afraid that you'll have to upgrade to 3.x, or install Opera. Oooops, maybe I am wrong, see http://perlitist.com/articles/on-firefox2-and-svg Gabor Gabor With thanks, Ted. Hmm ... Interesting. Many thanks for the reasearches, Gabor. Yes, it is a 2.x version. That URL states: [...] So what was the cause of all this woe and despair? Well it all stemmed from the fact that I upgrades from 1.5 to 2, and in 1.5 I was using the Adobe SVG plugin which disables the built-in SVG rendering. Firefox 2 helpfully copied this setting, but not the plugin. For future reference svg.enabled in about:config needs to be true for the built-in SVG viewer to be used. I checked the status of svg.enabled in 'about.config', and I see that it is TRUE. Further, exploring my ~/.mozilla tree, I do not see any reference to an Adobe SVG plugin -- the only Adobe plugins are for Acrobat Reader and Flash Player. So there is a bit more to this than meets the eye. Maybe I should try to find a different source of SVG material, maybe less demanding than Hans Borchers's examples, to see whether the alleged built-in SVG capability really works anyway. Thanks again! Ted. E-Mail: (Ted Harding) [EMAIL PROTECTED] Fax-to-email: +44 (0)870 094 0861 Date: 01-Dec-08 Time: 10:26:23 -- 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with package Rwave
I would suggest sowas (Douglas Maraun) or wmtsa (Percival and Walden). I don't know for sure but both of these probably rely on Rwave. I like both of the packages mentioned it just depends on what you want to do- wmtsa will do DWT and CWT + a lot more, and sowas is for testing hypotheses and wavelet coherence. hope this helps Stephen On Mon, Dec 1, 2008 at 11:06 PM, [EMAIL PROTECTED] wrote: I am looking for some explanations about the usage of the poorely documented R paclkage Rwave. Has anyone ever tried out its functions for Wavelet Analysis ? Thank you so much. Maura Alice Messenger ;-) chatti anche con gli amici di Windows Live Messenger e tutti i telefonini TIM! Vai su http://maileservizi.alice.it/alice_messenger/index.html?pmk=footer [[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. -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem with tcl/tk and Rcmdr - urgent help required
Hello everyone, i have been searching the whole day, trying ANY solution offered by the internet and before headbanging against the wall would like to try asking for your help. As many others, i am haveing problems loading the Rcmdr package with Macbook running Tiger 10.4.11. X11 version updated to the last one after having manually installed. I have also installed (obviously) the Rcmdr package with all dependencies. However (damn) i keep having the following answer to the library (rcmdr) command: library (Rcmdr) Carico il pacchetto richiesto: tcltk Loading Tcl/Tk interface ... Error in dyn.load(file, DLLpath = DLLpath, ...) : impossibile caricare libreria condivisa '/Library/Frameworks/R.framework/Versions/2.8/Resources/library/tcltk/libs/i386/tcltk.so': dlopen(/Library/Frameworks/R.framework/Versions/2.8/Resources/library/tcltk/libs/i386/tcltk.so, 10): Library not loaded: /usr/local/lib/libtcl8.5.dylib Referenced from: /Library/Frameworks/R.framework/Versions/2.8/Resources/library/tcltk/libs/i386/tcltk.so Reason: image not found Error : .onLoad non riuscito in 'loadNamespace' per tcltk Errore: pacchetto 'tcltk' non caricato The language is in italian but it basically says it cannot load shared library. x11 is running, the file tcltk.so phisically exists (i have checked myself) and both R and X11 are in their last updated version. I have also tried restarting after updating X11. Can someone try to help me? i have recently swithced to mac and am having an important exam soon. Thanks to anyone. Ben -- View this message in context: http://www.nabble.com/Problem-with-tcl-tk-and-Rcmdr---urgent-help-required-tp20791135p20791135.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] Can't load Rgraphviz on windows-based R
Dear all, I am facing the same problem. I followed the all instructions given in help file and some steps of previous discussion (from google search) but I could not install package Rgraphiviz in windows. I tried even the instructions given to install Bioconductor package then only able to install in Linux systems but not in Windows. In my opinion, Graphiviz package which creating problems in installation of Rgraphiviz packageis, is doing something wrong or needs some special requirements . If some body have idea regarding this problem, I am also enthusiastic to see the solution. Pls, if you find solution, let me know. Thanks Truly, Ram Kumar Basnet, Graduate student, Wageningen University, The Netherlands. --- On Tue, 12/2/08, Prof Brian Ripley [EMAIL PROTECTED] wrote: From: Prof Brian Ripley [EMAIL PROTECTED] Subject: Re: [R] Can't load Rgraphviz on windows-based R To: Daren Tan [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Tuesday, December 2, 2008, 1:47 AM Rgraphviz is a Bioconductor package, so please ask on the apporpriate mailing list (see the posting guide). On Tue, 2 Dec 2008, Daren Tan wrote: Hi, I have problem loading Rgraphviz. Following the instructions specified by the README in Rgraphviz_1.20.3.tar.gz didn't help either. o. set the following Windows environment variables accordingly (control panel - systems - Advanced - Environment Variables ): (a) create new user variables: GRAPHVIZ_INSTALL_DIR (e.g., C:\Graphviz-2.21) -- I stated C:\Graphviz-2.21 (I also tried C:\/Graphviz-2.21) GRAPHVIZ_INSTALL_MAJOR (e.g., 2) -- I stated 2 GRAPHVIZ_INSTALL_MINOR (e.g., 20) -- I stated 21 Notice the way \/ are used for the paths above. (b) add to user variable 'path': $GRAPHVIZ_INSTALL_DIR/bin e.g., C:\Graphviz-2.21\bin -- I stated C:\Graphviz-2.21\bin (I also tried C:\/Graphviz-2.21\/bin) It should be 'PATH', not 'path': environment variables are case-sensitive (in general, not sure what happens with PATH if set there). library(Rgraphviz) Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared library 'D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll': LoadLibrary failure: The specified module could not be found. That does not mean Rgraphviz.dll: it means a dependent DLL. You did actually install graphviz, I presume? In addition: Warning messages: 1: closing unused connection 4 (D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll) 2: closing unused connection 3 (D:/PROGRA~1/R/R-2.8.0/library/Rgraphviz/libs/Rgraphviz.dll) Error : .onLoad failed in 'loadNamespace' for 'Rgraphviz' Error: package/namespace load failed for 'Rgraphviz' file.exists(D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll) [1] TRUE sessionInfo() R version 2.8.0 (2008-10-20) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] graph_1.20.0 loaded via a namespace (and not attached): [1] cluster_1.11.11 tools_2.8.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] command files
Since I'm a SAS programmer, I'm used to creating command files in an editor for submission later. Is there a way to do this in R? I'd need to retain an ouput listing and a log to check for errors. _ Send e-mail faster without improving your typing skills. d_122008 [[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] Comparing output from linear regression to output from quasipoisson to determine the model that fits best.
John Sorkin wrote: R 2.7 Windows XP I have two model that have been run using exactly the same data, both fit using glm(). One model is a linear regression (gaussian(link = identity)) the other a quasipoisson(link = log). I have log likelihoods from each model. Is there any way I can determine which model is a better fit to the data? anova() does not appear to work as the models have the same residual degrees of freedom: Since the class of the models is quite different, I'd go on by looking carefully at the residuals. Uwe Ligges fit1-glm(PHYSFUNC~HIV,data=KA) summary(fit1) fitQP-glm(PHYSFUNC~HIV,data=KA,family=quasipoisson) summary(fitQP) anova(fit1,fitOP) Program OUTPUT: fit1-glm(PHYSFUNC~HIV,data=KA) summary(fit1) Call: glm(formula = PHYSFUNC ~ HIV, data = KA) Deviance Residuals: Min 1Q Median 3Q Max -4.197 -4.192 -2.192 2.808 19.808 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 4.196700.08508 49.33 2e-16 *** HIV -0.004870.12071 -0.040.968 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for gaussian family taken to be 22.78134) Null deviance: 142429 on 6253 degrees of freedom Residual deviance: 142429 on 6252 degrees of freedom (213 observations deleted due to missingness) AIC: 37302 Number of Fisher Scoring iterations: 2 fitQP-glm(PHYSFUNC~HIV,data=KA,family=quasipoisson) summary(fitQP) Call: glm(formula = PHYSFUNC ~ HIV, family = quasipoisson, data = KA) Deviance Residuals: Min 1Q Median 3Q Max -2.897 -2.895 -1.193 1.250 6.644 Coefficients: Estimate Std. Error t value Pr(|t|) (Intercept) 1.434297 0.020280 70.72 2e-16 *** HIV -0.001161 0.028780 -0.040.968 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 (Dispersion parameter for quasipoisson family taken to be 5.432011) Null deviance: 35439 on 6253 degrees of freedom Residual deviance: 35439 on 6252 degrees of freedom (213 observations deleted due to missingness) AIC: NA Number of Fisher Scoring iterations: 5 anova(fit1,fitQP) Analysis of Deviance Table Model 1: PHYSFUNC ~ HIV Model 2: PHYSFUNC ~ HIV Resid. Df Resid. Dev Df Deviance 1 6252 142429 2 6252 354390 106989 Thanks, John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Limit on number of Rows when reading R dataset
Hello, I am trying to read a dataset with 100,000 rows and around 365 columns into R, using read.table/read.csv. In Windows XP, with R 32 bit, I am able to read only 15266 rows and not more than that. I tried the same in R running in Ubuntu and it does the same and reads only 15266 rows. Using the nrows paramter i can read rows less than 15266, but when i used a value larger than 15266, it reads only 15266 nevertheless. Thank you for your patience and responses. Regards Harsh Singhal Bangalore, India __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] fGarch and is.na()
Hello, after loading package fGarch the function is.na.data.frame() is behaving different: sessionInfo() R version 2.8.0 (2008-10-20) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base dfr - data.frame(matrix(0,nrow = 1 , ncol = 1000)) dfr2 - is.na(dfr) require(fGarch) Loading required package: fGarch Loading required package: timeDate Loading required package: timeSeries Loading required package: fBasics Loading required package: MASS dfr2 - is.na(dfr) Error: evaluation nested too deeply: infinite recursion / options(expressions=)? I wonder whether this is intended. Best, Felix Tinbergen Institute P.O. Box 1738 3000 DR Rotterdam __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] command files
Try source('myFirstScript.R') Where myFirstScript.R as the following line x - rnorm(100) y - rnorm(100) plot(x,y) You could also use a editor like emacs with the ess-mode where one buffer can be your script with a live R session in a second buffer. Good luck On 12/2/08 7:21 AM, b g [EMAIL PROTECTED] wrote: Since I'm a SAS programmer, I'm used to creating command files in an editor for submission later. Is there a way to do this in R? I'd need to retain an ouput listing and a log to check for errors. _ Send e-mail faster without improving your typing skills. d_122008 [[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. -- Marco Blanchette, Ph.D. Assistant Investigator Stowers Institute for Medical Research 1000 East 50th St. Kansas City, MO 64110 Tel: 816-926-4071 Cell: 816-726-8419 Fax: 816-926-2018 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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't load Rgraphviz on windows-based R
L.S., I am facing the same problem. I followed the all instructions given in help file and some steps of previous discussion (from google search) but I could not install package Rgraphiviz in windows. I tried even the instructions given to install Bioconductor package then only able to install in Linux systems but not in Windows. In my opinion, Graphiviz package which creating problems in installation of Rgraphiviz packageis, is doing something wrong or needs some special requirements . If some body have idea regarding this problem, I am also enthusiastic to see the solution. Pls, if you find solution, let me know. I installed it (without problems) on someone's Windows PC yesterday. The recipe: 1) download and install the Windows installer for graphviz http://www.graphviz.org/pub/graphviz/stable/windows/graphviz-2.20.3.msi 2) add the path to the graphviz binaries to your PATH environment variable o in the Control Panel right click on System - Properties - Advanced - Environment Variables o edit PATH and add the path to the binaries (ends in ...\bin) 3) install the Rgraphviz package from BioConductor HTH, Tobias --- On Tue, 12/2/08, Prof Brian Ripley [EMAIL PROTECTED] wrote: From: Prof Brian Ripley [EMAIL PROTECTED] Subject: Re: [R] Can't load Rgraphviz on windows-based R To: Daren Tan [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Date: Tuesday, December 2, 2008, 1:47 AM Rgraphviz is a Bioconductor package, so please ask on the apporpriate mailing list (see the posting guide). On Tue, 2 Dec 2008, Daren Tan wrote: Hi, I have problem loading Rgraphviz. Following the instructions specified by the README in Rgraphviz_1.20.3.tar.gz didn't help either. o. set the following Windows environment variables accordingly (control panel - systems - Advanced - Environment Variables ): (a) create new user variables: GRAPHVIZ_INSTALL_DIR (e.g., C:\Graphviz-2.21) -- I stated C:\Graphviz-2.21 (I also tried C:\/Graphviz-2.21) GRAPHVIZ_INSTALL_MAJOR (e.g., 2) -- I stated 2 GRAPHVIZ_INSTALL_MINOR (e.g., 20) -- I stated 21 Notice the way \/ are used for the paths above. (b) add to user variable 'path': $GRAPHVIZ_INSTALL_DIR/bin e.g., C:\Graphviz-2.21\bin -- I stated C:\Graphviz-2.21\bin (I also tried C:\/Graphviz-2.21\/bin) It should be 'PATH', not 'path': environment variables are case-sensitive (in general, not sure what happens with PATH if set there). library(Rgraphviz) Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared library 'D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll': LoadLibrary failure: The specified module could not be found. That does not mean Rgraphviz.dll: it means a dependent DLL. You did actually install graphviz, I presume? In addition: Warning messages: 1: closing unused connection 4 (D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll) 2: closing unused connection 3 (D:/PROGRA~1/R/R-2.8.0/library/Rgraphviz/libs/Rgraphviz.dll) Error : .onLoad failed in 'loadNamespace' for 'Rgraphviz' Error: package/namespace load failed for 'Rgraphviz' file.exists(D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll) [1] TRUE sessionInfo() R version 2.8.0 (2008-10-20) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] graph_1.20.0 loaded via a namespace (and not attached): [1] cluster_1.11.11 tools_2.8.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Regarding posting a package to R-forge (with one of the dependent packages not in CRAN)
Hi Uwe, Thanks for the reply. I already tried that a couple of weeks ago, with the exactly the same arguments you posted. So far no reply from the author. I going to try again. Regards, Marcelo. On Tue, Dec 2, 2008 at 9:42 AM, Uwe Ligges [EMAIL PROTECTED]wrote: Marcelo Perlin wrote: Hi Guys, Recently I wrote a package for dealing with Markov Switching Regressions in R and it is included in the Rmetrics project. https://r-forge.r-project.org/projects/rmetrics/ Everything works fine when I use it in computer. But, the package depends on the use of optimization functions from the package Rdonlp2, which is not available on CRAN. So, if I have Rdonlp2 in my laptop (or any computer) I can load the package and it works fine. But, the problem Im having is that when I submit the package to R-Forge, the R-Forge system try to build it (Rcm -build ... ) and outputs a error message saying that Rdonlp2 is not found. This means that its not possible to get, from the internet, the package I wrote with install.package(...). Did anyone had a simillar problem ? Any suggestions for a workaround or solution ? Well, if others should be able to use your package, they will probably also need Rdonlp2. How are those others supposed to get it? I fear you will need to make it available as well - and if you are not the authors, convince its author to make it available. Best, Uwe Ligges Thanks for your help! Regards, Marcelo. [[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] Limit on number of Rows when reading R dataset
Thank you Uwe and Prof. Ripley. The problem was solved. The row in question indeed have garbage data, which possibly was truncating the number of lines read. I apologise for the oversight. Thank you once again. Regards Harsh Singhal Bangalore, India On Tue, Dec 2, 2008 at 2:50 PM, Prof Brian Ripley [EMAIL PROTECTED] wrote: Take a look at your dataset at around that row. Perhaps you have an unmatched quote? The limit on the number of rows of a data frame is far larger than 100,000 (2^31-1, but you will run out of address space on a 32-bit platform before that - see ?Memory-limits). On Tue, 2 Dec 2008, Harsh wrote: Hello, I am trying to read a dataset with 100,000 rows and around 365 columns into R, using read.table/read.csv. In Windows XP, with R 32 bit, I am able to read only 15266 rows and not more than that. I tried the same in R running in Ubuntu and it does the same and reads only 15266 rows. Using the nrows paramter i can read rows less than 15266, but when i used a value larger than 15266, it reads only 15266 nevertheless. Thank you for your patience and responses. Regards Harsh Singhal Bangalore, India -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] boxplot via plot command
Hi, Antje niederlein-rstat at yahoo.de writes: Hi folks, I've just discovered that the following code leads to boxplot (surprisingly to me). Can anybody explain to me why? Is this documented somewhere? I've never consider this option before. x - rnorm(300) l - c(rep(label1,100), rep(label2,50), rep(label3,150)) df - data.frame(as.factor(l), x) plot(df) Thank you! Antje You can follow this through the various methods. If you look at plot.data.frame getAnywhere(plot.data.frame) You'll see that when the data.frame has only 2 columns, it calls plot with the first two arguments. Since the first argument here is a factor, it dispatches to the plot.factor method getAnywhere(plot.factor) from which you'll see that under your circumstances it will call boxplot HTH, Ken __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Limit on number of Rows when reading R dataset
Take a look at your dataset at around that row. Perhaps you have an unmatched quote? The limit on the number of rows of a data frame is far larger than 100,000 (2^31-1, but you will run out of address space on a 32-bit platform before that - see ?Memory-limits). On Tue, 2 Dec 2008, Harsh wrote: Hello, I am trying to read a dataset with 100,000 rows and around 365 columns into R, using read.table/read.csv. In Windows XP, with R 32 bit, I am able to read only 15266 rows and not more than that. I tried the same in R running in Ubuntu and it does the same and reads only 15266 rows. Using the nrows paramter i can read rows less than 15266, but when i used a value larger than 15266, it reads only 15266 nevertheless. Thank you for your patience and responses. Regards Harsh Singhal Bangalore, India -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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't load Rgraphviz on windows-based R
Rgraphviz is a Bioconductor package, so please ask on the apporpriate mailing list (see the posting guide). On Tue, 2 Dec 2008, Daren Tan wrote: Hi, I have problem loading Rgraphviz. Following the instructions specified by the README in Rgraphviz_1.20.3.tar.gz didn't help either. o. set the following Windows environment variables accordingly (control panel - systems - Advanced - Environment Variables ): (a) create new user variables: GRAPHVIZ_INSTALL_DIR (e.g., C:\Graphviz-2.21) -- I stated C:\Graphviz-2.21 (I also tried C:\/Graphviz-2.21) GRAPHVIZ_INSTALL_MAJOR (e.g., 2)-- I stated 2 GRAPHVIZ_INSTALL_MINOR (e.g., 20) -- I stated 21 Notice the way \/ are used for the paths above. (b) add to user variable 'path': $GRAPHVIZ_INSTALL_DIR/bin e.g., C:\Graphviz-2.21\bin -- I stated C:\Graphviz-2.21\bin (I also tried C:\/Graphviz-2.21\/bin) It should be 'PATH', not 'path': environment variables are case-sensitive (in general, not sure what happens with PATH if set there). library(Rgraphviz) Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared library 'D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll': LoadLibrary failure: The specified module could not be found. That does not mean Rgraphviz.dll: it means a dependent DLL. You did actually install graphviz, I presume? In addition: Warning messages: 1: closing unused connection 4 (D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll) 2: closing unused connection 3 (D:/PROGRA~1/R/R-2.8.0/library/Rgraphviz/libs/Rgraphviz.dll) Error : .onLoad failed in 'loadNamespace' for 'Rgraphviz' Error: package/namespace load failed for 'Rgraphviz' file.exists(D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll) [1] TRUE sessionInfo() R version 2.8.0 (2008-10-20) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] graph_1.20.0 loaded via a namespace (and not attached): [1] cluster_1.11.11 tools_2.8.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with tcl/tk and Rcmdr - urgent help required
Dear Ben, It seems clear that the problem is in loading the tcltk package. To confirm that, does library(tcltk) fail? I'm not very knowledgeable about Mac OS X. I do have a MacBook, with OS X 10.5, however, and encountered no problems installing and running the Rcmdr package. Have you seen the R Commander installation instructions for Mac OS X 10.4, at http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/installation-notes.html? If not, maybe something there will help. I'm copying this response to Rob Goedman [EMAIL PROTECTED], who has provided help before. Regards, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of beniamino Sent: December-02-08 7:25 AM To: r-help@r-project.org Subject: [R] Problem with tcl/tk and Rcmdr - urgent help required Hello everyone, i have been searching the whole day, trying ANY solution offered by the internet and before headbanging against the wall would like to try asking for your help. As many others, i am haveing problems loading the Rcmdr package with Macbook running Tiger 10.4.11. X11 version updated to the last one after having manually installed. I have also installed (obviously) the Rcmdr package with all dependencies. However (damn) i keep having the following answer to the library (rcmdr) command: library (Rcmdr) Carico il pacchetto richiesto: tcltk Loading Tcl/Tk interface ... Error in dyn.load(file, DLLpath = DLLpath, ...) : impossibile caricare libreria condivisa '/Library/Frameworks/R.framework/Versions/2.8/Resources/library/tcltk/libs/i 3 86/tcltk.so': dlopen(/Library/Frameworks/R.framework/Versions/2.8/Resources/library/tcltk/ l ibs/i386/tcltk.so, 10): Library not loaded: /usr/local/lib/libtcl8.5.dylib Referenced from: /Library/Frameworks/R.framework/Versions/2.8/Resources/library/tcltk/libs/i3 8 6/tcltk.so Reason: image not found Error : .onLoad non riuscito in 'loadNamespace' per tcltk Errore: pacchetto 'tcltk' non caricato The language is in italian but it basically says it cannot load shared library. x11 is running, the file tcltk.so phisically exists (i have checked myself) and both R and X11 are in their last updated version. I have also tried restarting after updating X11. Can someone try to help me? i have recently swithced to mac and am having an important exam soon. Thanks to anyone. Ben -- View this message in context: http://www.nabble.com/Problem-with-tcl-tk-and- Rcmdr---urgent-help-required-tp20791135p20791135.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] Wiley Interdisciplinary Reviews
They are obviously growing desperate - I have now been asked to write 5 articles! Hadley -- 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] Using grep() to subset lines of text
ppaarrkk wrote: I have two vectors, a and b. b is a text file. I want to find in b those elements of a which occur at the beginning of the line in b. I have the following code, but it only returns a value for the first value in a, but I want both. Any ideas please. a = c(2,3) b = NULL b[1] = aaa 2 aaa b[2] = 2 aaa b[3] = 3 aaa b[4] = aaa 3 aaa grep(paste(^,a, sep=), b ) grep(paste(^, a, collapse = |, sep = ), b) Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 solve following equation?
I need to solve a equation like this : a = b/(1+x) + c/(1+x)^2 + d/(1+x)^3 where a,b,c,d are known constant. Is there any R-way to do that? Multiplying this expression with (1+x)^3 leads to a polynomial equation. I would certainly recommend the 'PolynomF' package here: # install.packages(PolynomF) library(PolynomF) options(digits=16) x - polynom() a - b - c - d - 1 p - a*(1+x)^3 - b*(1+x)^2 - c*(1+x) - d p # -2 + 2*x^2 + x^3 solve(p) # [1] -1.419643377607080-0.6062907292072i # -1.419643377607080+0.6062907292072i # [3] 0.839286755214161+0.0i The solution x0 = 0.839286755214161 is correct up to the last digit, as can be verified by using a computer algebra system. This also shows that Ryacas is quite exact in this task. Hans Werner Gabor Grothendieck ggrothendieck at gmail.com writes: Assume a = 1. If not set b = b/a, etc. Now use (1) uniroot f - function(x) b + c/(1+x) + d/(1+x)^2 - 1 - x uniroot(f, 0:1) $root [1] 0.8392679 $f.root [1] 3.049818e-05 $iter [1] 3 $estim.prec [1] 6.103516e-05 or multiply through by 1+x and subtract 1 from both sides giving x = b + c/(1+x) + d/(1+x)^2 - 1 and iterate that. a - b - c - d - 1 x - 0 for(i in 1:25) { + x - b + c/(1+x) + d/(1+x)^2 - 1 + print(x) + } [1] 2 [1] 0.444 [1] 1.171598 [1] 0.6725419 [1] 0.9553676 [1] 0.7729558 [1] 0.8821595 [1] 0.8135892 [1] 0.8554268 [1] 0.829437 [1] 0.8454056 [1] 0.835527 [1] 0.8416126 [1] 0.837854 [1] 0.8401717 [1] 0.838741 [1] 0.8396236 [1] 0.839079 [1] 0.839415 [1] 0.8392076 [1] 0.8393356 [1] 0.8392566 [1] 0.8393053 [1] 0.8392753 [1] 0.8392938 On Mon, Dec 1, 2008 at 9:47 PM, RON70 ron_michael70 at yahoo.com wrote: I need to solve a equation like this : a = b/(1+x) + c/(1+x)^2 + d/(1+x)^3 where a,b,c,d are known constant. Is there any R-way to do that? Thanks in advance -- View this message in context: http://www.nabble.com/How-to-solve-following-equation--tp20785063p20785063.html Sent from the R help mailing list archive at Nabble.com. __ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Left-truncated regression
Hi. I am looking for a function for left-truncated data. I have one data set with 2 variables (Hours~Yrs_Ed). I already left-censored the data at 200 and left-truncated it at the same spot, so that I am able to make 2 estimations (one for censoring and one for truncation). I know how to make the linear regression for the left-censored variable (hours) and how to plot the regression line into the (x,y) plot (packages AER, Zeileis, Survival, ...): tfit-survreg(Surv(Hours,Hours0, type='left')~Yrs_Ed,data=DataWomen,dist='gaussian') z-predict(tfit,type=response) plot(Yrs_Ed,Hours) abline(tfit) My aim is to compare the effects of truncation and censoring graphically by plotting the two regression lines into one plot with both datasets (censored and truncated). I just can't figure out how to write the function for left-truncated data and what package to use for this. I only need left-truncation, not left-truncation and right-censoring. I hope somebody can help me with that matter. Zita -- View this message in context: http://www.nabble.com/Left-truncated-regression-tp20789446p20789446.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] Can't load Rgraphviz on windows-based R
Hi, I have problem loading Rgraphviz. Following the instructions specified by the README in Rgraphviz_1.20.3.tar.gz didn't help either. o. set the following Windows environment variables accordingly (control panel - systems - Advanced - Environment Variables ): (a) create new user variables: GRAPHVIZ_INSTALL_DIR (e.g., C:\Graphviz-2.21) -- I stated C:\Graphviz-2.21 (I also tried C:\/Graphviz-2.21) GRAPHVIZ_INSTALL_MAJOR (e.g., 2) -- I stated 2 GRAPHVIZ_INSTALL_MINOR (e.g., 20) -- I stated 21 Notice the way \/ are used for the paths above. (b) add to user variable 'path': $GRAPHVIZ_INSTALL_DIR/bin e.g., C:\Graphviz-2.21\bin -- I stated C:\Graphviz-2.21\bin (I also tried C:\/Graphviz-2.21\/bin) library(Rgraphviz) Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared library 'D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll': LoadLibrary failure: The specified module could not be found. In addition: Warning messages: 1: closing unused connection 4 (D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll) 2: closing unused connection 3 (D:/PROGRA~1/R/R-2.8.0/library/Rgraphviz/libs/Rgraphviz.dll) Error : .onLoad failed in 'loadNamespace' for 'Rgraphviz' Error: package/namespace load failed for 'Rgraphviz' file.exists(D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll) [1] TRUE sessionInfo() R version 2.8.0 (2008-10-20) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] graph_1.20.0 loaded via a namespace (and not attached): [1] cluster_1.11.11 tools_2.8.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] boxplot via plot command
Hi folks, I've just discovered that the following code leads to boxplot (surprisingly to me). Can anybody explain to me why? Is this documented somewhere? I've never consider this option before. x - rnorm(300) l - c(rep(label1,100), rep(label2,50), rep(label3,150)) df - data.frame(as.factor(l), x) plot(df) Thank you! Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Regarding posting a package to R-forge (with one of the dependent packages not in CRAN)
Marcelo Perlin wrote: Hi Guys, Recently I wrote a package for dealing with Markov Switching Regressions in R and it is included in the Rmetrics project. https://r-forge.r-project.org/projects/rmetrics/ Everything works fine when I use it in computer. But, the package depends on the use of optimization functions from the package Rdonlp2, which is not available on CRAN. So, if I have Rdonlp2 in my laptop (or any computer) I can load the package and it works fine. But, the problem Im having is that when I submit the package to R-Forge, the R-Forge system try to build it (Rcm -build ... ) and outputs a error message saying that Rdonlp2 is not found. This means that its not possible to get, from the internet, the package I wrote with install.package(...). Did anyone had a simillar problem ? Any suggestions for a workaround or solution ? Well, if others should be able to use your package, they will probably also need Rdonlp2. How are those others supposed to get it? I fear you will need to make it available as well - and if you are not the authors, convince its author to make it available. Best, Uwe Ligges Thanks for your help! Regards, Marcelo. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Question to regular expressions
Hi there, I know, this question is not directly an R-help question but probably someone can give me a hint how to deal with the following problem. I have a vector with file/folder names and want to filter for all entries which have 6 numbers in a row and nothing else. folders - c(folder1, f2, F234562, 12345678, 234567, 912345, 333) I'd like to get only 234567 and 912345. Can anybody help me creating a regex for this??? For example this regex: regexpr([^:digit:$]{6}, folders) would match F234562, 12345678, 234567, 912345 Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] optimization problem
Hans W. Borchers [EMAIL PROTECTED] wrote: Why not use one of the global optimizers in R, for instance 'DEoptim', and then apply optim() to find the last six decimals? I am relatively sure that the Differential Evolution operator has a better chance to come near a global optimum than a loop over optim(), though 'DEoptim' may be a bit slow (only for quite large numbers of parameters). Thanks for the reference. I will see if 'DEoptim' might be useful in future problems. HWB asked, why not use 'DEoptim' rather than a loop? Perhaps that's a rhetorical question, but I'll answer it anyway, in the context of the specific problem I am solving. (1) I did not know that 'DEoptim' existed. (2) After starting a problem with 'nls', I changed its structure slightly, which meant a change to 'optim'. Because the two functions have totally different syntaxes, it was necessary to rewrite the entire script and its supporting functions. Adding a loop was much simpler than looking for yet *another* optimizer in R. (3) In the current problem, perhaps 97 of 100 runs of 'optim' come to the same solution (the best one found). That suggests that this is not a terribly difficult problem and that there is little to be gained by employing a different approach. SOMEONE once posted about an R function that masked the syntax differences among (at least some) R optimizers. That surely would lower the barrier to switching among them. I've lost that post, and my search has not turned it up. If that poster is reading this, would you please respond with the information? ALSO, is anyone aware of any document comparing the various optimizers available in R (even in core R)? What are the different intended applications, and when would each be preferred? There is some helpful material in MASS 4, but I am hoping for something more recent and detailed. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Limit on number of Rows when reading R dataset
Harsh wrote: Hello, I am trying to read a dataset with 100,000 rows and around 365 columns into R, using read.table/read.csv. In Windows XP, with R 32 bit, I am able to read only 15266 rows and not more than that. I tried the same in R running in Ubuntu and it does the same and reads only 15266 rows. Using the nrows paramter i can read rows less than 15266, but when i used a value larger than 15266, it reads only 15266 nevertheless. What happens exactly? Error message? How does you file look like in rows 15260-15270? Uwe Ligges Thank you for your patience and responses. Regards Harsh Singhal Bangalore, India __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Problem with the Rmpi package
Dear all, I just started to use the snow package to send multiple jobs on our cluster using MPI and the Rpmi package as the communication method. However, the Rmpi package have been behaving strangely. When I try to detach the Rmpi package I get the following error message: library(Rmpi) detach() Error in dyn.unload(file.path(libpath, libs, paste(Rmpi, .Platform$dynlib.ext, : dynamic/shared library '/Users/mab/Library/R/2.8/library/Rmpi/libs/Rmpi.so' was not loaded Following that error, the snow package seems to be unable to initiate a new cluster, whatever method is used. The fix is to kill and restart my R session. Any suggestion as to what is the problem? -- Marco Blanchette, Ph.D. Assistant Investigator Stowers Institute for Medical Research 1000 East 50th St. Kansas City, MO 64110 Tel: 816-926-4071 Cell: 816-726-8419 Fax: 816-926-2018 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 to regular expressions
Try this: folders - c(folder1, f2, F234562, 12345678, 234567, 912345, 333) grep(^[0-9]{6}$, folders, value = TRUE) [1] 234567 912345 On Tue, Dec 2, 2008 at 10:32 AM, Antje [EMAIL PROTECTED] wrote: Hi there, I know, this question is not directly an R-help question but probably someone can give me a hint how to deal with the following problem. I have a vector with file/folder names and want to filter for all entries which have 6 numbers in a row and nothing else. folders - c(folder1, f2, F234562, 12345678, 234567, 912345, 333) I'd like to get only 234567 and 912345. Can anybody help me creating a regex for this??? For example this regex: regexpr([^:digit:$]{6}, folders) would match F234562, 12345678, 234567, 912345 Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] legend idea for latticeExtra
Dear list, I've written a small utility function to add arbitrary legend(s) to a lattice graph (or a combination of them), much like the legend function of base graphics. I though perhaps it could be useful to someone else, or improved by suggestions. I understand this goes against the lattice paradigm somewhat, in that you short-cut the link between group variables and the appearance of the legend. There are some cases where I was missing this kind of raw command, though, and the custom legend dendrogram of the lattice book is intimidating if not a bit overkill. llegend - function(x=0.5, y=0.5, loc=FALSE, text=c(a, b), unit=npc, pch=1, lty=NULL, col=seq_along(text), cex=0.6, cex.title=0.8, ...){ if(loc) { ll - grid.locator(unit) print(ll) x - as.numeric(ll$x) y - as.numeric(ll$y) } lines - !is.null(lty) points - !is.null(pch) keyGrob - draw.key(key=simpleKey(text, lines=lines, points = points,cex=cex, cex.title=cex.title, ...), vp=viewport(x=unit(x, unit), y=unit(y, unit)), draw=F) grid.draw(keyGrob) invisible(keyGrob) } # example (locator used for the second legend) xyplot(1~1) llegend() llegend(loc=T, title=Here goes another) # click wherever on the viewport. Best wishes, baptiste _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 to regular expressions
Hi Gabor, it works! Thank you very much! But I still don't understand the difference between [0-9] and [:digit:]... Ciao, Antje Gabor Grothendieck schrieb: Try this: folders - c(folder1, f2, F234562, 12345678, 234567, 912345, 333) grep(^[0-9]{6}$, folders, value = TRUE) [1] 234567 912345 On Tue, Dec 2, 2008 at 10:32 AM, Antje [EMAIL PROTECTED] wrote: Hi there, I know, this question is not directly an R-help question but probably someone can give me a hint how to deal with the following problem. I have a vector with file/folder names and want to filter for all entries which have 6 numbers in a row and nothing else. folders - c(folder1, f2, F234562, 12345678, 234567, 912345, 333) I'd like to get only 234567 and 912345. Can anybody help me creating a regex for this??? For example this regex: regexpr([^:digit:$]{6}, folders) would match F234562, 12345678, 234567, 912345 Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Question to regular expressions
Try this: ^[[:digit:]]{6}$ On Tue, Dec 2, 2008 at 10:48 AM, Antje [EMAIL PROTECTED] wrote: Hi Gabor, it works! Thank you very much! But I still don't understand the difference between [0-9] and [:digit:]... Ciao, Antje Gabor Grothendieck schrieb: Try this: folders - c(folder1, f2, F234562, 12345678, 234567, 912345, 333) grep(^[0-9]{6}$, folders, value = TRUE) [1] 234567 912345 On Tue, Dec 2, 2008 at 10:32 AM, Antje [EMAIL PROTECTED] wrote: Hi there, I know, this question is not directly an R-help question but probably someone can give me a hint how to deal with the following problem. I have a vector with file/folder names and want to filter for all entries which have 6 numbers in a row and nothing else. folders - c(folder1, f2, F234562, 12345678, 234567, 912345, 333) I'd like to get only 234567 and 912345. Can anybody help me creating a regex for this??? For example this regex: regexpr([^:digit:$]{6}, folders) would match F234562, 12345678, 234567, 912345 Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] exclude a vector value from another vector
Others have shown ways to remove your sample from the population, but this may be doing things the long way. If you just want several samples from the same population without overlap between any of the samples, just take one sample of size equal to the sum of the individual sample sizes, randomize the order, then split it into the individual samples. For example, to get 6 samples of size 4 from the population of LETTERS: mysamples - matrix( sample(LETTERS, 24), ncol=6 ) mysamples [,1] [,2] [,3] [,4] [,5] [,6] [1,] F L H A S P [2,] M D U N G C [3,] O R E V K W [4,] J X B T Z I Now each column is a sample, us apply or a for loop to work on each one. Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] 801.408.8111 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] project.org] On Behalf Of Hamid Hamid Sent: Monday, December 01, 2008 12:17 PM To: r-help@r-project.org Subject: [R] exclude a vector value from another vector Dear All, I am trying to build a program which will take repeated samples (w/o replacement) from a population of values. The interesting catch is that I would like the sample values to be removed from the population, after each sample is taken. For example: pop-c(1,5,14,7,9,12,18,19,65,54) sample(pop, 2) = lets say, (5,54) ## This is where I would like values (5, 54) to be removed from the population vector, giving a new current population vector: new pop = [1,14,7,9,12,18,19,65] and has length 8 instead of 10. In the cases when the size of pop and deriven sample of it is enough large using the following command is not helpful. newpop-pop[-c(2,10)] One could simplify my question in this way: how we can exclude a sub vector values from a super vector value (i.e sub vecor values are subset of super vector values). Thanks in advance. Hamid [[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] exclude a vector value from another vector
Try this: setdiff(pop, sample(pop, 2)) On Mon, Dec 1, 2008 at 5:16 PM, Hamid Hamid [EMAIL PROTECTED] wrote: Dear All, I am trying to build a program which will take repeated samples (w/o replacement) from a population of values. The interesting catch is that I would like the sample values to be removed from the population, after each sample is taken. For example: pop-c(1,5,14,7,9,12,18,19,65,54) sample(pop, 2) = lets say, (5,54) ## This is where I would like values (5, 54) to be removed from the population vector, giving a new current population vector: new pop = [1,14,7,9,12,18,19,65] and has length 8 instead of 10. In the cases when the size of pop and deriven sample of it is enough large using the following command is not helpful. newpop-pop[-c(2,10)] One could simplify my question in this way: how we can exclude a sub vector values from a super vector value (i.e sub vecor values are subset of super vector values). Thanks in advance. Hamid [[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] Question to regular expressions
On Tue, Dec 2, 2008 at 9:48 AM, Antje [EMAIL PROTECTED] wrote: Hi Gabor, it works! Thank you very much! But I still don't understand the difference between [0-9] and [:digit:]... You might find this site helpful: http://regexp.resource.googlepages.com/analyzer.html Copy in your attempt and Gabor's correction to see the difference more clearly. Hadley -- 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.
[R] Bug in transform?
Dear useRs, Here is a weird behavior of transform function: mtcars1-matcars transform(mtcars1,t1=3,t2=4) Error in data.frame(`_data`, e[!matched]) : arguments imply differing number of rows: 32, 1 instead, this works: mtcars1$t1-0 transform(mtcars1,t1=3,t2=4) also works if applied in turn: transform(mtcars1,t1=3) transform(mtcars1,t2=4) I often need to use this for creating new variables in data frame from those already present. Sorely needed!! Best, Vitalie. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] command files
2008/12/2 b g [EMAIL PROTECTED]: Since I'm a SAS programmer, I'm used to creating command files in an editor for submission later. Is there a way to do this in R? I'd need to retain an ouput listing and a log to check for errors. You probably want R CMD BATCH from a command-line. For example, if myjob.R is: x=runif(100) y=runif(100) m=lm(y~x) summary(m) and I do: R CMD BATCH myjob.R from a command prompt then when it finishes I get a file myjob.Rout which is a transcript file just like you'd see if you did things interactively. Normally on a Unix box 'R' will be in your path so you can type it just like that from a terminal window. From Windows, I'm not so sure, so you may have to type the full path, like: C:\Program Files\R-2.8.0\bin\R.exe CMD BATCH myjob.R Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question to regular expressions
Antje wrote: Hi Gabor, it works! Thank you very much! But I still don't understand the difference between [0-9] and [:digit:]... If all else fails, read the help, here ?regex. Both [0-9] and [[:digit:]] are character classes of digits, but the first contains only arabic numerals. In some locales the second may contain other numerals (e.g. Japanese has other characters representing digits): however I believe that in the current R implementations that no other numerals are included in any locale. Ciao, Antje Gabor Grothendieck schrieb: Try this: folders - c(folder1, f2, F234562, 12345678, 234567, 912345, 333) grep(^[0-9]{6}$, folders, value = TRUE) [1] 234567 912345 On Tue, Dec 2, 2008 at 10:32 AM, Antje [EMAIL PROTECTED] wrote: Hi there, I know, this question is not directly an R-help question but probably someone can give me a hint how to deal with the following problem. I have a vector with file/folder names and want to filter for all entries which have 6 numbers in a row and nothing else. folders - c(folder1, f2, F234562, 12345678, 234567, 912345, 333) I'd like to get only 234567 and 912345. Can anybody help me creating a regex for this??? For example this regex: regexpr([^:digit:$]{6}, folders) would match F234562, 12345678, 234567, 912345 Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Bug in transform?
Try: cbind(mtcars, t1 = 3, t2 = 4) On Tue, Dec 2, 2008 at 11:14 AM, Vitalie Spinu [EMAIL PROTECTED] wrote: Dear useRs, Here is a weird behavior of transform function: mtcars1-matcars transform(mtcars1,t1=3,t2=4) Error in data.frame(`_data`, e[!matched]) : arguments imply differing number of rows: 32, 1 instead, this works: mtcars1$t1-0 transform(mtcars1,t1=3,t2=4) also works if applied in turn: transform(mtcars1,t1=3) transform(mtcars1,t2=4) I often need to use this for creating new variables in data frame from those already present. Sorely needed!! Best, Vitalie. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] command files
On Tue, Dec 2, 2008 at 11:18 AM, Barry Rowlingson [EMAIL PROTECTED] wrote: 2008/12/2 b g [EMAIL PROTECTED]: Since I'm a SAS programmer, I'm used to creating command files in an editor for submission later. Is there a way to do this in R? I'd need to retain an ouput listing and a log to check for errors. You probably want R CMD BATCH from a command-line. For example, if myjob.R is: x=runif(100) y=runif(100) m=lm(y~x) summary(m) and I do: R CMD BATCH myjob.R from a command prompt then when it finishes I get a file myjob.Rout which is a transcript file just like you'd see if you did things interactively. Normally on a Unix box 'R' will be in your path so you can type it just like that from a terminal window. From Windows, I'm not so sure, so you may have to type the full path, like: C:\Program Files\R-2.8.0\bin\R.exe CMD BATCH myjob.R On Windows if you grab Rcmd.bat from http://batchfiles.googlecode.com and place it anywhere in your PATH then you can do the above like this: Rcmd BATCH myjob.R without having to set any paths. Rcmd.bat and all other batch files in that collection, are self contained so installation is just a matter of placing whichever you need anywhere on your path. Rcmd.bat finds R by looking into the registry and then runs it. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Bug in transform?
As the help page says If some of the values are not vectors of the appropriate length, you deserve whatever you get! So you can use mtcars1 - mtcars mtcars1[c(t1, t2)] - cbind(rep(3,32), rep(4, 32)) or even mtcars1 - transform(mtcars, t1=rep(3, 32), t2=rep(4, 32)) Vitalie Spinu wrote: Dear useRs, Here is a weird behavior of transform function: mtcars1-matcars transform(mtcars1,t1=3,t2=4) Error in data.frame(`_data`, e[!matched]) : arguments imply differing number of rows: 32, 1 instead, this works: mtcars1$t1-0 transform(mtcars1,t1=3,t2=4) also works if applied in turn: transform(mtcars1,t1=3) transform(mtcars1,t2=4) 'works'? Only if you assign the result. I often need to use this for creating new variables in data frame from those already present. Sorely needed!! Just learn to use indexing: transform() is just syntactic sugar that you are not making use of. Best, Vitalie. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] linear functional relationships with heteroscedastic non-Gaussian errors - any packages around?
[apologies if this appears twice] Hi, I have a situation where I have a set of pairs of X Y variables for each of which I have a (fairly) well-defined PDF. The PDF(x_i) 's and PDF(y_i)'s are unfortunately often rather non-Gaussian although most of the time not multi-modal. For these data (estimates of gas content in galaxies), I need to quantify a linear functional relationship and I am trying to do this as carefully as I can. At the moment I am carrying out a Monte Carlo estimation, sampling from each PDF(x_i) and PDF(y_i) and using a orthogonal linear fit for each realisation but that is not very satisfactory as it leads to different linear relationships depending on whether I do the orhtogonal fit on x or y (as the errors on X Y are quite different non-Gaussian using the covariance matrix isn't all that useful either) Does anybody know of code in R to do this kind of fitting in a Bayesian framework? My concern isn't so much on getting _the_ best slope estimate but rather to have a good estimate of the uncertainty on the slope. Cheers, Jarle. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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't load Rgraphviz on windows-based R
You can get LoadLibrary failures if a dependency is not found (e.g. a required dll or shlib used by the dll that you are explicitly loading). So make sure that all necessary dependencies (e.g. graphviz libs) are available in the system path. Rory Rory Winston RBS Global Banking Markets Office: +44 20 7085 4476 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Daren Tan Sent: 02 December 2008 09:37 To: [EMAIL PROTECTED] Subject: [R] Can't load Rgraphviz on windows-based R Hi, I have problem loading Rgraphviz. Following the instructions specified by the README in Rgraphviz_1.20.3.tar.gz didn't help either. o. set the following Windows environment variables accordingly (control panel - systems - Advanced - Environment Variables ): (a) create new user variables: GRAPHVIZ_INSTALL_DIR (e.g., C:\Graphviz-2.21) -- I stated C:\Graphviz-2.21 (I also tried C:\/Graphviz-2.21) GRAPHVIZ_INSTALL_MAJOR (e.g., 2) -- I stated 2 GRAPHVIZ_INSTALL_MINOR (e.g., 20) -- I stated 21 Notice the way \/ are used for the paths above. (b) add to user variable 'path': $GRAPHVIZ_INSTALL_DIR/bin e.g., C:\Graphviz-2.21\bin -- I stated C:\Graphviz-2.21\bin (I also tried C:\/Graphviz-2.21\/bin) library(Rgraphviz) Error in inDL(x, as.logical(local), as.logical(now), ...) : unable to load shared library 'D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll': LoadLibrary failure: The specified module could not be found. In addition: Warning messages: 1: closing unused connection 4 (D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.dll) 2: closing unused connection 3 (D:/PROGRA~1/R/R-2.8.0/library/Rgraphviz/libs/Rgraphviz.dll) Error : .onLoad failed in 'loadNamespace' for 'Rgraphviz' Error: package/namespace load failed for 'Rgraphviz' file.exists(D:/PROGRA~1/R/R-28~1.0/library/Rgraphviz/libs/Rgraphviz.d ll) [1] TRUE sessionInfo() R version 2.8.0 (2008-10-20) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] grid stats graphics grDevices utils datasets methods base other attached packages: [1] graph_1.20.0 loaded via a namespace (and not attached): [1] cluster_1.11.11 tools_2.8.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** The Royal Bank of Scotland plc. Registered in Scotland No 90312. Registered Office: 36 St Andrew Square, Edinburgh EH2 2YB. Authorised and regulated by the Financial Services Authority This e-mail message is confidential and for use by the=2...{{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] Bug in transform?
On Tue, 02 Dec 2008 17:37:44 +0100, Prof Brian Ripley [EMAIL PROTECTED] wrote: As the help page says If some of the values are not vectors of the appropriate length, you deserve whatever you get! So you can use mtcars1 - mtcars mtcars1[c(t1, t2)] - cbind(rep(3,32), rep(4, 32)) Ok..I got it, it is an usual pain with R: vectors with length 1 are recycled and data.frames with nrows=1 and arrays with dim[1]=1 are not. Will have to use mtcars[c(t1,t2)]-with(mtcars, cbind(t1=..., t2=...)) or rewrite transform.data.frame myself. Thanks a lot, Vitalie. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] legend idea for latticeExtra
On 12/2/08, baptiste auguie [EMAIL PROTECTED] wrote: Dear list, I've written a small utility function to add arbitrary legend(s) to a lattice graph (or a combination of them), much like the legend function of base graphics. I though perhaps it could be useful to someone else, or improved by suggestions. I understand this goes against the lattice paradigm somewhat, in that you short-cut the link between group variables and the appearance of the legend. There are some cases where I was missing this kind of raw command, though, and the custom legend dendrogram of the lattice book is intimidating if not a bit overkill. The book has a similar example: data(Chem97, package = mlmRev) ## Figure 12.1 qqmath(~ gcsescore | factor(score), Chem97, groups = gender, f.value = function(n) ppoints(100), aspect = xy, page = function(n) { cat(Click on plot to place legend, fill = TRUE) ll - grid.locator(unit = npc) if (!is.null(ll)) draw.key(simpleKey(levels(factor(Chem97$gender))), vp = viewport(x = ll$x, y = ll$y), draw = TRUE) }) I will consider adding a version of this in latticeExtra (both this and your example are not sufficiently general in their present form). -Deepayan llegend - function(x=0.5, y=0.5, loc=FALSE, text=c(a, b), unit=npc, pch=1, lty=NULL, col=seq_along(text), cex=0.6, cex.title=0.8, ...){ if(loc) { ll - grid.locator(unit) print(ll) x - as.numeric(ll$x) y - as.numeric(ll$y) } lines - !is.null(lty) points - !is.null(pch) keyGrob - draw.key(key=simpleKey(text, lines=lines, points = points,cex=cex, cex.title=cex.title, ...), vp=viewport(x=unit(x, unit), y=unit(y, unit)), draw=F) grid.draw(keyGrob) invisible(keyGrob) } # example (locator used for the second legend) xyplot(1~1) llegend() llegend(loc=T, title=Here goes another) # click wherever on the viewport. Best wishes, baptiste _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] linear functional relationships with heteroscedastic non-Gaussian errors - any packages around?
I wonder if you are using this term in its correct technical sense. A linear functional relationship is V = a + bU X = U + e Y = V + f e and f are random errors (often but not necessarily independent) with distributions possibly depending on U and V respectively. and pairs from (X,Y) are observed. As U and V are not random, there is no PDF of X or Y: each X_i has a different distribution. If you know the error distribution for each X_i and Y_i, you can easily write down a log-likelihood and maximize it. The first hit I got on Google, http://www.rsc.org/Membership/Networking/InterestGroups/Analytical/AMC/Software/FREML.asp, has a reference to a paper for the Gaussian case. But finding R code for the non-Gaussian case seems a very long shot. Jarle Brinchmann wrote: [apologies if this appears twice] It did ... Hi, I have a situation where I have a set of pairs of X Y variables for each of which I have a (fairly) well-defined PDF. The PDF(x_i) 's and PDF(y_i)'s are unfortunately often rather non-Gaussian although most of the time not multi-modal. For these data (estimates of gas content in galaxies), I need to quantify a linear functional relationship and I am trying to do this as carefully as I can. At the moment I am carrying out a Monte Carlo estimation, sampling from each PDF(x_i) and PDF(y_i) and using a orthogonal linear fit for each realisation but that is not very satisfactory as it leads to different linear relationships depending on whether I do the orhtogonal fit on x or y (as the errors on X Y are quite different non-Gaussian using the covariance matrix isn't all that useful either) Does anybody know of code in R to do this kind of fitting in a Bayesian framework? My concern isn't so much on getting _the_ best slope estimate but rather to have a good estimate of the uncertainty on the slope. Cheers, Jarle. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] linear functional relationships with heteroscedastic non-Gaussian errors - any packages around?
I wonder if you are using this term in its correct technical sense. A linear functional relationship is V = a + bU X = U + e Y = V + f e and f are random errors (often but not necessarily independent) with distributions possibly depending on U and V respectively. and pairs from (X,Y) are observed. As U and V are not random, there is no PDF of X or Y: each X_i has a different distribution. If you know the error distribution for each X_i and Y_i, you can easily write down a log-likelihood and maximize it. The first hit I got on Google, http://www.rsc.org/Membership/Networking/InterestGroups/Analytical/AMC/Software/FREML.asp, has a reference to a paper for the Gaussian case. But finding R code for the non-Gaussian case seems a very long shot. Jarle Brinchmann wrote: [apologies if this appears twice] It did ... Hi, I have a situation where I have a set of pairs of X Y variables for each of which I have a (fairly) well-defined PDF. The PDF(x_i) 's and PDF(y_i)'s are unfortunately often rather non-Gaussian although most of the time not multi-modal. For these data (estimates of gas content in galaxies), I need to quantify a linear functional relationship and I am trying to do this as carefully as I can. At the moment I am carrying out a Monte Carlo estimation, sampling from each PDF(x_i) and PDF(y_i) and using a orthogonal linear fit for each realisation but that is not very satisfactory as it leads to different linear relationships depending on whether I do the orhtogonal fit on x or y (as the errors on X Y are quite different non-Gaussian using the covariance matrix isn't all that useful either) Does anybody know of code in R to do this kind of fitting in a Bayesian framework? My concern isn't so much on getting _the_ best slope estimate but rather to have a good estimate of the uncertainty on the slope. Cheers, Jarle. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] factanal question
At 11:04 AM -0500 12/1/08, John Fox wrote: Dear Bill, Thanks for pointing out that this functionality is already in the psych package. Shouldn't factor.residuals() avoid this computation for oblique rotations? John, Good suggestion. I will add that in the next revision. Bill Regards, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of William Revelle Sent: December-01-08 10:26 AM To: John Fox; 'Don McNeil' Cc: r-help@r-project.org Subject: Re: [R] factanal question Don and John, factor.residuals in the psych package does what you want (and basically what John wrote). Bill At 9:30 AM -0500 12/1/08, John Fox wrote: Dear Don, All long as you leave the factors unrotated or do an orthogonal rotation (as is the default), you can compute reproduced correlations among the variables from the factor loadings, and thus residual correlations given the loadings and the original correlation matrix, both of which are accessible in the object returned by factanal(); the following isn't carefully tested, but should work: repRes - function(F, round=3){ A - loadings(F) R - F$correlation RR - A %*% t(A) ResR - R - RR list(reproduced.correlations=round(RR, round), residual.correlations=round(ResR, round)) } Here F is an object returned by factanal(). The diagonal elements of the reproduced correlations are the communalities, and of the residual correlations, the uniquenesses. To do this from an oblique rotation would require the factor-correlation matrix, which, as has been pointed out previously, factanal() oddly doesn't provide. In this case, that's not a real impediment, since reproduced and residual correlations are invariant with respect to rotation of the factors. I hope this helps, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Don McNeil Sent: November-30-08 11:39 PM To: r-help@r-project.org Subject: [R] factanal question Dear R users: I'm wondering if it's possible to get the residual correlation matrix when using factanal. Since factanal assumes that the errors are normally distributed and independent (provided the factor model fits the data) this would be useful. Of course you would need to submit the data to the function to get the residuals (not just their correlation matrix), but it should be possible to get the residual correlation matrix if only the data correlation matrix is provided. Don McNeil __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- William Revellehttp://personality-project.org/revelle.html Professor http://personality-project.org/personality.html Department of Psychology http://www.wcas.northwestern.edu/psych/ Northwestern Universityhttp://www.northwestern.edu/ Attend ISSID/ARP:2009 http://issid.org/issid.2009/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- William Revelle http://personality-project.org/revelle.html Professor http://personality-project.org/personality.html Department of Psychology http://www.wcas.northwestern.edu/psych/ Northwestern University http://www.northwestern.edu/ Attend ISSID/ARP:2009 http://issid.org/issid.2009/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Asymmetric CIs
Hi, I was wondering if there was some sort of package or function that calculated asymmetric confidence intervals for small proportions. I thought of both the epicalc and epitools package, but I am hoping to find something where you can just plug in a standard error and point estimate and it will output the upper and lower CI bounds. Thanks! Sarah __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Installation of RCurl Windows binary package from BioC extra repos (was Re: [BioC] Rcurl 0.8-1 update for bioconductor 2.7)
Roger, I had success installing RCurl per Patrick's instructions. I also got DAVIDQuery to install and run correctly but I had to run R CMD INSTALL DAVIDQuery from a cygwin terminal after 1) I replaced cygwin's make program v3.81 with the same version patched for windows from the mingw project. Make has stopped supporting windows path-names as of v 3.81. (see http://www.cygwin.com/ml/cygwin-announce/2006-07/msg8.html) 2) I had to replace the perl used by cygwin to the port provided by ActiveState in c:\Perl\bin (see http://tolstoy.newcastle.edu.au/R/help/02a/3915.html). NOTE: I tried using the R GUI to install DAVIDQuery but it reported: utils:::menuInstallLocal() updating HTML package descriptions library(DAVIDQuery) Error in library(DAVIDQuery) : 'DAVIDQuery' is not a valid package -- installed 2.0.0? NOTE: I tried to use the windows terminal but it reported: 'make' is not recognized as an internal or external c operable program or batch file. c:\Users\boycerd\DownloadsR CMD INSTALL DAVIDQuery installing to 'c:/PROGRA~1/R/R-28~1.0/library' 'mv' is not recognized as an internal or external com operable program or batch file. 'make' is not recognized as an internal or external c operable program or batch file. *** Installation of DAVIDQuery failed *** Removing 'c:/PROGRA~1/R/R-28~1.0/library/DAVIDQuery' hope it helps, -rdb Roger, Given that you are having problems installing the RCurl package from source, I recommend you install the binary version of the package instead. (It sounds like you may need to clean up broken installations first.) Here is what an installation would look like on a machine without the libcurl library installed on it: source(http://bioconductor.org/biocLite.R;) biocLite(RCurl) Running biocinstall version 2.3.9 with R version 2.8.0 Your version of R requires version 2.3 of Bioconductor. Warning in install.packages(pkgs = pkgs, repos = repos, dependencies = dependencies, : argument 'lib' is missing: using 'C:\Users\patrick\Documents/R/win-library/2.8' trying URL 'http://bioconductor.org/packages/2.3/extra/bin/windows/contrib/2.8/RCurl_0.92-0.zip' Content type 'application/zip' length 1347812 bytes (1.3 Mb) opened URL downloaded 1.3 Mb package 'RCurl' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Users\patrick\AppData\Local\Temp\RtmpTNKaC7\downloaded_packages updating HTML package descriptions library(RCurl) uris - c(http://www.omegahat.org/RCurl/index.html;, http://www.omegahat.org/RCurl/philosophy.xml;) txt - getURI(uris) names(txt) [1] http://www.omegahat.org/RCurl/index.html; http://www.omegahat.org/RCurl/philosophy.xml; nchar(txt) http://www.omegahat.org/RCurl/index.html http://www.omegahat.org/RCurl/philosophy.xml 426948969 sessionInfo() R version 2.8.0 (2008-10-20) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] RCurl_0.92-0 loaded via a namespace (and not attached): [1] tools_2.8.0 Day, Roger S wrote: Thanks, Patrick. As I mentioned, this results in a hung system, I've waited as long as an hour, no progress in the GUI past downloaded 234 Kb. The 00LOCK folder is created but is empty. An R.INSTALL. folder is created, with the unpacked package file. There is a README.windows file, but it seems a bit garbled, as if some text were accidentally replaced by line feeds. My interpretation: Retrieve curl-7.19.2-ssl-sspi-zlib-static-bin-w32 from http://curl.haxx.se/ (I did not find 7.12.0 there.) Set LIBCURL_DIR=where.i.put.it\curl-7.19.2-ssl-sspi-zlib-static-bin-w32 Go to R.INSTALL. R CMD INSTALL RCurl The result: -- Making package RCurl test: and: unknown operand Cannot find libcurl.dll in C:\Documents and Settings\day\Desktop\curl-7.19.2-ssl-sspi-zlib-static-bin-w32 make[2]: *** [c:/PROGRA~1/R/R-28~1.0/library/RCurl/] Error 1 make[1]: *** [all] Error 2 make: *** [pkg-RCurl] Error 2 *** Installation of RCurl failed *** Got rid of the test: and: error by copying the curl folder to . and resetting LIBCURL_DIR. But libcurl.dll still cannot be found by configure.win (despite its presence). Examining configure.win, it turns out that setting CURL_LIB_DIR works. Possibly a bug in configure.win. Next problem: Cannot find curl/curl.h in curl-7.19.2-ssl-sspi-zlib-static-bin-w32/include True, this file is not there.By un-setting LIBCURL_DIR this problem 'vanishes'. (a good thing or not?) Next problem: cp: cannot stat `curl-7.19.2-ssl-sspi-zlib-static-bin-w32/libcurl.dll': ( 3 other dlls) By moving
Re: [R] Question to regular expressions
Thanks a lot again to all of you!!! Antje Antje schrieb: Hi Gabor, it works! Thank you very much! But I still don't understand the difference between [0-9] and [:digit:]... Ciao, Antje Gabor Grothendieck schrieb: Try this: folders - c(folder1, f2, F234562, 12345678, 234567, 912345, 333) grep(^[0-9]{6}$, folders, value = TRUE) [1] 234567 912345 On Tue, Dec 2, 2008 at 10:32 AM, Antje [EMAIL PROTECTED] wrote: Hi there, I know, this question is not directly an R-help question but probably someone can give me a hint how to deal with the following problem. I have a vector with file/folder names and want to filter for all entries which have 6 numbers in a row and nothing else. folders - c(folder1, f2, F234562, 12345678, 234567, 912345, 333) I'd like to get only 234567 and 912345. Can anybody help me creating a regex for this??? For example this regex: regexpr([^:digit:$]{6}, folders) would match F234562, 12345678, 234567, 912345 Antje __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] predicted probabilities after lmer
Dear R-users, I'm using lmer to fit two-level logistic models and I'm interested in predicted probabilities that I get in this way (using fitted): glm1 = lmer(XY$T1~X1 + X2 + X3 + (1|Cind), family=binomial) #estimation of a two-level logit model fit1=fitted(glm1) # I get the fitted linear predictor ilog = function(x) { 1/(1 + exp(-x)) } ps1=ilog(fit1) # In order to get the estimated probabilities Is this procedure correct? In this way I'm getting the conditional probabilities, right? Is there any function I can use in order to get the empirical bayes (EB) probabilities? Any suggestion? And more generally, can you suggest me any paper/textbook/notes clarifying when it's more suitable to use one kind of probability than the other? Here are the formulas for what I labelled as conditional and EB probability: The model is: logit(P(Y=1)) = a + bX + u conditional: P(Y=1/u=u^) = 1/(1 + exp(-(a^ + b^X + u^))) EB: ∫[1/(1 + exp(-(a^ + b^X + u)))] x Posterior (u/Y, X) du (u is the random effect; ^ indicates estimated) Many thanks -- View this message in context: http://www.nabble.com/predicted-probabilities-after-lmer-tp20796391p20796391.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] question on lmer function
suppose something like probability(passing test) is driven by 1. fixed effects -- sex 2. district effects - district funding 3. school effects - neighborhood income, racial composition, % two parent families, ... 4. class effects - teacher quality measurement, 5. individual random effects - IQ. how would such a model be setup in lmer? I can't find much discussion on the web. Is there extended documentation somewhere on lmer? Richard Palmer Home 508 877-3862 Cell 508 982-7266 [[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] Left-truncated regression
Look at the sand package, which is available at http://www.csm.ornl.gov/esh/statoed/ and the NADA package, which is available from CRAN. One or both may have items of interest. Tom Zita wrote: Hi. I am looking for a function for left-truncated data. I have one data set with 2 variables (Hours~Yrs_Ed). I already left-censored the data at 200 and left-truncated it at the same spot, so that I am able to make 2 estimations (one for censoring and one for truncation). I know how to make the linear regression for the left-censored variable (hours) and how to plot the regression line into the (x,y) plot (packages AER, Zeileis, Survival, ...): tfit-survreg(Surv(Hours,Hours0, type='left')~Yrs_Ed,data=DataWomen,dist='gaussian') z-predict(tfit,type=response) plot(Yrs_Ed,Hours) abline(tfit) My aim is to compare the effects of truncation and censoring graphically by plotting the two regression lines into one plot with both datasets (censored and truncated). I just can't figure out how to write the function for left-truncated data and what package to use for this. I only need left-truncation, not left-truncation and right-censoring. I hope somebody can help me with that matter. Zita -- View this message in context: http://www.nabble.com/Left-truncated-regression-tp20789446p20798448.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] linear functional relationships with heteroscedastic non-Gaussian errors - any packages around?
Thanks for the reply! On Tue, Dec 2, 2008 at 6:34 PM, Prof Brian Ripley [EMAIL PROTECTED] wrote: I wonder if you are using this term in its correct technical sense. A linear functional relationship is V = a + bU X = U + e Y = V + f e and f are random errors (often but not necessarily independent) with distributions possibly depending on U and V respectively. This is indeed what I mean, poor phrasing of me. What I have is the effectively the PDF for e f for each instance, and I wish to get a b. For Gaussian errors there are certainly various ways to approach it and the maximum-likelihood estimator is fine and is what I normally use when my errors are sort-of-normal. However in this instance my uncertainty estimates are strongly non-Gaussian and even defining the mode of the distribution becomes rather iffy so I really prefer to sample the likelihoods properly. Using the maximum-likelihood estimator naively in this case is not terribly useful and I have no idea what the derived confidence limits means. Ah well, I guess what I have to do at the moment is to use brute force and try to calculate P(a,b|X,Y) properly using a marginalisation over U (I hadn't done that before, I expect that was part of my problem). Hopefully that will give reasonable uncertainty estimates, lots of pain for a figure nobody will look at for much time :) Thanks, Jarle. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Asymmetric CIs
Sarah E. McCormick wrote: Hi, I was wondering if there was some sort of package or function that calculated asymmetric confidence intervals for small proportions. I thought of both the epicalc and epitools package, but I am hoping to find something where you can just plug in a standard error and point estimate and it will output the upper and lower CI bounds. Thanks! Sarah If you want asymmetric CLs (a good idea) you can't base them on standard errors. See the binconf function in the Hmisc package for some solutions. Frank __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 on lmer function
Richard There is much more information that you need to provide before a thoughtful answer can be provided. Maybe you can describe the structure of your data, your outcome variable, etc. There is a vignette in the lmer package called 'Implementation' that will show you some methods for model fitting. With that said, at the most basic level, a model of the form response = \mu + beta(covariate) + a_j + e_ij, a_j ~ N(0,r^2), e_ij ~ N(0, s^2) Might be as follows in lmer lmer(response ~ covariate + (1|covariate), ... ) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Richard Palmer Sent: Tuesday, December 02, 2008 1:40 PM To: r-help@r-project.org Subject: [R] question on lmer function suppose something like probability(passing test) is driven by 1. fixed effects -- sex 2. district effects - district funding 3. school effects - neighborhood income, racial composition, % two parent families, ... 4. class effects - teacher quality measurement, 5. individual random effects - IQ. how would such a model be setup in lmer? I can't find much discussion on the web. Is there extended documentation somewhere on lmer? Richard Palmer Home 508 877-3862 Cell 508 982-7266 [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] question about the tisPlot function in package tis
List, I am using the 'tisPlot' function in Jeff Hallman's excellent tis package and was hoping that someone could spare me from having to dig into the code of his 'tisPlot' function. So far as I can tell, the preferred method of controlling the plotting of the x-axis is using the 'xTickFreq' and 'xTickSkip' options. Unfortunately, the where the data ends up on the resultant plot is not invariant to this choice, as indicated in the documentation of the 'xTickFreq' option. Has anyone adjusted the frequency of their x-axis label using this package before? I imagine that there must be a better way of doing what I am trying to accomplish, but if not, does anyone have a suggestion on how to work around this without digging into the function itself? ## an example library(tis) strt - ti(2101, monthly) dat - tis(runif(9*12 - 1), start=strt) # ends in 11/2008 par(mfrow=c(2,1)) tisPlot(dat, xTickFreq=monthly, xTickSkip=6) # graph ends in 11/2008, but looks to start some time in late 1999 tisPlot(dat, xTickFreq=monthly, xTickSkip=12) # graph looks to end around 3/2009 ## end TIA, Kyle ___ Research Associate, Macroeconomics Federal Reserve Bank of San Francisco [[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] match
Hi, I would like to check which rows of 'types.prev' matrix pop up in 'types', following R in-built procedure. I tried 'match' function but it works in case of the one dimensional vectors. Will appreciate any suggestions. best, robert types edateK [1,] 20060819 12.5 [2,] 20060819 17.5 [3,] 20060819 22.5 [4,] 20070217 12.5 [5,] 20060617 10.0 [6,] 20060617 15.0 [7,] 20060520 12.5 [8,] 20060520 15.0 [9,] 20060520 17.5 [10,] 20061118 10.0 [11,] 20061118 12.5 [12,] 20061118 15.0 [13,] 20061118 17.5 types.prev edateK [1,] 20060819 10.0 [2,] 20060819 12.5 [3,] 20060819 17.5 [4,] 20070217 10.0 [5,] 20070217 12.5 [6,] 20070217 15.0 [7,] 20060617 10.0 [8,] 20060617 12.5 [9,] 20060617 15.0 [10,] 20060617 20.0 [11,] 20060520 10.0 [12,] 20060520 12.5 [13,] 20060520 17.5 [14,] 20061118 12.5 [15,] 20061118 15.0 [16,] 20061118 17.5 -- View this message in context: http://www.nabble.com/match-tp20799206p20799206.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] question about the tisPlot function in package tis
The development version of zoo has a tis to zoo conversion function that would allow you to plot your data using plot.zoo and xplot.zoo in which case you can use classic graphics axis function (for plot.zoo) or lattice facilities (with xyplot.zoo): source(http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/R/as.zoo.tis.R?rev=524root=zoo;) z - as.zoo(dat, class = yearmon) plot(dat) xyplot(dat) There are many examples at ?plot.zoo and ?xyplot.zoo and in the three zoo vignettes. On Tue, Dec 2, 2008 at 1:49 PM, [EMAIL PROTECTED] wrote: List, I am using the 'tisPlot' function in Jeff Hallman's excellent tis package and was hoping that someone could spare me from having to dig into the code of his 'tisPlot' function. So far as I can tell, the preferred method of controlling the plotting of the x-axis is using the 'xTickFreq' and 'xTickSkip' options. Unfortunately, the where the data ends up on the resultant plot is not invariant to this choice, as indicated in the documentation of the 'xTickFreq' option. Has anyone adjusted the frequency of their x-axis label using this package before? I imagine that there must be a better way of doing what I am trying to accomplish, but if not, does anyone have a suggestion on how to work around this without digging into the function itself? ## an example library(tis) strt - ti(2101, monthly) dat - tis(runif(9*12 - 1), start=strt) # ends in 11/2008 par(mfrow=c(2,1)) tisPlot(dat, xTickFreq=monthly, xTickSkip=6) # graph ends in 11/2008, but looks to start some time in late 1999 tisPlot(dat, xTickFreq=monthly, xTickSkip=12) # graph looks to end around 3/2009 ## end TIA, Kyle ___ Research Associate, Macroeconomics Federal Reserve Bank of San Francisco [[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] question about the tisPlot function in package tis
Sorry that should have been: library(zoo) z - as.zoo(dat, class = yearmon) plot(z) xyplot(z) On Tue, Dec 2, 2008 at 2:35 PM, Gabor Grothendieck [EMAIL PROTECTED] wrote: The development version of zoo has a tis to zoo conversion function that would allow you to plot your data using plot.zoo and xplot.zoo in which case you can use classic graphics axis function (for plot.zoo) or lattice facilities (with xyplot.zoo): source(http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/*checkout*/pkg/R/as.zoo.tis.R?rev=524root=zoo;) z - as.zoo(dat, class = yearmon) plot(dat) xyplot(dat) There are many examples at ?plot.zoo and ?xyplot.zoo and in the three zoo vignettes. On Tue, Dec 2, 2008 at 1:49 PM, [EMAIL PROTECTED] wrote: List, I am using the 'tisPlot' function in Jeff Hallman's excellent tis package and was hoping that someone could spare me from having to dig into the code of his 'tisPlot' function. So far as I can tell, the preferred method of controlling the plotting of the x-axis is using the 'xTickFreq' and 'xTickSkip' options. Unfortunately, the where the data ends up on the resultant plot is not invariant to this choice, as indicated in the documentation of the 'xTickFreq' option. Has anyone adjusted the frequency of their x-axis label using this package before? I imagine that there must be a better way of doing what I am trying to accomplish, but if not, does anyone have a suggestion on how to work around this without digging into the function itself? ## an example library(tis) strt - ti(2101, monthly) dat - tis(runif(9*12 - 1), start=strt) # ends in 11/2008 par(mfrow=c(2,1)) tisPlot(dat, xTickFreq=monthly, xTickSkip=6) # graph ends in 11/2008, but looks to start some time in late 1999 tisPlot(dat, xTickFreq=monthly, xTickSkip=12) # graph looks to end around 3/2009 ## end TIA, Kyle ___ Research Associate, Macroeconomics Federal Reserve Bank of San Francisco [[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] Bug in transform?
Prof Brian Ripley wrote: As the help page says If some of the values are not vectors of the appropriate length, you deserve whatever you get! Yes (did I write that?). It is a bit annoying with things that almost work, though. [snip] I often need to use this for creating new variables in data frame from those already present. Sorely needed!! Just learn to use indexing: transform() is just syntactic sugar that you are not making use of. ...at least when you're not making use of the scoping aspects. And if you calculate at least one vector of full length, then the issue goes away. transform(aq, a=1,b=2) Error in data.frame(`_data`, e[!matched]) : arguments imply differing number of rows: 6, 1 transform(aq, a=1,b=2,o=Ozone) Ozone Solar.R Wind Temp Month Day a b o 3 12 149 12.6 74 5 3 1 2 12 31 37 279 7.4 76 5 31 1 2 37 34 NA 242 16.1 67 6 3 1 2 NA 65 NA 101 10.9 84 7 4 1 2 NA 59 NA 98 11.5 80 6 28 1 2 NA 13324 259 9.7 73 9 10 1 2 24 The underlying issue is actually not in transform() but in data.frame(): aq - airquality[sample(1:153,6),] data.frame(aq, list(a=1,b=2)) Error in data.frame(aq, list(a = 1, b = 2)) : arguments imply differing number of rows: 6, 1 data.frame(aq, list(a=1)) Ozone Solar.R Wind Temp Month Day a 3 12 149 12.6 74 5 3 1 31 37 279 7.4 76 5 31 1 34 NA 242 16.1 67 6 3 1 65 NA 101 10.9 84 7 4 1 59 NA 98 11.5 80 6 28 1 13324 259 9.7 73 9 10 1 -- O__ Peter Dalgaard Øster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 on lmer function
Thanks Harold, I will review the lmer vignette again. On Tue, Dec 2, 2008 at 2:12 PM, Doran, Harold [EMAIL PROTECTED] wrote: Richard There is much more information that you need to provide before a thoughtful answer can be provided. Maybe you can describe the structure of your data, your outcome variable, etc. There is a vignette in the lmer package called 'Implementation' that will show you some methods for model fitting. With that said, at the most basic level, a model of the form response = \mu + beta(covariate) + a_j + e_ij, a_j ~ N(0,r^2), e_ij ~ N(0, s^2) Might be as follows in lmer lmer(response ~ covariate + (1|covariate), ... ) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Richard Palmer Sent: Tuesday, December 02, 2008 1:40 PM To: r-help@r-project.org Subject: [R] question on lmer function suppose something like probability(passing test) is driven by 1. fixed effects -- sex 2. district effects - district funding 3. school effects - neighborhood income, racial composition, % two parent families, ... 4. class effects - teacher quality measurement, 5. individual random effects - IQ. how would such a model be setup in lmer? I can't find much discussion on the web. Is there extended documentation somewhere on lmer? Richard Palmer Home 508 877-3862 Cell 508 982-7266 [[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. -- Richard Palmer Home 508 877-3862 Cell 508 982-7266 [[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] match
Tena koe Robert You could first apply paste apply(types, 1, paste, collapse=':') and then match. HTH Peter Alspach -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of threshold Sent: Wednesday, 3 December 2008 8:32 a.m. To: r-help@r-project.org Subject: [R] match Hi, I would like to check which rows of 'types.prev' matrix pop up in 'types', following R in-built procedure. I tried 'match' function but it works in case of the one dimensional vectors. Will appreciate any suggestions. best, robert types edateK [1,] 20060819 12.5 [2,] 20060819 17.5 [3,] 20060819 22.5 [4,] 20070217 12.5 [5,] 20060617 10.0 [6,] 20060617 15.0 [7,] 20060520 12.5 [8,] 20060520 15.0 [9,] 20060520 17.5 [10,] 20061118 10.0 [11,] 20061118 12.5 [12,] 20061118 15.0 [13,] 20061118 17.5 types.prev edateK [1,] 20060819 10.0 [2,] 20060819 12.5 [3,] 20060819 17.5 [4,] 20070217 10.0 [5,] 20070217 12.5 [6,] 20070217 15.0 [7,] 20060617 10.0 [8,] 20060617 12.5 [9,] 20060617 15.0 [10,] 20060617 20.0 [11,] 20060520 10.0 [12,] 20060520 12.5 [13,] 20060520 17.5 [14,] 20061118 12.5 [15,] 20061118 15.0 [16,] 20061118 17.5 -- View this message in context: http://www.nabble.com/match-tp20799206p20799206.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. The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Compiling R for 64-bit Windows (was Re: increasing memory limit in Windows Server 2008 64-bit)
Michael Styer wrote: So my next question is, does anyone have any thoughts about how significant a project it would be to compile R for 64-bit windows (using, e.g., the Portland Group compiler)? Based on our experiences at REvolution Computing, it's quite a significant project. We're the commercial company Peter Dalgaard alluded to last week (thanks for the advertising, Peter!) that is working on the port. It's taken quite a while, but we expect to have REvolution R for Windows 64-bit available for beta testing in January. If you (or anyone else) is interested in beta testing on Windows 64-bit please let me know. When it's released our 64-bit binary will come with a paid support contract but as Peter mentioned we'll be submitting the changes back to r-core and (assuming they're incorporated) you can try compiling it yourself at that point. We have found that there are idiosyncrasies amongst the different compilers and configurations on the Windows 64-bit platform; we're using the Intel compiler and your mileage may well vary with others. # David Smith -- David M Smith [EMAIL PROTECTED] Director of Community, REvolution Computing www.revolution-computing.com Tel: +1 (206) 577-4778 x3203 (Seattle, 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] Suppressing tick labels?
I am trying to suppress the tick labels on the x-axis of the following: barchart(richness[Wood==V]~Sample[Wood==V]) I have tried col.axis=white I have tried removing the axis all together with axes=FALSE I have tried xaxt=n I have also tried labels=c(label1, label2) to replace the default labels, based on reading that the defaults are only printed if an alternative isn't specified. But none of these is making any difference to the graphical output. I know these don't all do exactly the same thing, but I have just been trying to find something that makes any change in the right direction that might help me find a solution. Can any one help with this I am using Ubuntu 8.04 and R 2.8.0. Many thanks, Graham __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] linear functional relationships with heteroscedastic non-Gaussian errors - any packages around?
Isn't this a special case of structural equation modeling, handled by the 'sem' package? Spencer Jarle Brinchmann wrote: Thanks for the reply! On Tue, Dec 2, 2008 at 6:34 PM, Prof Brian Ripley [EMAIL PROTECTED] wrote: I wonder if you are using this term in its correct technical sense. A linear functional relationship is V = a + bU X = U + e Y = V + f e and f are random errors (often but not necessarily independent) with distributions possibly depending on U and V respectively. This is indeed what I mean, poor phrasing of me. What I have is the effectively the PDF for e f for each instance, and I wish to get a b. For Gaussian errors there are certainly various ways to approach it and the maximum-likelihood estimator is fine and is what I normally use when my errors are sort-of-normal. However in this instance my uncertainty estimates are strongly non-Gaussian and even defining the mode of the distribution becomes rather iffy so I really prefer to sample the likelihoods properly. Using the maximum-likelihood estimator naively in this case is not terribly useful and I have no idea what the derived confidence limits means. Ah well, I guess what I have to do at the moment is to use brute force and try to calculate P(a,b|X,Y) properly using a marginalisation over U (I hadn't done that before, I expect that was part of my problem). Hopefully that will give reasonable uncertainty estimates, lots of pain for a figure nobody will look at for much time :) Thanks, Jarle. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] linear functional relationships with heteroscedastic non-Gaussian errors - any packages around?
Yes I think so if the errors were normally distributed. Unfortunately I'm far from that but the combination of sem its bootstrap is a good way to deal with it in the normal case. I must admit as a non-statistician I'm a not 100% sure what the difference (if there is one) between a linear functional relationship and a linear structural equation model is as they both deal with hidden variables as far as I can see. J. On Tue, Dec 2, 2008 at 9:33 PM, Spencer Graves [EMAIL PROTECTED] wrote: Isn't this a special case of structural equation modeling, handled by the 'sem' package? Spencer Jarle Brinchmann wrote: Thanks for the reply! On Tue, Dec 2, 2008 at 6:34 PM, Prof Brian Ripley [EMAIL PROTECTED] wrote: I wonder if you are using this term in its correct technical sense. A linear functional relationship is V = a + bU X = U + e Y = V + f e and f are random errors (often but not necessarily independent) with distributions possibly depending on U and V respectively. This is indeed what I mean, poor phrasing of me. What I have is the effectively the PDF for e f for each instance, and I wish to get a b. For Gaussian errors there are certainly various ways to approach it and the maximum-likelihood estimator is fine and is what I normally use when my errors are sort-of-normal. However in this instance my uncertainty estimates are strongly non-Gaussian and even defining the mode of the distribution becomes rather iffy so I really prefer to sample the likelihoods properly. Using the maximum-likelihood estimator naively in this case is not terribly useful and I have no idea what the derived confidence limits means. Ah well, I guess what I have to do at the moment is to use brute force and try to calculate P(a,b|X,Y) properly using a marginalisation over U (I hadn't done that before, I expect that was part of my problem). Hopefully that will give reasonable uncertainty estimates, lots of pain for a figure nobody will look at for much time :) Thanks, Jarle. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] (no subject)
I have been using rpart to get trees. May someone help me with how I can do some logistic regression modelling to derive odds ratios on the branches. Also help on how to derive estimates on prediction error. -- Kind Regards, Jestinah Home Address: Brusselsepoortstraat 85 9000 Gent Belgium [[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] date operations
Hi all, I'm dealing with dates in R (2.7.2), but some basic operations raise a warning. Incompatible methods (+.Date, Ops.difftime) for + I saw this topic in this mailing list, but I do not understand what to do... cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html Do I have to convert Dates to numeric? Thanks in advance Christophe PS : R script used alpha2=as.Date(2008-12-21) alpha1=as.Date(2008-12-21)-as.Date(2008-10-26) alpha1 alpha2 alpha1+alpha2 [[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] optimization problem (optim vs. nlminb)
In case anyone is still reading this thread, I want to add this: In a current problem (a data-shy five-parameter nonlinear optimization), I found nlminb markedly more reliable than optim with method L-BFGS-B. In reviewing the fit I made, I found that optim only came close to its own minimum in about 13 of 120 trials (same data, different starting values). I previously said 97, but I was clearly looking at the wrong data! In contrast, nlminb came to that best answer in about 92 trials out of 120. The original poster might consider nlminb instead of optim. Because nonlinear optimization is sensitive to starting values, I would still advise solving the problem a number of times to see if a clear minimum solution emerges. -- Mike Prager, NOAA, Beaufort, NC * Opinions expressed are personal and not represented otherwise. * Any use of tradenames does not constitute a NOAA endorsement. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] QQ plots and boxcox
Dear R People: In the DASL library, there is a story about hot dogs. Here are the data: Beef186 495 Beef181 477 Beef176 425 Beef149 322 Beef184 482 Beef190 587 Beef158 370 Beef139 322 Beef175 479 Beef148 375 Beef152 330 Beef111 300 Beef141 386 Beef153 401 Beef190 645 Beef157 440 Beef131 317 Beef149 319 Beef135 298 Beef132 253 Meat173 458 Meat191 506 Meat182 473 Meat190 545 Meat172 496 Meat147 360 Meat146 387 Meat139 386 Meat175 507 Meat136 393 Meat179 405 Meat153 372 Meat107 144 Meat195 511 Meat135 405 Meat140 428 Meat138 339 Poultry 129 430 Poultry 132 375 Poultry 102 396 Poultry 106 383 Poultry 94 387 Poultry 102 542 Poultry 87 359 Poultry 99 357 Poultry 107 528 Poultry 113 513 Poultry 135 426 Poultry 142 513 Poultry 86 358 Poultry 143 581 Poultry 152 588 Poultry 146 522 Poultry 144 545 Here is my work: dog1.df - read.table(file=dog1.dat,as.is=F,header=F, + col.names=c(type,cal,sodium)) dog1.aov - aov(cal~type,data=dog1.df) summary(dog1.aov) Df Sum Sq Mean Sq F valuePr(F) type 2 17692.2 8846.1 16.074 3.862e-06 *** Residuals 51 28067.1 550.3 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 TukeyHSD(dog1.aov) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = cal ~ type, data = dog1.df) $type diff lwr upr p adj Meat-Beef 1.855882 -16.82550 20.53726 0.9688129 Poultry-Beef -38.085294 -56.76667 -19.40391 0.277 Poultry-Meat -39.941176 -59.36515 -20.51720 0.239 plot(dog1.aov) When I look at the QQ plot, it's quite snaky. I thought that doing a transformation (based on boxcox) would help with the snakiness. However, when I re-run with the transformation, it's still snaky. Any suggestions, please? Thanks, Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ggplot2 facet_wrap problem
Hadley, I don't know if I am doing something wrong or if it is ggplot please see the two graphs at the bottom of the page (code). melt.nut - (structure(list(RiverMile = c(119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L,
Re: [R] Suppressing tick labels?
[R] Suppressing tick labels? Graham Smith myotisone at gmail.com Tue Dec 2 21:26:03 CET 2008 I am trying to suppress the tick labels on the x-axis of the following: barchart(richness[Wood==V]~Sample[Wood==V]) Use the scales= argument. E.g. d-data.frame(richness=log(1:12), Wood=rep(c(S,V),each=6), Sample=rep(1:6,2)) barchart(richness[Wood==V]~Sample[Wood==V], data=d, scales=list(x=list(at=numeric(0), lab=character(0 You can get the tick positions and labels of your choice with scales: barchart(richness[Wood==V]~Sample[Wood==V], data=d, scales=list(x=list(at=c(2,5), lab=c(Two,Five Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.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] QQ plots and boxcox
Dear Erin, What you characterize as snaky might also be called bimodal and short-tailed. Try, e.g., plot(density(residuals(dog1.aov))) to see the bimodality more clearly. A Box-Cox transformation can correct skewness, but won't help here. I hope this helps, John -- John Fox, Professor Department of Sociology McMaster University Hamilton, Ontario, Canada web: socserv.mcmaster.ca/jfox -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Erin Hodgess Sent: December-02-08 4:28 PM To: r-help@r-project.org Subject: [R] QQ plots and boxcox Dear R People: In the DASL library, there is a story about hot dogs. Here are the data: Beef 186 495 Beef 181 477 Beef 176 425 Beef 149 322 Beef 184 482 Beef 190 587 Beef 158 370 Beef 139 322 Beef 175 479 Beef 148 375 Beef 152 330 Beef 111 300 Beef 141 386 Beef 153 401 Beef 190 645 Beef 157 440 Beef 131 317 Beef 149 319 Beef 135 298 Beef 132 253 Meat 173 458 Meat 191 506 Meat 182 473 Meat 190 545 Meat 172 496 Meat 147 360 Meat 146 387 Meat 139 386 Meat 175 507 Meat 136 393 Meat 179 405 Meat 153 372 Meat 107 144 Meat 195 511 Meat 135 405 Meat 140 428 Meat 138 339 Poultry 129 430 Poultry 132 375 Poultry 102 396 Poultry 106 383 Poultry 94 387 Poultry 102 542 Poultry 87 359 Poultry 99 357 Poultry 107 528 Poultry 113 513 Poultry 135 426 Poultry 142 513 Poultry 86 358 Poultry 143 581 Poultry 152 588 Poultry 146 522 Poultry 144 545 Here is my work: dog1.df - read.table(file=dog1.dat,as.is=F,header=F, + col.names=c(type,cal,sodium)) dog1.aov - aov(cal~type,data=dog1.df) summary(dog1.aov) Df Sum Sq Mean Sq F valuePr(F) type 2 17692.2 8846.1 16.074 3.862e-06 *** Residuals 51 28067.1 550.3 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 TukeyHSD(dog1.aov) Tukey multiple comparisons of means 95% family-wise confidence level Fit: aov(formula = cal ~ type, data = dog1.df) $type diff lwr upr p adj Meat-Beef 1.855882 -16.82550 20.53726 0.9688129 Poultry-Beef -38.085294 -56.76667 -19.40391 0.277 Poultry-Meat -39.941176 -59.36515 -20.51720 0.239 plot(dog1.aov) When I look at the QQ plot, it's quite snaky. I thought that doing a transformation (based on boxcox) would help with the snakiness. However, when I re-run with the transformation, it's still snaky. Any suggestions, please? Thanks, Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: [EMAIL PROTECTED] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] question about the tisPlot function in package tis
[EMAIL PROTECTED] writes: List, I am using the 'tisPlot' function in Jeff Hallman's excellent tis package and was hoping that someone could spare me from having to dig into the code of his 'tisPlot' function. So far as I can tell, the preferred method of controlling the plotting of the x-axis is using the 'xTickFreq' and 'xTickSkip' options. Unfortunately, the where the data ends up on the resultant plot is not invariant to this choice, as indicated in the documentation of the 'xTickFreq' option. Has anyone adjusted the frequency of their x-axis label using this package before? I imagine that there must be a better way of doing what I am trying to accomplish, but if not, does anyone have a suggestion on how to work around this without digging into the function itself? ## an example library(tis) strt - ti(2101, monthly) dat - tis(runif(9*12 - 1), start=strt) # ends in 11/2008 par(mfrow=c(2,1)) tisPlot(dat, xTickFreq=monthly, xTickSkip=6) # graph ends in 11/2008, but looks to start some time in late 1999 tisPlot(dat, xTickFreq=monthly, xTickSkip=12) # graph looks to end around 3/2009 Try this: tisPlot(dat, xTickFreq = annual, xMinorTickFreq = monthly) I don't understand what you mean by where the data ends up on the resultant plot is not invariant to this choice, as indicated in the documentation of the 'xTickFreq' option. The documentation for xTickFreq says: xTickFreq: a string like the ones returned by 'tifName'. This argument and 'xTickSkip' jointly specify locations for labeled x axis ticks as follow: (i) find the 'ti''s of the given frequency that correspond to 'xAxisMin' and 'xAxisMax', then (ii) including those as endpoints, generate a sequence of every 'xTickSkip''th 'ti' between them. Two special strings can also be given. none means no labelled tick marks, while auto tries (not always successfully) to come up with reasonable tick locations automatically. auto also overrides any 'xTickSkip' setting. The default is auto. which does not indicate that your data points are moved. At any rate, please try my suggestion above, which gives a pretty nice axis for your time range. Jeff __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] simultaneous plots
Is there a good and concise way of making simultaneous plots that are identical, but directed to different devices? I'm writing an R-script that produces a pdf file. I would really like to check visually whether the pdf file shows what I expect. So I would like the same commands to produce a plot on screen. At the moment I'm using cut-and-paste, which is not ideal because any corrections have to be done twice---very error-prone. Thanks David -- View this message in context: http://www.nabble.com/simultaneous-plots-tp20802447p20802447.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] fGarch and is.na()
Thanks for the report, the problem boils down to the call of methods:::bind_activation(TRUE) in one of the depended package. I can reproduce the problem with methods:::bind_activation(TRUE) dfr - data.frame(matrix(0, nrow = 1 , ncol = 1000)) dfr2 - is.na(dfr) I will forward you remark to the R-dev mailing list. regards, Yohan FL == Felix Lamp [EMAIL PROTECTED] on Tue, 2 Dec 2008 15:06:37 +0100 FL Hello, FL FL after loading package fGarch the function is.na.data.frame() is behaving different: FL FL sessionInfo() FL R version 2.8.0 (2008-10-20) FL i386-pc-mingw32 FL FL locale: FL LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 FL FL attached base packages: FL [1] stats graphics grDevices utils datasets methods base FL FL dfr - data.frame(matrix(0,nrow = 1 , ncol = 1000)) FL dfr2 - is.na(dfr) FL FL require(fGarch) FL Loading required package: fGarch FL Loading required package: timeDate FL Loading required package: timeSeries FL Loading required package: fBasics FL Loading required package: MASS FL FL dfr2 - is.na(dfr) FL Error: evaluation nested too deeply: infinite recursion / options(expressions=)? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] sampling from data.frame
Hi all, I have a data frame with clustered rows as follows: Cu1 x1 y1 z1 ... Cu1 x2 y2 z2 ... Cu1 x3 y3 z3 ... # end of first cluster Cu1 Cu2 x4 y4 z4 ... Cu2 x5 y5 z5 Cu2 ... # end of second cluster Cu2 Cu3 ... ... cluster-size is 3 in the example above (rows making up a cluster are always consecutive). Is there any faster way to sample n clusters (with replacement) from this dataframe and build up a new data frame out of these sampled clusters? I use the sample function and a for-loop. Thanks in advance Armin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ggplot2 45deg axis labels
I would like to rotate the axis labels 45 deg. -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] date operations
'str' is your friend. Look at the results: alpha2=as.Date(2008-12-21) alpha1=as.Date(2008-12-21)-as.Date(2008-10-26) alpha1 Time difference of 56 days alpha2 [1] 2008-12-21 alpha1+alpha2 Time difference of 14290 days Warning message: Incompatible methods (Ops.difftime, +.Date) for + str(alpha1) Class 'difftime' atomic [1:1] 56 ..- attr(*, units)= chr days str(alpha2) Class 'Date' num 14234 alpha1 is not of the Date class. On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang [EMAIL PROTECTED] wrote: Hi all, I'm dealing with dates in R (2.7.2), but some basic operations raise a warning. Incompatible methods (+.Date, Ops.difftime) for + I saw this topic in this mailing list, but I do not understand what to do... cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html Do I have to convert Dates to numeric? Thanks in advance Christophe PS : R script used alpha2=as.Date(2008-12-21) alpha1=as.Date(2008-12-21)-as.Date(2008-10-26) alpha1 alpha2 alpha1+alpha2 [[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] date operations
If you want to do the addition, 'unclass' the variable: alpha2+4 [1] 2008-12-25 alpha2 + unclass(alpha1) [1] 2009-02-15 On Tue, Dec 2, 2008 at 4:10 PM, Christophe Dutang [EMAIL PROTECTED] wrote: Hi all, I'm dealing with dates in R (2.7.2), but some basic operations raise a warning. Incompatible methods (+.Date, Ops.difftime) for + I saw this topic in this mailing list, but I do not understand what to do... cf. https://stat.ethz.ch/pipermail/r-help/2008-June/165842.html Do I have to convert Dates to numeric? Thanks in advance Christophe PS : R script used alpha2=as.Date(2008-12-21) alpha1=as.Date(2008-12-21)-as.Date(2008-10-26) alpha1 alpha2 alpha1+alpha2 [[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] ggplot2 facet_wrap problem
Hi Stephen, I think you will need to clarify what your problem is with the second plot. HTH, Thierry -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] namens stephen sefick Verzonden: di 2-12-2008 22:52 Aan: hadley wickham; R-help Onderwerp: [R] ggplot2 facet_wrap problem Hadley, I don't know if I am doing something wrong or if it is ggplot please see the two graphs at the bottom of the page (code). melt.nut - (structure(list(RiverMile = c(119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L,
Re: [R] ggplot2 45deg axis labels
Hi Stephen, Have a look at the ggplot2 book. You will find an example on p. 6 of http://had.co.nz/ggplot2/book/polishing.pdf HTH, Thierry -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] namens stephen sefick Verzonden: wo 3-12-2008 0:31 Aan: R-help Onderwerp: [R] ggplot2 45deg axis labels I would like to rotate the axis labels 45 deg. -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 45deg axis labels
Hi Stephen, Have a look at the polishing your plot for publication chapter of the ggplot2 book. Regards, Hadley On Tue, Dec 2, 2008 at 5:31 PM, stephen sefick [EMAIL PROTECTED] wrote: I would like to rotate the axis labels 45 deg. -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sampling from data.frame
Not sure exactly what you mean by 'sample' since you did not provide an example of the expected output, or input data that could be used. Here is an example of taking one sample from each cluster: df - data.frame(id=paste(C, rep(1:5, each=3), sep=''), data=1:15) # sample 1 from each cluster result - lapply(split(seq(nrow(df)), df$id), function(.indx){ + df[sample(.indx, 1),] + }) do.call(rbind,result) id data C1 C11 C2 C24 C3 C39 C4 C4 11 C5 C5 15 result - lapply(split(seq(nrow(df)), df$id), function(.indx){ + df[sample(.indx, 1),] + }) do.call(rbind,result) id data C1 C12 C2 C26 C3 C39 C4 C4 11 C5 C5 15 result - lapply(split(seq(nrow(df)), df$id), function(.indx){ + df[sample(.indx, 1),] + }) do.call(rbind,result) id data C1 C13 C2 C24 C3 C38 C4 C4 10 C5 C5 13 On Tue, Dec 2, 2008 at 6:27 PM, axionator [EMAIL PROTECTED] wrote: Hi all, I have a data frame with clustered rows as follows: Cu1 x1 y1 z1 ... Cu1 x2 y2 z2 ... Cu1 x3 y3 z3 ... # end of first cluster Cu1 Cu2 x4 y4 z4 ... Cu2 x5 y5 z5 Cu2 ... # end of second cluster Cu2 Cu3 ... ... cluster-size is 3 in the example above (rows making up a cluster are always consecutive). Is there any faster way to sample n clusters (with replacement) from this dataframe and build up a new data frame out of these sampled clusters? I use the sample function and a for-loop. Thanks in advance Armin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ggplot2 facet_wrap problem
If you look at the TSS graph in the faceted example and then look at the plot of just the GPP vs. TSS. They are different graphs all together. The one that is not faceted is correct. On Tue, Dec 2, 2008 at 6:36 PM, ONKELINX, Thierry [EMAIL PROTECTED] wrote: Hi Stephen, I think you will need to clarify what your problem is with the second plot. HTH, Thierry -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] namens stephen sefick Verzonden: di 2-12-2008 22:52 Aan: hadley wickham; R-help Onderwerp: [R] ggplot2 facet_wrap problem Hadley, I don't know if I am doing something wrong or if it is ggplot please see the two graphs at the bottom of the page (code). melt.nut - (structure(list(RiverMile = c(119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 202L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 215L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 61L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 119L, 148L, 148L, 148L, 148L, 148L, 148L, 148L, 179L, 179L, 179L, 179L, 179L, 179L, 179L, 185L, 185L, 185L, 185L, 185L, 185L, 185L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 190L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 198L, 202L, 202L, 202L, 202L, 202L,
[R] help on tapply using sample with differing sample-sizes
Hello, My question likely got buried so I am reposting it in the hopes that someone has an answer. I have thought more about the question and modified my question. I hope tha my specific question is: I am attempting to create a bootstrap procedure for a finite sample using the theory of Rao and Wu, JASA (1988) that replicates within each strata (h) n_h - 1 times. To this end, I require a different sample size for each stratum. Unfortunately, it appears that the sample command which is used to obtain my resamples only allows a scalar for the sample size. i.e it does not currently work with a vector. Does any one have any suggestions as to how to get around this or if this is not possible, if there is another way to accomplish what I want to do. Perhaps, tapply is not the best way to go about getting what I want. if so what would all you strong programmers reccommend instead. I am thinking that perhaps loops may be the only way to go. raoboot - function (datavar, statavar, weight, nboot, ciqntl, ciqntu) { i - 1 sdatavar - sort(datavar) sstratavar - sort(statavar) sweight - sort(weight) sdatavarwght - sdatavar*sweight # stramn - tapply(sdatavar, sstratavar, mean) meanvect - rep(0, times = nboot) stratasize - tapply(sdatavarwght, sstratavar, length) stratasizemone - stratasize -1 while (i nboot) { #vector of resampled observations vectobsrestemp - tapply(sdatavarwght, sstratavar, sample, replace = T, size = stratasizemone) vectobsres - unlist(vectobsrestemp) meanvect[i] - mean(vectobsres) i - i + 1 } repvectboot - rep(mean(meanvect), times = i) vb - sum((repvectboot - meanvect)^2)/(i -1) lwrbndmnp - quantile(meanvect, ciqntl) uppbndmnp - quantile(meanvect, ciqntu) vb } __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 with maps
A few questions about maps... (1) How can I find a listing of the internal data sets that map() from the maps library contains? For example, usa, county, state, nz all work. Are there any others? (2) Is there an easier, more generalized way to produce this (http://www.ai.rug.nl/~hedderik/R/US2004/ ) type of plot than this (http://www.ai.rug.nl/~hedderik/R/US2004/map.r ) ? I have geographic (e.g. country, state, county, zip code) count data in a data frame that I would like to represent on a map, but still need to study how map.r works, especially the map.center function... (3) The examples at http://had.co.nz/ggplot2/coord_map.html are great. Adding another example that with color codes for counts from a data frame would be very useful too. (4) Is there a reason why I can produce a map of France but not the UK ? library(maps) library(ggplot2) library(mapproj) (qplot(x, y, data=(data.frame(map(france, plot=FALSE)[c(x,y)])), geom=path)) + coord_map() (qplot(x, y, data=(data.frame(map(uk, plot=FALSE)[c(x,y)])), geom=path)) + coord_map() Error in get(dbname) : variable ukMapEnv was not found In addition: Warning message: In data(list = dbname) : data set 'ukMapEnv' not found ( version 2.8.0, on win xp currently) Thanks in advance, Avram __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with maps
On Tue, Dec 2, 2008 at 6:21 PM, Avram Aelony [EMAIL PROTECTED] wrote: A few questions about maps... (1) How can I find a listing of the internal data sets that map() from the maps library contains? For example, usa, county, state, nz all work. Are there any others? help(package = maps) (2) Is there an easier, more generalized way to produce this (http://www.ai.rug.nl/~hedderik/R/US2004/ ) type of plot than this (http://www.ai.rug.nl/~hedderik/R/US2004/map.r ) ? I have geographic (e.g. country, state, county, zip code) count data in a data frame that I would like to represent on a map, but still need to study how map.r works, especially the map.center function... Yes, it's about six lines of ggplot2 code. But a lot depends on the format of your data, so if you could provide a reproducible example of what you're trying to do, that would be very helpful. (3) The examples at http://had.co.nz/ggplot2/coord_map.html are great. Adding another example that with color codes for counts from a data frame would be very useful too. qplot(..., colour = count) ? (4) Is there a reason why I can produce a map of France but not the UK ? library(maps) library(ggplot2) library(mapproj) (qplot(x, y, data=(data.frame(map(france, plot=FALSE)[c(x,y)])), geom=path)) + coord_map() (qplot(x, y, data=(data.frame(map(uk, plot=FALSE)[c(x,y)])), geom=path)) + coord_map() Error in get(dbname) : variable ukMapEnv was not found In addition: Warning message: In data(list = dbname) : data set 'ukMapEnv' not found map('world', regions=uk) Hadley -- 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.
[R] how to handle irregularly spaced data as timeseries
I have a set of modeled climate data recorded at irregular intervals. The format of the data is such that there are monthly measurements for the years 2000, 2020, 2050, 2080, etc. Therefore I have 12 regular records, a skip of some number of years, then 12 more monthly records, another skip, and so on I created a dataframe from .txt with the read.table() command. For starters I need to simply plot the data as a timeseries with DATE on the x axis. I am just getting my feet wet with R, so I'm struggling a bit to follow the help() pages. Can anyone point me in the proper direction? Thank you in advance. Here is a piece of the dataframe: cloq.worldclim.HADCM3.A2a DATE YEAR MONTH DAY DOY TMAX TMINPAR PRECIP 1 15-Jan-2000 2000 1 15 16 -7.2 -19.7 334.992.5 2 15-Feb-2000 2000 2 15 46 -3.5 -16.8 471.481.7 3 15-Mar-2000 2000 3 15 75 2.7 -9.4 636.964.1 4 15-Apr-2000 2000 4 15 106 11.3 -2.1 726.605.6 5 15-May-2000 2000 5 15 136 18.9 3.3 767.508.3 6 15-Jun-2000 2000 6 15 167 23.8 8.3 783.51 10.3 7 15-Jul-2000 2000 7 15 197 26.9 12.1 827.879.9 8 15-Aug-2000 2000 8 15 228 25.3 11.2 775.03 10.1 9 15-Sep-2000 2000 9 15 259 19.7 6.7 649.839.2 10 15-Oct-2000 200010 15 289 13.3 1.1 500.146.2 11 15-Nov-2000 200011 15 320 3.1 -6.3 349.144.4 12 15-Dec-2000 200012 15 350 -4.8 -15.4 293.072.9 13 15-Jan-2020 2020 1 15 16 -7.4 -19.6 334.992.5 14 15-Feb-2020 2020 2 15 46 -3.1 -16.2 471.481.7 15 15-Mar-2020 2020 3 15 75 3.0 -8.7 636.964.9 16 15-Apr-2020 2020 4 15 106 12.9 -5.0 726.607.4 17 15-May-2020 2020 5 15 136 20.1 4.4 767.508.8 18 15-Jun-2020 2020 6 15 167 25.2 9.6 783.51 10.4 19 15-Jul-2020 2020 7 15 197 28.9 13.6 827.879.4 20 15-Aug-2020 2020 8 15 228 27.3 13.1 775.03 11.6 21 15-Sep-2020 2020 9 15 259 22.0 8.8 649.839.6 22 15-Oct-2020 202010 15 289 15.4 2.6 500.146.8 23 15-Nov-2020 202011 15 320 4.3 -4.8 349.144.8 24 15-Dec-2020 202012 15 350 -4.1 -14.3 293.072.5 25 15-Jan-2050 2050 1 15 16 -5.5 -17.3 334.993.2 26 15-Feb-2050 2050 2 15 46 -1.7 -14.2 471.481.8 27 15-Mar-2050 2050 3 15 75 4.0 -7.1 636.965.1 28 15-Apr-2050 2050 4 15 106 13.4 -3.0 726.607.1 29 15-May-1950 2050 5 15 136 21.7 5.8 767.508.4 30 15-Jun-2050 2050 6 15 167 27.2 11.2 783.519.5 31 15-Jul-2050 2050 7 15 197 31.2 15.3 827.879.4 32 15-Aug-2050 2050 8 15 228 30.4 15.0 775.039.6 33 15-Sep-2050 2050 9 15 259 23.8 10.1 649.83 10.3 34 15-Oct-2050 205010 15 289 16.6 3.9 500.147.7 35 15-Nov-2050 205011 15 320 5.5 -3.6 349.145.3 36 15-Dec-2050 205012 15 350 -3.3 -13.2 293.072.5 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 handle irregularly spaced data as timeseries
Have a look at the zoo package. There are three vignettes (pdf documents) included with the package that give many examples of its use. Also see ?read.zoo, ?plot.zoo and ?xyplot.zoo You will need something like: library(zoo) z - read.zoo(myfile, ...whatever...) plot(z) On Tue, Dec 2, 2008 at 7:47 PM, Kirk Wythers [EMAIL PROTECTED] wrote: I have a set of modeled climate data recorded at irregular intervals. The format of the data is such that there are monthly measurements for the years 2000, 2020, 2050, 2080, etc. Therefore I have 12 regular records, a skip of some number of years, then 12 more monthly records, another skip, and so on I created a dataframe from .txt with the read.table() command. For starters I need to simply plot the data as a timeseries with DATE on the x axis. I am just getting my feet wet with R, so I'm struggling a bit to follow the help() pages. Can anyone point me in the proper direction? Thank you in advance. Here is a piece of the dataframe: cloq.worldclim.HADCM3.A2a DATE YEAR MONTH DAY DOY TMAX TMINPAR PRECIP 1 15-Jan-2000 2000 1 15 16 -7.2 -19.7 334.992.5 2 15-Feb-2000 2000 2 15 46 -3.5 -16.8 471.481.7 3 15-Mar-2000 2000 3 15 75 2.7 -9.4 636.964.1 4 15-Apr-2000 2000 4 15 106 11.3 -2.1 726.605.6 5 15-May-2000 2000 5 15 136 18.9 3.3 767.508.3 6 15-Jun-2000 2000 6 15 167 23.8 8.3 783.51 10.3 7 15-Jul-2000 2000 7 15 197 26.9 12.1 827.879.9 8 15-Aug-2000 2000 8 15 228 25.3 11.2 775.03 10.1 9 15-Sep-2000 2000 9 15 259 19.7 6.7 649.839.2 10 15-Oct-2000 200010 15 289 13.3 1.1 500.146.2 11 15-Nov-2000 200011 15 320 3.1 -6.3 349.144.4 12 15-Dec-2000 200012 15 350 -4.8 -15.4 293.072.9 13 15-Jan-2020 2020 1 15 16 -7.4 -19.6 334.992.5 14 15-Feb-2020 2020 2 15 46 -3.1 -16.2 471.481.7 15 15-Mar-2020 2020 3 15 75 3.0 -8.7 636.964.9 16 15-Apr-2020 2020 4 15 106 12.9 -5.0 726.607.4 17 15-May-2020 2020 5 15 136 20.1 4.4 767.508.8 18 15-Jun-2020 2020 6 15 167 25.2 9.6 783.51 10.4 19 15-Jul-2020 2020 7 15 197 28.9 13.6 827.879.4 20 15-Aug-2020 2020 8 15 228 27.3 13.1 775.03 11.6 21 15-Sep-2020 2020 9 15 259 22.0 8.8 649.839.6 22 15-Oct-2020 202010 15 289 15.4 2.6 500.146.8 23 15-Nov-2020 202011 15 320 4.3 -4.8 349.144.8 24 15-Dec-2020 202012 15 350 -4.1 -14.3 293.072.5 25 15-Jan-2050 2050 1 15 16 -5.5 -17.3 334.993.2 26 15-Feb-2050 2050 2 15 46 -1.7 -14.2 471.481.8 27 15-Mar-2050 2050 3 15 75 4.0 -7.1 636.965.1 28 15-Apr-2050 2050 4 15 106 13.4 -3.0 726.607.1 29 15-May-1950 2050 5 15 136 21.7 5.8 767.508.4 30 15-Jun-2050 2050 6 15 167 27.2 11.2 783.519.5 31 15-Jul-2050 2050 7 15 197 31.2 15.3 827.879.4 32 15-Aug-2050 2050 8 15 228 30.4 15.0 775.039.6 33 15-Sep-2050 2050 9 15 259 23.8 10.1 649.83 10.3 34 15-Oct-2050 205010 15 289 16.6 3.9 500.147.7 35 15-Nov-2050 205011 15 320 5.5 -3.6 349.145.3 36 15-Dec-2050 205012 15 350 -3.3 -13.2 293.072.5 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] for loop looking for file names
I have a series of csv files in several folders. All begin with a 7 digit number and end with the letter E (eg. 0726016E.csv). I want to be able to read a file in to R, take some of the data out of it and store it in a matrix, then move on to the next file and do the same thing. I was planning on using a for loop for the digits at the start of the file name, but I'm not sure how I can append the letter to the end of the number string. I'm also open to any ideas other than the for loop. Thanks, Steven Kennedy == The information contained in this e-mail message may be confidential information, and may also be privileged. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. If you have received this message in error, please notify us by return email and delete the original message. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] for loop looking for file names
To get the file names in the current directory try: list.files(pattern=[[:digit:]]{7}E) On Tue, Dec 2, 2008 at 4:11 PM, Steven Kennedy [EMAIL PROTECTED] wrote: I have a series of csv files in several folders. All begin with a 7 digit number and end with the letter E (eg. 0726016E.csv). I want to be able to read a file in to R, take some of the data out of it and store it in a matrix, then move on to the next file and do the same thing. I was planning on using a for loop for the digits at the start of the file name, but I'm not sure how I can append the letter to the end of the number string. I'm also open to any ideas other than the for loop. Thanks, Steven Kennedy == The information contained in this e-mail message may be confidential information, and may also be privileged. If you are not the intended recipient, any use, interference with, disclosure or copying of this material is unauthorised and prohibited. If you have received this message in error, please notify us by return email and delete the original message. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Help with maps
On Tuesday, December 02, 2008, at 04:40PM, hadley wickham [EMAIL PROTECTED] wrote: On Tue, Dec 2, 2008 at 6:21 PM, Avram Aelony [EMAIL PROTECTED] wrote: A few questions about maps... (1) How can I find a listing of the internal data sets that map() from the maps library contains? For example, usa, county, state, nz all work. Are there any others? help(package = maps) Thanks for this. (2) Is there an easier, more generalized way to produce this (http://www.ai.rug.nl/~hedderik/R/US2004/ ) type of plot than this (http://www.ai.rug.nl/~hedderik/R/US2004/map.r ) ? I have geographic (e.g. country, state, county, zip code) count data in a data frame that I would like to represent on a map, but still need to study how map.r works, especially the map.center function... Yes, it's about six lines of ggplot2 code. But a lot depends on the format of your data, so if you could provide a reproducible example of what you're trying to do, that would be very helpful. What format is best? I don't really have an example, because I only have a data frame with geo and count data. The map() function gives me the following d - data.frame(map(county, plot=FALSE)[c(x,y)]) head head(d) xy 1 -86.81457 32.34920 #presumably latitudes and longitudes ??? 2 -86.81457 32.33774 3 -86.80311 32.32628 4 -86.79737 32.32055 5 -86.78019 32.32628 6 -86.78019 32.34347 and I am not sure how to join this with data from a csv formatted file with columns for country, state, county, zip code, a, b, c, where a,b,c are integers. Ideally, I'd like to show a map of the US by county that represents the sum of all a in that county with darker colors for larger values of x ... Then I'd like to do the same for the UK. If I could do the same at the zip code level for certain counties, that would be even better. (3) The examples at http://had.co.nz/ggplot2/coord_map.html are great. Adding another example that with color codes for counts from a data frame would be very useful too. qplot(..., colour = count) ? Doesn't that assume that county names and associated counts are mapped to lat/lon ? How does the map() function understand france or county so that it can do this internally? I'd like map() to figure out the lat/lon details. head head(d) xy 1 -86.81457 32.34920 2 -86.81457 32.33774 3 -86.80311 32.32628 Doesn't each row correspond to a vertex? How to get from vertices to county names with associated counts? (4) Is there a reason why I can produce a map of France but not the UK ? library(maps) library(ggplot2) library(mapproj) (qplot(x, y, data=(data.frame(map(france, plot=FALSE)[c(x,y)])), geom=path)) + coord_map() (qplot(x, y, data=(data.frame(map(uk, plot=FALSE)[c(x,y)])), geom=path)) + coord_map() Error in get(dbname) : variable ukMapEnv was not found In addition: Warning message: In data(list = dbname) : data set 'ukMapEnv' not found map('world', regions=uk) This produces a very small UK in the upper left quadrant. Hadley -- http://had.co.nz/ thanks again in advance __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.