[R] Thank you
Dear r-community, Today I have completed my PhD. I would like to take this opportunity to thank the r-community for helping me with the r-coding. I use r to do data manipulation during my PhD and I benefit a lot through the discussion in the r-forum. I will continue using R and help the others too. Thank you so much. Regards, Roslina UniSA. [[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] quantmod package
the code you posted works well except that when i am using chartSeries() it does not give any graphical stuff: chartSeries(P,type=auto) Error in if (on == years) { : missing value where TRUE/FALSE needed i also tried to store the entire getQuote output (OHLC object) by the above manner but it then reads the number in a format (i guess character) unsupported by the chartSeries(). -- View this message in context: http://r.789695.n4.nabble.com/quantmod-package-tp3921071p3947026.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] plotting large time series
A simple way may be not to plot all data points. But it will depend on your data if that is a good idea. Regards, Enrico ## EXAMPLE require(zoo) ## random data dates - seq(from = as.Date(2000-01-01), to = as.Date(2011-10-31), by = 1 day) x - cumsum(rnorm(length(dates))) ## plot all plot(zoo(x, dates), col = blue) ## plot every 100th point subs - seq(1, length(x), by = 10) lines(zoo(x[subs], dates[subs]), lwd = 2) Am 28.10.2011 02:46, schrieb jim holtman: Try another format (tiff, jpg, etc) to see how they look, what the sizes are for different resolutions. If you have a lot of single points, PDF files get very large because of the commands used to print each point. If you want to keep PDF, then find some way of aggregating the data points so that you plot an average of several of them. Depending on what you are trying to show, I have used the hexbin package to plot large numbers of points. Why do you need PDFs? Will something else do? On Thu, Oct 27, 2011 at 11:39 AM, Agnes Richardagnes.rich...@fhnw.ch wrote: hello, I got a problem with plotting large time series, since I want to store the results in a .PDF file (I want to store several pages of plots). The PDF files get too large to be handled ( 10MB, one was even 200MB big). So I wonder, if there would be a possibilty to either - reduce the file size of the PDF - change the way the plot is generated to reduce the plot size? I use: plot(myDate,myFile[,1],type=l,xlab=Date) using myts = as.ts(start=myDate[1],end=myDate[length(myDate)],x=myFile[,1]) plot.ts(myts,xlab=Date) produces the same file size. for storing the PDF I use: pdf(file=paste(outpath,myPDF.pdf,sep=''),paper=a4r). I would be very grateful for an answer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Enrico Schumann Lucerne, Switzerland http://nmof.net/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error installing packages
Hi Picohan, I notice that you install this to the c directory. If you are on windows 7, make sure R has proper write permissions. I collected some links about similar issues at this post: http://www.r-statistics.com/2011/04/how-to-upgrade-r-on-windows-7/ Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Thu, Oct 27, 2011 at 11:50 AM, picohan han...@picoquant.com wrote: Hello, I got an error if I try to install a package. For example package emg: R CMD check emg Everything is fine. R CMD INSTALL emg I got the following errors: * installing to library 'c:/R_2_13_1/library' * installing *source* package 'emg' ... Error in file_path_as_absolute(dfile) : Datei './DESCRIPTION' existiert nicht ERROR: installing package DESCRIPTION failed fo * removing 'c:/R_2_13_1/library/emg' * restoring previous 'c:/R_2_13_1/library/emg' It says, file DESCRIPTION is missing, despite it exists. The same behavoir with other packages. I would be very pleased if someone can help me with that problem. cheers, Joerg -- View this message in context: http://r.789695.n4.nabble.com/Error-installing-packages-tp3943807p3943807.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. [[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] new R debugging tool
Hello Norm, I just noticed you posted this to the R help a while ago, and wanted to invite you to write some guest R post about your new debugging system for R (how to easily install/use it). I will gladly guest post it on my blog and then also on r-bloggers.com(where it is likely to get some good exposure) p.s: I got your book on my bookshelf, and hope to read it in this upcoming year. With regards, Tal Contact Details:--- Contact me: tal.gal...@gmail.com | 972-52-7275845 Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) | www.r-statistics.com (English) -- On Thu, Oct 20, 2011 at 12:22 AM, Norm Matloff matl...@cs.ucdavis.eduwrote: I've developed a new R debugging tool, debugR, available at http://heather.cs.ucdavis.edu/debugR.html This basically replaces my edtdbg, which I will no longer be supporting. The new tool is now decoupled from one's text editor, and has a lot more features than edtdbg did. Try it! Feedback is encouraged, of course. Norm Matloff __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] plotting large time series
On 10/28/2011 07:21 AM, Enrico Schumann wrote: A simple way may be not to plot all data points. But it will depend on your data if that is a good idea. Regards, Enrico ## EXAMPLE require(zoo) ## random data dates - seq(from = as.Date(2000-01-01), to = as.Date(2011-10-31), by = 1 day) x - cumsum(rnorm(length(dates))) ## plot all plot(zoo(x, dates), col = blue) ## plot every 100th point subs - seq(1, length(x), by = 10) lines(zoo(x[subs], dates[subs]), lwd = 2) Hi, I would only plot every 100th line if the plot itself is unreadable because the points obscure each other. When the problem is that the resulting file is too big, I would favor dumping the file to 'png' file instead of pdf. Making the dpi high enough ensures that the illustration is still publication ready. regards, Paul Am 28.10.2011 02:46, schrieb jim holtman: Try another format (tiff, jpg, etc) to see how they look, what the sizes are for different resolutions. If you have a lot of single points, PDF files get very large because of the commands used to print each point. If you want to keep PDF, then find some way of aggregating the data points so that you plot an average of several of them. Depending on what you are trying to show, I have used the hexbin package to plot large numbers of points. Why do you need PDFs? Will something else do? On Thu, Oct 27, 2011 at 11:39 AM, Agnes Richardagnes.rich...@fhnw.ch wrote: hello, I got a problem with plotting large time series, since I want to store the results in a .PDF file (I want to store several pages of plots). The PDF files get too large to be handled ( 10MB, one was even 200MB big). So I wonder, if there would be a possibilty to either - reduce the file size of the PDF - change the way the plot is generated to reduce the plot size? I use: plot(myDate,myFile[,1],type=l,xlab=Date) using myts = as.ts(start=myDate[1],end=myDate[length(myDate)],x=myFile[,1]) plot.ts(myts,xlab=Date) produces the same file size. for storing the PDF I use: pdf(file=paste(outpath,myPDF.pdf,sep=''),paper=a4r). I would be very grateful for an answer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Paul Hiemstra, Ph.D. Global Climate Division Royal Netherlands Meteorological Institute (KNMI) Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39 P.O. Box 201 | 3730 AE | De Bilt tel: +31 30 2206 494 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Downloading Error
Hi, I am trying to install qvalue, however its giving installation error - Error : package 'tcltk' does not have a name space ERROR: lazy loading failed for package qvalue * removing /home/sbw/R/x86_64-unknown-linux-gnu-library/2.12/qvalue The downloaded packages are in /tmp/RtmpKnS1X4/downloaded_packages Warning message: In install.packages(pkgs = pkgs, repos = repos, ...) : installation of package 'qvalue' had non-zero exit status Please help in resolving this error. Thank you, Deepthi BM PGDB-10-10-04 Institute of Bioinformatics and Applied Biotechnology Biotech Park, Electronic City, Phase I, Bengaluru-560100 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error installing packages
Thanks for the tip, but I am not on win 7, I am on win xp. -- View this message in context: http://r.789695.n4.nabble.com/Re-Error-installing-packages-tp3947187p3947308.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] RJava
Hello All, I have successfully installed rJava. I have written a sample code in java to check how it runs. the code successfully compiled. to compile i used javac --classpath /home/deepthi/R/x86_64-unknown-linux-gnu-library/2.13/rJava/jri/JRI.jar:/home/deepthi/R/x86_64-unknown-linux-gnu-library/2.13/JavaGD/java/javaGD.jar JRItest.java than to execute i used ./run JRItest This gave me the following error: Cannot find JRI native library! Please make sure that the JRI native library is in a directory listed in java.library.path. java.lang.UnsatisfiedLinkError: /home/deepthi/R/x86_64-unknown-linux-gnu-library/2.13/rJava/jri/libjri.so: libblas.so.3gf: cannot open shared object file: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1807) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1732) at java.lang.Runtime.loadLibrary0(Runtime.java:823) at java.lang.System.loadLibrary(System.java:1028) at org.rosuda.JRI.Rengine.clinit(Rengine.java:19) at JRItest.main(JRItest.java:22) Please help me to resolve this. Thank you, Deepthi BM PGDB-10-10-04 Institute of Bioinformatics and Applied Biotechnology Biotech Park, Electronic City, Phase I, Bengaluru-560100 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Difference between xyplot() and plot()
Hi, I draw two Plots, one with xyplot() and one with plot(). Why is the line with xyplot() not always in the middle of the dots like plot()? library(lattice) x-c(1,2,3,4,5,6) y-x plot.new() plot(x ~ y, main = Sequenz 1 und Sequenz 2, xlab=Sequenz 2, ylab=Sequenz 1, las=1) abline(a=0, b=1,col='red',lwd=2) and library(lattice) x-c(1,2,3,4,5,6) y-x plot.new() xyplot(x ~ y, main = Sequenz 1 und Sequenz 2, xlab=Sequenz 2, ylab=Sequenz 1, las=1) abline(a=0, b=1,col='red',lwd=2) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Difference between xyplot() and plot()
From: Jörg Reuter Why is the line with xyplot() not always in the middle of the dots like plot()? Because you used the base graphics command abline() on a lattice plot? They don't mix. The plot regions are different for lattice and base graphics - notice that the second abline doesn;t go to the window edges either. S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Difference between xyplot() and plot()
Thanks, i have it now: library(lattice) mein.panel - function(x, y){ panel.xyplot(x, y) panel.abline(a=0, b=1, lwd=2, col=red)} x-c(1,2,3,4,5,6) y-x xyplot(x ~ y, main = xyplot, xlab=Sequenz 2, ylab=Sequenz 1, las=1, panel=mein.panel) 2011/10/28 S Ellison s.elli...@lgcgroup.com: From: Jörg Reuter Why is the line with xyplot() not always in the middle of the dots like plot()? Because you used the base graphics command abline() on a lattice plot? They don't mix. The plot regions are different for lattice and base graphics - notice that the second abline doesn;t go to the window edges either. S Ellison *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error installing packages
Hi Picohan I had a really similar error messages recently when trying to install packages from sources and it was related to my version of windows not being in english. See this for a discussion: http://r.789695.n4.nabble.com/Building-package-DESCRIPTION-file-not-existing-td3935084.html Cheers, Francois Rousseu Date: Fri, 28 Oct 2011 02:11:24 -0700 From: han...@picoquant.com To: r-help@r-project.org Subject: Re: [R] Error installing packages Thanks for the tip, but I am not on win 7, I am on win xp. -- View this message in context: http://r.789695.n4.nabble.com/Re-Error-installing-packages-tp3947187p3947308.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. [[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] LATEX Command in R in Windows 7
On 27.10.2011 18:34, Baris Demiral wrote: Hi guys, I have 64-bit Windows 7 machine. I need to execute the latex and pdflatex commands from R to print out tables in pdf. I use R 2.13 64-bit, and I have GSView, GSScript and TexWorks installed. I remember i did this once but I forgot the next step. What shall I do? Thanks, Package tools has texi2dvi(). 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] creating vector os zeros for simulations (beginner's question)
Thank you all very much, specially Ellison. I have been looking at some codes for simulation and I am trying to recreate them to my needs, but I understand I'm probably not doing it in the most efficient way. What you said was very useful. I really want to create a series of vector of random numbers, because later I will multiply them to a matrix P (choleski decomposition of variance-covariance of the residuals of a VAR), so to create a serie of vectors of shocks that will be added to my predictions. The thing is, I wasn't able to construct the vectors of random numbers in a way they could be multiplied by the matrix P . Would you be so kind as to point again what is wrong? I am finding it very difficult to get it right in terms of what the object must be to be used the way I want, a list, a data.frame, matrix, etc What I want to do is this: 1 - create a serie of N random vectors (actually, each 5 colums and 1 row), in this exercise N=30 2 - Create the serie P, by multiplying each of the random vectors by the same matrix c (choleski decomposition), which is 5x5, to get the shocks that consider the correlation between the variables. 3 - Create serie prev, with the predictions one step ahead of the variables, by multiplying the matrix coef (coefficients of the VAR) to the last prediction and adding the vector P of shocks. What I tried was: # 1- different ways of creating the random vectors, to see if any multiply by c: N=30 # N = numero de periodos para computar a trajetoria da divida u2-list() for(i in 1:N) u2[[i]] - rnorm(5) u2 str(u2) u3 - as.data.frame(matrix(rnorm(150), nrow=N, ncol=5)) u3 str(u3) u4-list() for (i in 1:N) { u4[[i]]- matrix(rnorm(150), ncol=5, nrow=N) } u4 # 2- create serie P, of shocks ajusted by the correlations P2-matrix(0, ncol=N, nrow=5) P2 for(i in 1:N){ P2[i]-c%*%u2[i] } #but this is what i get: Error in c %*% u2[i] : requires numeric/complex matrix/vector arguments # i've tried taking out the [i], that doesn't work either. # tried also u3, u4 # obs- c is matrix 5x5: c rp igpm ereal crescpib jurosreal rp 0.2249159 -0.02046234 0.004685928 -0.0002799183 2.639328e-04 igpm 0.000 0.59823056 -0.577864072 0.0070967189 -5.797647e-03 ereal 0.000 0. 0.129118968 0.0007949951 -1.061969e-04 crescpib 0.000 0. 0.0 0.0236250353 2.646392e-05 jurosreal 0.000 0. 0.0 0.00 2.027526e-03 # 3 - create serie previ2, size=N, # obs - prev2[1] = vector z, of last observations prev2-c(z,rep(0,100)) prev2 for (i in 2:N) { prev2[i]-coef%*%prev2[i-1]+P2[i] } Once again, thank you very much for the kind help. Regards, Iara De: S Ellison s.elli...@lgcgroup.com Enviadas: Sexta-feira, 28 de Outubro de 2011 8:02 Assunto: RE: [R] creating vector os zeros for simulations (beginner's question) -Original Message- On Thu, Oct 27, 2011 at 1:44 PM, Iara Faria Dear R helpers, I know this is a simple task, but I'm new to R and I'm still havind difficulties with the language. I want to create 30 vectors to be used in a simulation, each with 1 columm and 5 lines, of random numbers N(0,1). What I tried was this: N=150 u2-rep(1:150,0) u2-list(matrix(0,5)) u2 for(i in 1:N) { u2[i]-rnorm(5) } u2 This line u2[i]-rnorm(5) should be written u2[[i]]-rnorm(5) u2[i] is a list element and ur[[i]] is the contents of the list element. Not quite the same thing. Your code could also be a great deal simpler as you don't need to generate a zero-filled list to start with. Try u2-list() for(i in 1:N) u2[[i]] - rnorm(5) But it's easier to generate the matrix version as Seb said. If you _really_ want a list - which can be useful, but is often unnecessary if you use apply() - you can also do u2 - as.data.frame(matrix(rnorm(150), nrow=5, ncol=30)) which, since a data frame is a list, is also a list. And while we're on the topic, look at lapply and other versions of apply be[[elided Yahoo spam]] ### also tried this: N=150 u2-rep((matrix(0,5)),30) u2 for(i in 1:N) { u2[i]-rnorm(5) } u2 The problem is none of this gives me the random numbers arranged in vectors. I've tried other variations too, but haven't managed to get it through. Any help is very welcome. Kind regards, Iara [[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,
Re: [R] Syntax Check: rshape2 melt()
On Thu, 27 Oct 2011, Rich Shepard wrote: Nope. Can't. Dan et al.: I apologize for the certainty; anything can happen to data as un-intended consequences of processing. I will write that there _should_ be no duplicates. What I'm going to do is re-read the data frame from the source text file that was written out from the postgres table, then subset only a single stream's worth of data as a test set. I'll obfuscate the identification (although the data have been submitted to the regulator over the decades) and make the set available to use if this new approach still has issues with dcast(). May not be until Monday that I return with results on this effort as I'm going to be carfully checking and documenting each step and its results. Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Equivalent of win.print for Linux
Hi! In Windows the win.print function allows plotting directly to a printer (or copying an open device to the printer). This is very convenient to quickly print a plot once it looks good. Is there an equivalent function under Linux? For example through CUPS, IPP, LPD or other ? Obviously with a printer on the parallel port one could write postscript(/dev/lp0) but what about network printers? Currently what I do is printing the open device to a postscript() file, open this file in a postscript viewer and print it from there. But I'm lazy and a win.print-like shortcut would be welcome. Thanks, Xavier PS: I'm running Ubuntu 10.04 64bit. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Downloading Error
Upgrade R and try again. Preferably use the release candidate version of the upcoming R-2.14.0. Uwe Ligges On 28.10.2011 11:10, bdeep...@ibab.ac.in wrote: Hi, I am trying to install qvalue, however its giving installation error - Error : package 'tcltk' does not have a name space ERROR: lazy loading failed for package ‘qvalue’ * removing ‘/home/sbw/R/x86_64-unknown-linux-gnu-library/2.12/qvalue’ The downloaded packages are in ‘/tmp/RtmpKnS1X4/downloaded_packages’ Warning message: In install.packages(pkgs = pkgs, repos = repos, ...) : installation of package 'qvalue' had non-zero exit status Please help in resolving this error. Thank you, Deepthi BM PGDB-10-10-04 Institute of Bioinformatics and Applied Biotechnology Biotech Park, Electronic City, Phase I, Bengaluru-560100 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Equivalent of win.print for Linux
I have never used, but take a look on ?dev.print On Fri, Oct 28, 2011 at 11:16 AM, Xavier Robin xavier.ro...@unige.chwrote: Hi! In Windows the win.print function allows plotting directly to a printer (or copying an open device to the printer). This is very convenient to quickly print a plot once it looks good. Is there an equivalent function under Linux? For example through CUPS, IPP, LPD or other ? Obviously with a printer on the parallel port one could write postscript(/dev/lp0) but what about network printers? Currently what I do is printing the open device to a postscript() file, open this file in a postscript viewer and print it from there. But I'm lazy and a win.print-like shortcut would be welcome. Thanks, Xavier PS: I'm running Ubuntu 10.04 64bit. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Atenciosamente, Raphael Saldanha saldanha.plan...@gmail.com [[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] Contrasts with an interaction
Windows XP R 2.12.1 contrast package. I am trying to understand how to create contrasts for a model that contatains an interaction. I can get contrasts to work for a model without interaction, but not after adding the interaction. Please see code below. The last two contrast statements show the problem. I would appreciate someone letting me know what is wrong with the syntax of my contrast statements. Thank you, John library(contrast) # Create 2x2 contingency table. counts=c(50,50,30,70) row -gl(2,2,4) column - gl(2,1,4) mydata - data.frame(row,column,counts) print(mydata) # Show levels of 2x2 table levels(mydata$row) levels(mydata$column) # Models, no interaction, and interaction fitglm0 - glm(counts ~ row + column, family=poisson(link=log)) fitglm - glm(counts ~ row + column + row*column, family=poisson(link=log)) # Contrasts for model without interaction works fine! anova(fitglm0) summary(fitglm0) con0-contrast(fitglm0,list(row=1,column=1)) print(con0,X=TRUE) # Contrast for model with interaction does not work. anova(fitglm) summary(fitglm) con-contrast(fitglm,list(row=1,column=1) print(con,X=TRUE) # Nor does this work. con-contrast(fitglm,list(row=1,column=1,row:column=c(0,0))) print(con,X=TRUE) 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.
Re: [R] Equivalent of win.print for Linux
Thanks Raphael, dev.print will create a copy of the device into another device, but it won't actually push the data to a paper printer unless that other device represents a printer device (as win.print does). Typically in Windows I use it together with win.print as dev.print(win.print, printer=blah) Now the question is, is there a printer device equivalent to win.print for Linux? Thanks, Xavier On Fri, Oct 28, 2011 at 15:23, Raphael Saldanha wrote: I have never used, but take a look on ?dev.print On Fri, Oct 28, 2011 at 11:16 AM, Xavier Robin xavier.ro...@unige.chwrote: Hi! In Windows the win.print function allows plotting directly to a printer (or copying an open device to the printer). This is very convenient to quickly print a plot once it looks good. Is there an equivalent function under Linux? For example through CUPS, IPP, LPD or other ? Obviously with a printer on the parallel port one could write postscript(/dev/lp0) but what about network printers? Currently what I do is printing the open device to a postscript() file, open this file in a postscript viewer and print it from there. But I'm lazy and a win.print-like shortcut would be welcome. Thanks, Xavier PS: I'm running Ubuntu 10.04 64bit. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Xavier Robin Biomedical Proteomics Research Group Department of Structural Biology and Bioinformatics Faculty of Medicine, University Medical Center University of Geneva 1, rue Michel Servet - CH-1211 Genève 4 - Switzerland Tel: (+41 22) 379 41 69 Fax: (+41 22) 379 59 84 xavier.ro...@unige.ch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Equivalent of win.print for Linux
See the help for postscript ... especially the 'Printing' section. On Fri, 28 Oct 2011, Xavier Robin wrote: Hi! In Windows the win.print function allows plotting directly to a printer (or copying an open device to the printer). This is very convenient to quickly print a plot once it looks good. Is there an equivalent function under Linux? For example through CUPS, IPP, LPD or other ? Obviously with a printer on the parallel port one could write postscript(/dev/lp0) but what about network printers? Currently what I do is printing the open device to a postscript() file, open this file in a postscript viewer and print it from there. But I'm lazy and a win.print-like shortcut would be welcome. Thanks, Xavier PS: I'm running Ubuntu 10.04 64bit. -- Brian D. Ripley, rip...@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 'for' in steps
Thank you Marc and David for your suggestions. I think Marc's is going to work nicely for what I need but I'll also try David's. Many thanks both Fiona -- View this message in context: http://r.789695.n4.nabble.com/for-in-steps-tp3946248p3947950.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] sorting data
I want to sort my following data set according to value in 4th column 0 1 0 27877.3044386212 15.8733019973557 2640.42407064348 0 1 1 27470.1699006254 35.4182473588807 2303.26461260826 0 1 2 27468.0314985496 38.4400363878507 2300.05521684593 0 1 3 27469.1130543141 40.7540672493746 2299.32564458085 0 1 4 27442.3152643187 52.4342875797706 2277.18286686329 0 1 5 27440.7923082136 54.8003481512783 2274.49112409585 . I tried following : first i wanted just to sort 4th column a-read.tables(file_namr) attributes(a) gives class as $class [1] data.frame and sort(a[4]) Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = decreasing)) : undefined columns selected How can I sort the data according to value in 4th column and print along with other columns -- Amar Kumar Nandan Karnataka, India, 560100 â:+91-9019054471 â:nandan.a...@gmail.com http://aknandan.co.nr [[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] sorting data
a - a[order(a[[4]]),] On Fri, Oct 28, 2011 at 10:01 AM, nandan amar nandan.a...@gmail.com wrote: I want to sort my following data set according to value in 4th column 0 1 0 27877.3044386212 15.8733019973557 2640.42407064348 0 1 1 27470.1699006254 35.4182473588807 2303.26461260826 0 1 2 27468.0314985496 38.4400363878507 2300.05521684593 0 1 3 27469.1130543141 40.7540672493746 2299.32564458085 0 1 4 27442.3152643187 52.4342875797706 2277.18286686329 0 1 5 27440.7923082136 54.8003481512783 2274.49112409585 . I tried following : first i wanted just to sort 4th column a-read.tables(file_namr) attributes(a) gives class as $class [1] data.frame and sort(a[4]) Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = decreasing)) : undefined columns selected How can I sort the data according to value in 4th column and print along with other columns -- Amar Kumar Nandan Karnataka, India, 560100 ☎:+91-9019054471 ✉:nandan.a...@gmail.com http://aknandan.co.nr [[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 Data Munger Guru 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] sorting data
I am not sure (I can't test at the moment) but will this work? sort(a[,4]) 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) nandan amar nandan.a...@gmail.com 10/28/2011 10:01 AM I want to sort my following data set according to value in 4th column 0 1 0 27877.3044386212 15.8733019973557 2640.42407064348 0 1 1 27470.1699006254 35.4182473588807 2303.26461260826 0 1 2 27468.0314985496 38.4400363878507 2300.05521684593 0 1 3 27469.1130543141 40.7540672493746 2299.32564458085 0 1 4 27442.3152643187 52.4342875797706 2277.18286686329 0 1 5 27440.7923082136 54.8003481512783 2274.49112409585 . I tried following : first i wanted just to sort 4th column a-read.tables(file_namr) attributes(a) gives class as $class [1] data.frame and sort(a[4]) Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = decreasing)) : undefined columns selected How can I sort the data according to value in 4th column and print along with other columns -- Amar Kumar Nandan Karnataka, India, 560100 ☎:+91-9019054471 ✉:nandan.a...@gmail.com http://aknandan.co.nr [[alternative HTML version deleted]] Confidentiality Statement: This email message, including any attachments, is for th...{{dropped:6}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] sorting data
Thanks to all, a - a[order(a[[4]]),] gives desired result sort(a[,4]) sorts the data a[4] regards,. On Fri, Oct 28, 2011 at 7:42 PM, John Sorkin jsor...@grecc.umaryland.eduwrote: I am not sure (I can't test at the moment) but will this work? sort(a[,4]) 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) nandan amar nandan.a...@gmail.com 10/28/2011 10:01 AM I want to sort my following data set according to value in 4th column 0 1 0 27877.3044386212 15.8733019973557 2640.42407064348 0 1 1 27470.1699006254 35.4182473588807 2303.26461260826 0 1 2 27468.0314985496 38.4400363878507 2300.05521684593 0 1 3 27469.1130543141 40.7540672493746 2299.32564458085 0 1 4 27442.3152643187 52.4342875797706 2277.18286686329 0 1 5 27440.7923082136 54.8003481512783 2274.49112409585 . I tried following : first i wanted just to sort 4th column a-read.tables(file_namr) attributes(a) gives class as $class [1] data.frame and sort(a[4]) Error in `[.data.frame`(x, order(x, na.last = na.last, decreasing = decreasing)) : undefined columns selected How can I sort the data according to value in 4th column and print along with other columns -- Amar Kumar Nandan Karnataka, India, 560100 â:+91-9019054471 â:nandan.a...@gmail.com http://aknandan.co.nr [[alternative HTML version deleted]] Confidentiality Statement: This email message, including any attachments, is for ...{{dropped:20}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] time series - cbind
Hi, I have a time series ts.score that gets created based on a function. When I print the time series out it prints two rows, first the date then the value. 2011-06-14 -1.25947868 The function gets called multiple times in my script and I'm trying to append the time series to an object called ts.bind using the cbind function like so. The only problem I have is that the date is an index for all of the columns, which is only correct for the first column. Is there a way that I can associate the correct dates with each column? ts.bind - cbind(ts.bind, ts.score) ts.score ts.score ts.score ts.score ts.score 2010-10-14 1.06493449 0.96323675 1.13255734 -0.3060238 1.0083540 2010-10-15 0.51371978 -0.54348798 0.82563515 -0.8808261 0.9578659 2010-10-18 0.03667826 0.25904910 0.5618 -1.0084433 0.5220185 2010-10-19 -2.32490163 0.08469947 0.09021838 -1.7677688 0.7954248 2010-10-20 -1.52627229 0.15408516 0.16440753 -1.4923426 0.5221617 I appreciate any help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] quick matching question
Hey, I'm trying to match patient identifiers from two separate input files, and then add information from one of the input files to the corresponding output file. I'd greatly appreciate any help! More specifically, Input_File_1 has a column header bcr_patient_barcode Input_File_2 has a column header Barcode and a column header Batch I want my script to match the appropriate patient identifiers since bcr_patient_barcode and Barcode are not in the same order. Then I want to add the information from Batch to the corresponding patient. My (incorrect) code is below: #batch tmp - Input_File_2$Barcode tmp1 - Input_File_1$bcr_patient_barcode for i in tmp for item in tmp1 if (tmp == tmp1) { curated$batch - Input_File_2$Batch } Thanks! [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] quick matching question
Looks like a job for merge(). On Fri, Oct 28, 2011 at 10:49 AM, Ben Ganzfried ben.ganzfr...@gmail.com wrote: Hey, I'm trying to match patient identifiers from two separate input files, and then add information from one of the input files to the corresponding output file. I'd greatly appreciate any help! More specifically, Input_File_1 has a column header bcr_patient_barcode Input_File_2 has a column header Barcode and a column header Batch I want my script to match the appropriate patient identifiers since bcr_patient_barcode and Barcode are not in the same order. Then I want to add the information from Batch to the corresponding patient. My (incorrect) code is below: #batch tmp - Input_File_2$Barcode tmp1 - Input_File_1$bcr_patient_barcode for i in tmp for item in tmp1 if (tmp == tmp1) { curated$batch - Input_File_2$Batch } -- Sarah Goslee http://www.functionaldiversity.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] quick matching question
On Oct 28, 2011, at 9:49 AM, Ben Ganzfried wrote: Hey, I'm trying to match patient identifiers from two separate input files, and then add information from one of the input files to the corresponding output file. I'd greatly appreciate any help! More specifically, Input_File_1 has a column header bcr_patient_barcode Input_File_2 has a column header Barcode and a column header Batch I want my script to match the appropriate patient identifiers since bcr_patient_barcode and Barcode are not in the same order. Then I want to add the information from Batch to the corresponding patient. My (incorrect) code is below: #batch tmp - Input_File_2$Barcode tmp1 - Input_File_1$bcr_patient_barcode for i in tmp for item in tmp1 if (tmp == tmp1) { curated$batch - Input_File_2$Batch } Thanks! See ?merge and then use something like: newDF - merge(Input_File_2, Input_File_1, by.x = Barcode, by.y = bcr_patient_barcode) Also, pay attention to the 'all', 'all.x' and 'all.y' arguments, which control whether or not only matching records are retained or non-matching records are retained from one or both datasets. merge() performs an SQL-like join operation. HTH, Marc Schwartz __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Equivalent of win.print for Linux
Thank you, it was exactly what I was looking for! Regards, Xavier Le 28. 10. 11 15:45, Prof Brian Ripley a écrit : See the help for postscript ... especially the 'Printing' section. On Fri, 28 Oct 2011, Xavier Robin wrote: Hi! In Windows the win.print function allows plotting directly to a printer (or copying an open device to the printer). This is very convenient to quickly print a plot once it looks good. Is there an equivalent function under Linux? For example through CUPS, IPP, LPD or other ? Obviously with a printer on the parallel port one could write postscript(/dev/lp0) but what about network printers? Currently what I do is printing the open device to a postscript() file, open this file in a postscript viewer and print it from there. But I'm lazy and a win.print-like shortcut would be welcome. Thanks, Xavier PS: I'm running Ubuntu 10.04 64bit. -- Xavier Robin Biomedical Proteomics Research Group Department of Structural Biology and Bioinformatics Faculty of Medicine, University Medical Center University of Geneva 1, rue Michel Servet - CH-1211 Genève 4 - Switzerland Tel: (+41 22) 379 41 69 Fax: (+41 22) 379 59 84 xavier.ro...@unige.ch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem with svyvar in survey package
I am using Package survey version 3.20 and R 2.11.1. --Amitava -- View this message in context: http://r.789695.n4.nabble.com/Problem-with-svyvar-in-survey-package-tp3932818p3947306.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 R regarding consecutive numbers
In the general case, there is still a gap in your solution sum( tbl[1, 2:ncol(tbl)] ). This solution refers to a specific column number (here: column number 2) and not to the actual length of the run, doesn't it? That is, in this simple example the column number 2 actually corresponds to the length 2, but this must not be the case in general. For instance if there is no run of length 2 but only of length 1 and 3, the column number 2 will refer to length 3 (try it with the new vector below). I realized this problem when applying your solution to a much more extended vector. So, the problem is that I would have to check manually whether the column number really corresponds to the length of runs. A possible solution would be to force R to show all the lengths from 1:ncol even if there is no run of some lengths in-between and just fill the whole column with zero's. x=c(1,3,4,9,1,9,1,5,4,5,2,1,1,1,6) Any ideas how to solve this problem? Cheers, S.B. -Ursprüngliche Nachricht- Von: David Winsemius [mailto:dwinsem...@comcast.net] Gesendet: Donnerstag, 27. Oktober 2011 16:44 An: Duncan Murdoch Cc: Samir Benzerfa; r-help@r-project.org Betreff: Re: [R] question R regarding consecutive numbers On Oct 27, 2011, at 9:21 AM, Duncan Murdoch wrote: On 27/10/2011 8:43 AM, Samir Benzerfa wrote: Hi everyone Do you know about any possibility in R to check for consecutive numbers in vectors? That is, I do not only want to count the number of observations in total (which can be done table(x)), but I also want to count for instance how many times that vector contains a certain number consecutively. For example in the following vector x the number 1 appears 7 times. However, I want to check for instance how many times two consecutive 1's appear in the vector, which would actually be two times the case in the below vector. x=c(1,1,3,4,9,1,9,1,5,4,5,2,1,1,1,6) Any ideas for this issue? How about this? runs - rle(x) with(runs, table(values, lengths)) And to go even a bit further, the table function returns a matrix which can be addressed to yield the specific answer requested: with(runs, table(values, lengths))[1,2] [1] 1 # m=number of exactly runs if length 2 sum( tbl[1, 2:ncol(tbl)] ) [1] 2 # number of runs of length two or more. -- David lengths values 1 2 3 1 2 1 1 2 1 0 0 3 1 0 0 4 2 0 0 5 2 0 0 6 1 0 0 9 2 0 0 Duncan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Gap in solution
Hi David, In the general case, there is still a gap in your solution sum( tbl[1, 2:ncol(tbl)] ). This solution refers to a specific column number (here: column number 2) and not to the actual length of the run, doesn't it? That is, in this simple example the column number 2 actually corresponds to the length 2, but this must not be the case in general. For instance if there is no run of length 2 but only of length 1 and 3, the column number 2 will refer to length 3 (try it with the new vector below). I realized this problem when applying your solution to a much more extended vector. So, the problem is that I would have to check manually whether the column number really corresponds to the length of runs. A possible solution would be to force R to show all the lengths from 1:ncol even if there is no run of some lengths in-between and just fill the whole column with zero's. x=c(1,3,4,9,1,9,1,5,4,5,2,1,1,1,6) Any ideas how to solve this problem? Cheers, S.B. -Ursprüngliche Nachricht- Von: David Winsemius [mailto:dwinsem...@comcast.net] Gesendet: Donnerstag, 27. Oktober 2011 16:44 An: Duncan Murdoch Cc: Samir Benzerfa; r-help@r-project.org Betreff: Re: [R] question R regarding consecutive numbers On Oct 27, 2011, at 9:21 AM, Duncan Murdoch wrote: On 27/10/2011 8:43 AM, Samir Benzerfa wrote: Hi everyone Do you know about any possibility in R to check for consecutive numbers in vectors? That is, I do not only want to count the number of observations in total (which can be done table(x)), but I also want to count for instance how many times that vector contains a certain number consecutively. For example in the following vector x the number 1 appears 7 times. However, I want to check for instance how many times two consecutive 1's appear in the vector, which would actually be two times the case in the below vector. x=c(1,1,3,4,9,1,9,1,5,4,5,2,1,1,1,6) Any ideas for this issue? How about this? runs - rle(x) with(runs, table(values, lengths)) And to go even a bit further, the table function returns a matrix which can be addressed to yield the specific answer requested: with(runs, table(values, lengths))[1,2] [1] 1 # m=number of exactly runs if length 2 sum( tbl[1, 2:ncol(tbl)] ) [1] 2 # number of runs of length two or more. -- David [[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] Fgarch: garchFit, limits of transformations
The (maximum) limit for shape is set on 10 for the function garchfit. Hence it is impossible to estimate data for a student-t distributed error term with a higher degrees of freedom than 10. I wonder how to change this parameter. I hope someone could give me the answer. Thank you verry much in advance! -- View this message in context: http://r.789695.n4.nabble.com/Fgarch-garchFit-limits-of-transformations-tp3947351p3947351.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] SARIMAX as extended AR(I)MAX?
Though I have not found the solution anywhere I have come up with a trick that I will post here for future reference: As long as you only want to include AR terms of the external variables (even the dependant variable can be used as an external variable) it is possible to manually lag the variables and then put them together by using ts.union(). Then the normal ARIMA function can be used to solve this problem. -- View this message in context: http://r.789695.n4.nabble.com/SARIMAX-as-extended-AR-I-MAX-tp3898726p3947880.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] Poblems wih EBImage
Yes, I'm using windows. Thank you. I made some improvement, I think, but then why did I receive this? utils:::menuInstallLocal() package 'EBImage' successfully unpacked and MD5 sums checked library(EBImage) Error: package 'EBImage' was built before R 2.10.0: please re-install it which one did I need to re-install? The EBImage or the R? Thank you? -- View this message in context: http://r.789695.n4.nabble.com/Poblems-wih-EBImage-tp1902367p3947242.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] Extracting a regression equation from 'lars' or 'glmnet'
Hi All, sorry but its probably another beginners question. I have run my data through both the 'lars' and 'glmnet' packages in R in an effort to reduce the number of predictors going into my regression equation. Is there a way to view the final (best) equation output from the function? Hopefully including variable names and coefficients. MJS -- View this message in context: http://r.789695.n4.nabble.com/Extracting-a-regression-equation-from-lars-or-glmnet-tp3947772p3947772.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] Email out of R (code)
Thanks for posting this. If anyone is interested in a short extension to include an attachment, try the function below. I make no guarantees though. Also, note that winDialog() is used in a couple places, so it may need some therapy before working outside of Windows. send.email - function(to, from, subject, message, attachment=NULL, username, password, server=smtp.gmail.com:587, confirmBeforeSend=TRUE){ # to: a list object of length 1. Using list(Recipient = re...@somewhere.net) will send the message to the address but # the name will appear instead of the address. # from: a list object of length 1. Same behavior as 'to' # subject: Character(1) giving the subject line. # message: Character(1) giving the body of the message # attachment: Character(1) giving the location of the attachment # username: character(1) giving the username. If missing and you are using Windows, R will prompt you for the username. # password: character(1) giving the password. If missing and you are using Windows, R will prompt you for the password. # server: character(1) giving the smtp server. # confirmBeforeSend: Logical. If True, a dialog box appears seeking confirmation before sending the e-mail. This is to #prevent me to send multiple updates to a collaborator while I am working interactively. if (!is.list(to) | !is.list(from)) stop('to' and 'from' must be lists) if (length(from) 1) stop('from' must have length 1) if (length(to) 1) stop('send.email' currently only supports one recipient e-mail address) if (length(attachment) 1) stop('send.email' can currently send only one attachment) if (length(message) 1){ stop('message' must be of length 1) message - paste(message, collapse=\\n\\n) } if (is.null(names(to))) names(to) - to if (is.null(names(from))) names(from) - from if (!is.null(attachment)) if (!file.exists(attachment)) stop(paste(', attachment, ' does not exist!, sep=)) if (missing(username)) username - winDialogString(Please enter your e-mail username, ) if (missing(password)) password - winDialogString(Please enter your e-mail password, ) require(rJython) rJython - rJython() rJython$exec(import smtplib) rJython$exec(import os) rJython$exec(from email.MIMEMultipart import MIMEMultipart) rJython$exec(from email.MIMEBase import MIMEBase) rJython$exec(from email.MIMEText import MIMEText) rJython$exec(from email.Utils import COMMASPACE, formatdate) rJython$exec(from email import Encoders) rJython$exec(import email.utils) mail-c( #Email settings paste(fromaddr = ', from, ', sep=), paste(toaddrs = ', to, ', sep=), msg = MIMEMultipart(), paste(msg.attach(MIMEText(', message, ')), sep=), paste(msg['From'] = email.utils.formataddr((', names(from), ', fromaddr)), sep=), paste(msg['To'] = email.utils.formataddr((', names(to), ', toaddrs)), sep=), paste(msg['Subject'] = ', subject, ', sep=)) if (!is.null(attachment)){ mail - c(mail, paste(f = ', attachment, ', sep=), part=MIMEBase('application', 'octet-stream'), part.set_payload(open(f, 'rb').read()), Encoders.encode_base64(part), part.add_header('Content-Disposition', 'attachment; filename=\%s\' % os.path.basename(f)), msg.attach(part)) } #SMTP server credentials mail - c(mail, paste(username = ', username, ', sep=), paste(password = ', password, ', sep=), #Set SMTP server and send email, e.g., google mail SMTP server paste(server = smtplib.SMTP(', server, '), sep=), server.ehlo(), server.starttls(), server.ehlo(), server.login(username,password), server.sendmail(fromaddr, toaddrs, msg.as_string()), server.quit()) message.details - paste(To: , names(to), (, unlist(to), ), \n, From: , names(from), (, unlist(from), ), \n, Using server: , server, \n, Subject: , subject, \n, With Attachments: , attachment, \n, And the message:\n, message, \n, sep=) if (confirmBeforeSend) SEND - winDialog(yesnocancel, paste(Are you sure you want to send this e-mail to , unlist(to), ?, sep=)) else SEND - YES if (SEND %in% YES){ jython.exec(rJython,mail) cat(message.details) } else cat(E-mail Delivery was Canceled by the User) } -- View this message in context: http://r.789695.n4.nabble.com/Email-out-of-R-code-tp3530671p3948061.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] weibull fitdistr problem: optimization failed
I'm getting errors when running what seems to be a simple Weibull distribution function: This works: x - c(23,19,37,38,40,36,172,48,113,90,54,104,90,54,157,51,77,78,144,34,29,45,16,15,37,218,170,44,121) rate - c(.01,.02,.04,.05,.1,.2,.3,.4,.5,.8,.9) year - c(100,50,25,20,10,5,3.3,2.5,2,1.2,1.1) library(MASS) x - sort(x) tryCatch( f-fitdistr(x, 'weibull'), error = function(e) cat(as.character(e)) ) shape = f$estimate[shape] scale = f$estimate[scale] cat(shape,scale,\n) for (i in 1:length(rate)){ cat(scale*(-log(rate[i]))^(1/shape)) cat(,) } I get my shape and scale printed out, and my calculated values, no problem. If I change the data to this: x - c(4,22,26,27,44,46,83,83,122,125,129,151,153,157,171,173,186,199,201,202,205,219,239,242,252,315,326,449,771) I get the error Error in fitdistr(x, weibull): optimization failed I can run a Weibull distribution in SAS with this same data, and it gives me what looks like a reasonable answer. What am I missing here? Thanks, --Ethan -- View this message in context: http://r.789695.n4.nabble.com/weibull-fitdistr-problem-optimization-failed-tp3947997p3947997.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] help with parallel processing code
the part of the question dawned on me now is, should I try to do the parallel processing of the full code or only the iteration part? if it is full code then I am at the complete mercy of the R help community or I giveup on this and let the computation run the serial way, which is continuing from past sat. Sharad -- View this message in context: http://r.789695.n4.nabble.com/help-with-parallel-processing-code-tp3944303p3948118.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] 3d graph to show matrix of z matrix values
Hello, I'm not getting a great looking 3d graph when plotting my z values: x - seq(0.0, max(d1), max(d1)/20) y - seq(0.0, max(d2), max(d2)/20) z - matrix(NA, length(x), length(y)) persp3d(x, y, z, phi=30, theta=30, scale=TRUE,shade = 0.75, col=pal[col.ind], xlab=var.name[1], ylab=var.name[2], main=3d plot) Are there other options like persp3d where I can just plot my z-values along the x and y axis?? Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/3d-graph-to-show-matrix-of-z-matrix-values-tp3948174p3948174.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] time series - cbind
On Oct 28, 2011, at 10:32 AM, Joe Stuart wrote: Hi, I have a time series ts.score that gets created based on a function. When I print the time series out it prints two rows, first the date then the value. 2011-06-14 -1.25947868 The function gets called multiple times in my script and I'm trying to append the time series to an object called ts.bind using the cbind function like so. The only problem I have is that the date is an index for all of the columns, which is only correct for the first column. Is there a way that I can associate the correct dates with each column? You should look at the 'zoo' package. It supplies merge and cbind methods for its zoo-class objects that will properly align values by their index. Many people have experienced the problems you are currently seeing and zoo is the solution. ts.bind - cbind(ts.bind, ts.score) ts.score ts.score ts.score ts.scorets.score 2010-10-14 1.06493449 0.96323675 1.13255734 -0.3060238 1.0083540 2010-10-15 0.51371978 -0.54348798 0.82563515 -0.8808261 0.9578659 2010-10-18 0.03667826 0.25904910 0.5618 -1.0084433 0.5220185 2010-10-19 -2.32490163 0.08469947 0.09021838 -1.7677688 0.7954248 2010-10-20 -1.52627229 0.15408516 0.16440753 -1.4923426 0.5221617 I appreciate any help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question R regarding consecutive numbers
Are you looking for something like the following? ifactor() is like factor but assumes that x is integral and that levels should be {1, 2, ..., max(x)} with no gaps. x - c(1,3,4,9,1,9,1,5,4,5,2,1,1,1,6) ifactor - function(x, levels=seq_len(max(0, x, na.rm=TRUE))) factor(x, levels=levels) with(rle(x), table(ifactor(values), ifactor(lengths))) 1 2 3 1 3 0 1 2 1 0 0 3 1 0 0 4 2 0 0 5 2 0 0 6 1 0 0 7 0 0 0 8 0 0 0 9 2 0 0 Also note that tbl[2,3] does not mean the same as tbl[2,3], although if you use the ifactor function as above they will refer to the same element. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Samir Benzerfa Sent: Friday, October 28, 2011 12:35 AM To: 'David Winsemius'; 'Duncan Murdoch' Cc: r-help@r-project.org Subject: Re: [R] question R regarding consecutive numbers In the general case, there is still a gap in your solution sum( tbl[1, 2:ncol(tbl)] ). This solution refers to a specific column number (here: column number 2) and not to the actual length of the run, doesn't it? That is, in this simple example the column number 2 actually corresponds to the length 2, but this must not be the case in general. For instance if there is no run of length 2 but only of length 1 and 3, the column number 2 will refer to length 3 (try it with the new vector below). I realized this problem when applying your solution to a much more extended vector. So, the problem is that I would have to check manually whether the column number really corresponds to the length of runs. A possible solution would be to force R to show all the lengths from 1:ncol even if there is no run of some lengths in-between and just fill the whole column with zero's. x=c(1,3,4,9,1,9,1,5,4,5,2,1,1,1,6) Any ideas how to solve this problem? Cheers, S.B. -Ursprüngliche Nachricht- Von: David Winsemius [mailto:dwinsem...@comcast.net] Gesendet: Donnerstag, 27. Oktober 2011 16:44 An: Duncan Murdoch Cc: Samir Benzerfa; r-help@r-project.org Betreff: Re: [R] question R regarding consecutive numbers On Oct 27, 2011, at 9:21 AM, Duncan Murdoch wrote: On 27/10/2011 8:43 AM, Samir Benzerfa wrote: Hi everyone Do you know about any possibility in R to check for consecutive numbers in vectors? That is, I do not only want to count the number of observations in total (which can be done table(x)), but I also want to count for instance how many times that vector contains a certain number consecutively. For example in the following vector x the number 1 appears 7 times. However, I want to check for instance how many times two consecutive 1's appear in the vector, which would actually be two times the case in the below vector. x=c(1,1,3,4,9,1,9,1,5,4,5,2,1,1,1,6) Any ideas for this issue? How about this? runs - rle(x) with(runs, table(values, lengths)) And to go even a bit further, the table function returns a matrix which can be addressed to yield the specific answer requested: with(runs, table(values, lengths))[1,2] [1] 1 # m=number of exactly runs if length 2 sum( tbl[1, 2:ncol(tbl)] ) [1] 2 # number of runs of length two or more. -- David lengths values 1 2 3 1 2 1 1 2 1 0 0 3 1 0 0 4 2 0 0 5 2 0 0 6 1 0 0 9 2 0 0 Duncan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 3d graph to show matrix of z matrix values
On 28/10/2011 11:04 AM, playballa23 wrote: Hello, I'm not getting a great looking 3d graph when plotting my z values: x- seq(0.0, max(d1), max(d1)/20) y- seq(0.0, max(d2), max(d2)/20) z- matrix(NA, length(x), length(y)) persp3d(x, y, z, phi=30, theta=30, scale=TRUE,shade = 0.75, col=pal[col.ind], xlab=var.name[1], ylab=var.name[2], main=3d plot) Your z values are all NA. What are you expecting to see? Duncan Murdoch Are there other options like persp3d where I can just plot my z-values along the x and y axis?? Thanks in advance -- View this message in context: http://r.789695.n4.nabble.com/3d-graph-to-show-matrix-of-z-matrix-values-tp3948174p3948174.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Gap in solution
On Oct 28, 2011, at 4:08 AM, Samir Benzerfa wrote: Hi David, In the general case, there is still a gap in your solution sum( tbl[1, 2:ncol(tbl)] ). This solution refers to a specific column number (here: column number 2) and not to the actual length of the run, doesn't it? That is correct. Fully tested solutions are provided when complete example code displaying the complexity of the problem is offered. If I had been posed a question that actually had a gap then the first thing I would have tried would be to construct a logical test for the condition under scrutiny and apply it to the indexing system. Using you example below (which is deficint in not having more than one column with hits) str(with(runs, table(values, lengths))) 'table' int [1:7, 1:2] 3 1 1 2 2 1 2 1 0 0 ... - attr(*, dimnames)=List of 2 ..$ values : chr [1:7] 1 2 3 4 ... ..$ lengths: chr [1:2] 1 3 xtbl - with(runs, table(values, lengths)) attr(xtbl, dimnames)$lengths [1] 1 3 which( as.numeric( attr(xtbl, dimnames)$lengths) =2 ) [1] 2 You could have just used that value, but I think it would be useful to test it with an example that has another run length 2 including one that is disjpoint x=c(1,3,4,9,1,9,1,5,4,5,2,1,1,1,6, 1,1,1,1,1) xtbl - with(rle(x), table(values, lengths)) xtbl lengths values 1 3 5 1 3 1 1 2 1 0 0 3 1 0 0 4 2 0 0 5 2 0 0 6 1 0 0 9 2 0 0 which( as.numeric( attr(xtbl, dimnames)$lengths) =2 ) [1] 2 3 So this is a better tested solution: xtbl[1, which( as.numeric( attr(xtbl, dimnames)$lengths) =2 )] 3 5 1 1 -- David. That is, in this simple example the column number 2 actually corresponds to the length 2, but this must not be the case in general. For instance if there is no run of length 2 but only of length 1 and 3, the column number 2 will refer to length 3 (try it with the new vector below). I realized this problem when applying your solution to a much more extended vector. So, the problem is that I would have to check manually whether the column number really corresponds to the length of runs. A possible solution would be to force R to show all the lengths from 1:ncol even if there is no run of some lengths in-between and just fill the whole column with zero's. x=c(1,3,4,9,1,9,1,5,4,5,2,1,1,1,6) Any ideas how to solve this problem? Cheers, S.B. -Ursprüngliche Nachricht- Von: David Winsemius [mailto:dwinsem...@comcast.net] Gesendet: Donnerstag, 27. Oktober 2011 16:44 An: Duncan Murdoch Cc: Samir Benzerfa; r-help@r-project.org Betreff: Re: [R] question R regarding consecutive numbers On Oct 27, 2011, at 9:21 AM, Duncan Murdoch wrote: On 27/10/2011 8:43 AM, Samir Benzerfa wrote: Hi everyone Do you know about any possibility in R to check for consecutive numbers in vectors? That is, I do not only want to count the number of observations in total (which can be done table(x)), but I also want to count for instance how many times that vector contains a certain number consecutively. For example in the following vector x the number 1 appears 7 times. However, I want to check for instance how many times two consecutive 1's appear in the vector, which would actually be two times the case in the below vector. x=c(1,1,3,4,9,1,9,1,5,4,5,2,1,1,1,6) Any ideas for this issue? How about this? runs - rle(x) with(runs, table(values, lengths)) And to go even a bit further, the table function returns a matrix which can be addressed to yield the specific answer requested: with(runs, table(values, lengths))[1,2] [1] 1 # m=number of exactly runs if length 2 sum( tbl[1, 2:ncol(tbl)] ) [1] 2 # number of runs of length two or more. -- David [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Proc Mixed to R
You need to use either the lme4 or nlme packages for mixed models. (There are some other possibilities as well). See http://glmm.wikidot.com/faq for MUCH more detail On 10/27/2011 7:19 PM, Molly Hanlon wrote: Hi All, I'm working with some SAS code to analyze an experiment set up as follows: 66 subjects (colonies) treated with a random treatment (1-8) and measured at three time points. The data structure looks like: input colony tmt y1 y2 y3; y=y1; date=*1*; output; y=y2; date=*2*; output; y=y3; date=*3*; output; datalines; 1 3 6725 6750 925 2 8 6950 5800 11275 3 4 4200 6100 6475 Procedure: *proc* *mixed* data=Nosema method=ml covtest; class colony tmt; model y=tmt date tmt*date / s; repeated / type=un subject=colony; random colony; lsmeans tmt/cl adjust=tukey; I am able to get something close by running aov on it, even closer by using Anova{car} and calling type=3. The problem I'm having is running the tukey and/or getting something similar to SAS's Solution for Fixed Effects table. Any idea what to do? Thanks, Molly [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Polynomial regression line
The cubic regression of my model is significant and I want to plot a line that best fits. It's not abline() function, because it has a curve. Please, how can I plot it? --- Fernando Andreacci Biólogo Fone +55 47 9921 4015 fandrea...@gmail.com [[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] time series - cbind
I will. Thanks On Fri, Oct 28, 2011 at 10:18 AM, David Winsemius dwinsem...@comcast.net wrote: On Oct 28, 2011, at 10:32 AM, Joe Stuart wrote: Hi, I have a time series ts.score that gets created based on a function. When I print the time series out it prints two rows, first the date then the value. 2011-06-14 -1.25947868 The function gets called multiple times in my script and I'm trying to append the time series to an object called ts.bind using the cbind function like so. The only problem I have is that the date is an index for all of the columns, which is only correct for the first column. Is there a way that I can associate the correct dates with each column? You should look at the 'zoo' package. It supplies merge and cbind methods for its zoo-class objects that will properly align values by their index. Many people have experienced the problems you are currently seeing and zoo is the solution. ts.bind - cbind(ts.bind, ts.score) ts.score ts.score ts.score ts.score ts.score 2010-10-14 1.06493449 0.96323675 1.13255734 -0.3060238 1.0083540 2010-10-15 0.51371978 -0.54348798 0.82563515 -0.8808261 0.9578659 2010-10-18 0.03667826 0.25904910 0.5618 -1.0084433 0.5220185 2010-10-19 -2.32490163 0.08469947 0.09021838 -1.7677688 0.7954248 2010-10-20 -1.52627229 0.15408516 0.16440753 -1.4923426 0.5221617 I appreciate any help. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] question R regarding consecutive numbers
On Oct 28, 2011, at 11:26 AM, William Dunlap wrote: Are you looking for something like the following? ifactor() is like factor but assumes that x is integral and that levels should be {1, 2, ..., max(x)} with no gaps. x - c(1,3,4,9,1,9,1,5,4,5,2,1,1,1,6) ifactor - function(x, levels=seq_len(max(0, x, na.rm=TRUE))) factor(x, levels=levels) with(rle(x), table(ifactor(values), ifactor(lengths))) 1 2 3 1 3 0 1 2 1 0 0 3 1 0 0 4 2 0 0 5 2 0 0 6 1 0 0 7 0 0 0 8 0 0 0 9 2 0 0 Also note that tbl[2,3] does not mean the same as tbl[2,3], although if you use the ifactor function as above they will refer to the same element. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com I answered earlier in a posting that did not get threaded properly in my mailer and this is a précis: xtbl - with(rle(x), table(values, lengths)) xtbl[1, which( as.numeric( attr(xtbl, dimnames)$lengths) =2 )] 3 5 1 1 Since character-numeric comparisons appear to get properly coerced the as numeric may not be necessary: xtbl[1, which( attr(xtbl, dimnames)$lengths =2 )] 3 5 1 1 -- David. -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of Samir Benzerfa Sent: Friday, October 28, 2011 12:35 AM To: 'David Winsemius'; 'Duncan Murdoch' Cc: r-help@r-project.org Subject: Re: [R] question R regarding consecutive numbers In the general case, there is still a gap in your solution sum( tbl[1, 2:ncol(tbl)] ). This solution refers to a specific column number (here: column number 2) and not to the actual length of the run, doesn't it? That is, in this simple example the column number 2 actually corresponds to the length 2, but this must not be the case in general. For instance if there is no run of length 2 but only of length 1 and 3, the column number 2 will refer to length 3 (try it with the new vector below). I realized this problem when applying your solution to a much more extended vector. So, the problem is that I would have to check manually whether the column number really corresponds to the length of runs. A possible solution would be to force R to show all the lengths from 1:ncol even if there is no run of some lengths in-between and just fill the whole column with zero's. x=c(1,3,4,9,1,9,1,5,4,5,2,1,1,1,6) Any ideas how to solve this problem? Cheers, S.B. -Ursprüngliche Nachricht- Von: David Winsemius [mailto:dwinsem...@comcast.net] Gesendet: Donnerstag, 27. Oktober 2011 16:44 An: Duncan Murdoch Cc: Samir Benzerfa; r-help@r-project.org Betreff: Re: [R] question R regarding consecutive numbers On Oct 27, 2011, at 9:21 AM, Duncan Murdoch wrote: On 27/10/2011 8:43 AM, Samir Benzerfa wrote: Hi everyone Do you know about any possibility in R to check for consecutive numbers in vectors? That is, I do not only want to count the number of observations in total (which can be done table(x)), but I also want to count for instance how many times that vector contains a certain number consecutively. For example in the following vector x the number 1 appears 7 times. However, I want to check for instance how many times two consecutive 1's appear in the vector, which would actually be two times the case in the below vector. x=c(1,1,3,4,9,1,9,1,5,4,5,2,1,1,1,6) Any ideas for this issue? How about this? runs - rle(x) with(runs, table(values, lengths)) And to go even a bit further, the table function returns a matrix which can be addressed to yield the specific answer requested: with(runs, table(values, lengths))[1,2] [1] 1 # m=number of exactly runs if length 2 sum( tbl[1, 2:ncol(tbl)] ) [1] 2 # number of runs of length two or more. -- David lengths values 1 2 3 1 2 1 1 2 1 0 0 3 1 0 0 4 2 0 0 5 2 0 0 6 1 0 0 9 2 0 0 Duncan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained,
Re: [R] Polynomial regression line
Hi, On Oct 28, 2011, at 11:49 AM, Fernando Andreacci wrote: The cubic regression of my model is significant and I want to plot a line that best fits. It's not abline() function, because it has a curve. Please, how can I plot it? Will curve() do it for you? ?curve Cheers, Ben --- Fernando Andreacci Biólogo Fone +55 47 9921 4015 fandrea...@gmail.com [[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. Ben Tupper Bigelow Laboratory for Ocean Sciences 180 McKown Point Rd. P.O. Box 475 West Boothbay Harbor, Maine 04575-0475 http://www.bigelow.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] weibull fitdistr problem: optimization failed
ethan.shepherd someguy235 at gmail.com writes: I'm getting errors when running what seems to be a simple Weibull distribution function: [snip] If I change the data to this: [snip] I get the error Error in fitdistr(x, weibull): optimization failed I can run a Weibull distribution in SAS with this same data, and it gives me what looks like a reasonable answer. How about: x - c(4,22,26,27,44,46,83,83,122,125,129,151,153,157,171, 173,186,199,201,202,205,219,239,242,252,315,326,449,771) hist(x) fit2 -fitdistr(x, 'weibull',lower=c(0.01,0.01)) hist(x,freq=FALSE,col=gray,ylim=c(0,0.004)) with(as.list(coef(fit2)),curve(dweibull(x,shape=shape,scale=scale), add=TRUE,col=2)) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Syntax Check: rshape2 melt() [RESOLVED]
On Fri, 28 Oct 2011, Rich Shepard wrote: May not be until Monday that I return with results on this effort as I'm going to be carfully checking and documenting each step and its results. Dan, et al.: Got it working properly now. Took a different approach after re-reading the source data into an R data frame. I applied the subset() function to extract all rows for a single stream (all commands are on a single line in emacs but wrap when copied into alpine): burns - subset(chemdata, stream == 'BurnsCrk', select = c(site, sampdate, param, quant), drop = T) Then I applied the reshape2 melt() function: burns.melt - melt(burns, id.vars = c('site', 'sampdate', 'param')) which produced this data frame: head(burns.melt) site sampdate param variable value 1 BC-0.5 1996-06-02OHquant NA 2 BC-0.5 1996-06-02 SO4quant 194.00 3 BC-0.5 1996-06-02 TDSquant 530.00 4 BC-0.5 1996-06-02 TSSquant NA 5 BC-0.5 1996-04-19Asquant 0.01 6 BC-1.5 1996-09-19Asquant NA Then the reshape2 dcast() function produced the desired results: burns.cast - dcast(burns.melt, site + sampdate ~ param) head(burns.cast) site sampdate Acid Ag Al Alk-HO Alk-Tot As Ba Be Bo CO3Ca Cd 1 BC-0.5 1996-04-19 NA NA 0.07 NA 162 0.01 0.18 NA NA NA 76.56 NA 2 BC-0.5 1996-05-21 NA NA NA NA 152 NA NA NA NA NANA NA 3 BC-0.5 1996-06-02 NA NA NA NA 212 NA NA NA NA NANA NA 4 BC-1 1988-06-26 NA NA NA NA NA 0.00 NA NA NA NANA NA 5 BC-1 1988-07-30 NA NA NA NA NA 0.00 NA NA NA NANA NA 6 BC-1 1989-05-15 NA NA NA NA NA 0.00 NA NA NA NANA NA et cetera. Thank you all for your patient help. Now I should be able to produce scatter plots and run linear regressions on selected parameter pairs by site and date. Carpe weekend, all, Rich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Polynomial regression line
I would think you could also do so with lines() directly, though you'll have to choose an appropriate mesh of points to do so. A little wrapper function could be written to do so pretty easily if you want to combine it with the scatterplot, but since the fitted values are already in the output of lm something like this should work: # Untested lines(m$x, m$fitted.values) Michael On Oct 28, 2011, at 12:10 PM, Ben Tupper btup...@bigelow.org wrote: Hi, On Oct 28, 2011, at 11:49 AM, Fernando Andreacci wrote: The cubic regression of my model is significant and I want to plot a line that best fits. It's not abline() function, because it has a curve. Please, how can I plot it? Will curve() do it for you? ?curve Cheers, Ben --- Fernando Andreacci Biólogo Fone +55 47 9921 4015 fandrea...@gmail.com [[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. Ben Tupper Bigelow Laboratory for Ocean Sciences 180 McKown Point Rd. P.O. Box 475 West Boothbay Harbor, Maine 04575-0475 http://www.bigelow.org __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] ACE/AVAS with bootstrap
I am using ACE/AVAS to fit a non-parametric regression model to a multivariate data set. Is there a way to add confidence intervals to the fit and predictions by using bootstrap? Thanks for any suggestions. [[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] NROW doesn't equal length(x)
And to further the example, length() of matrix is not equal to the number of rows either. mm - matrix(1:6, ncol=2) length(mm) [1] 6 dim(mm) [1] 3 2 Also, NROW() and nrow() are different; I'd be cautious about using NROW without making sure I understood the difference. NROW function (x) if (is.array(x) || is.data.frame(x)) nrow(x) else length(x) environment: namespace:base nrow function (x) dim(x)[1L] environment: namespace:base -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 10/27/11 12:23 PM, R. Michael Weylandt michael.weyla...@gmail.com michael.weyla...@gmail.com wrote: Data frame is list internally so length(df) = ncol(df) M On Oct 27, 2011, at 2:44 PM, Muhammad Abuizzah izzah...@yahoo.com wrote: Hi, I am converting a data.frame to xts. the data.frame is 4 columns and 1000 rows. I get a message that NROW (x) must match length(order.by) class is data.frame, mode is list when I run dim(x) # I get 1000 4 #which is consistent with 1000 rows and 4 columns NROW (x) # I get 1000 # which is the right answer When I run length on each of columns in x separately using the $ I get 1000, which is the right number too. So length on each of the columns individually gives me the right answer, but length on the data.frame gives me the number of columns instead of the number of rows, is there an explanation thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Poblems wih EBImage
On 10/28/2011 01:27 AM, diyanah wrote: Yes, I'm using windows. Thank you. I made some improvement, I think, but then why did I receive this? utils:::menuInstallLocal() package 'EBImage' successfully unpacked and MD5 sums checked library(EBImage) Error: package 'EBImage' was built before R 2.10.0: please re-install it which one did I need to re-install? The EBImage or the R? You're using a version of EBImage that is not meant for your version of R. The recommended way to install Bioconductor packages, and avoid these mismatches, is source(http://bioconductor.org/biocLite.R;) biocLite(EBImage) Please post any follow-up questions to the Bioconductor mailing list http://bioconductor.org/help/mailing-list/ (no subscription necessary) Martin Thank you? -- View this message in context: http://r.789695.n4.nabble.com/Poblems-wih-EBImage-tp1902367p3947242.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. -- Computational Biology Fred Hutchinson Cancer Research Center 1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109 Location: M1-B861 Telephone: 206 667-2793 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] file name too long error during R CMD INSTALL
Hi all, I am attempting to install a package called phylobase from source directory. It all seems to work until the end, at which point it looks like the last compile command fails because the line is too long...perhaps because the g++ command line also includes Loading ~/.Rprofile..., like this: g++ -arch i386 -dynamiclib -Wl,-headerpad_max_install_names -mmacosx-version-min=10.4 -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o phylobase.so GetNCL.o ancestors.o descendants.o nxsassumptionsblock.o nxsblock.o [etc] reorderRobust.o Loading ~/.Rprofile... Currently viewed PATH: /opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/Library/Frameworks/Python.framework/Versions/Current/bin:[...etc...] Any hints on what might be going on? Is there a way to access the makefile directly so that I can tinker with it? Or tell INSTALL to not bother with .Rprofile? I get similar errors when installing from zipfile, or from using install.packages within R. Cheers, Nick Full output: === [getting sessionInfo()] mws2:~/Desktop/downloads nick$ R R version 2.10.1 (2009-12-14) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Loading ~/.Rprofile... Currently viewed PATH: /opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/soylatte16-i386/bin:/Applications/muscle:/Applications/dssp:/opt/local/include:/Library/Frameworks/GDAL.framework/Programs:/Library/Frameworks/PROJ.framework/Programs:/sw/include/wx-2.8:/Library/Frameworks/PROJ.framework/Programs:_njm:/opt/git/bin:/Users/nick/gtk/inst/bin:/Users/nick/bin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/bioinformatics/ncbi_execs/sap:/bioinformatics/ncbi_execs/tcoffee565/bin:/usr/local/ActivePerl-5.10/bin:/bioinformatics/ncbi_execs/bin:/Users/nick:/bioinformatics:/bioinformatics/ncbi_execs/ncbi_tools/:/bioinformatics/pythonstuff/soylatte16-i386-1.0.3/bin:/bioinformatics/diva_mac:/usr/texbin/usr/ebiotools/staden/macosx-bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/ebiotools/ncbi/bin:/usr/ebiotools/bin:/usr/local/bin:/usr/texbin:/usr/X11R6/bin:/usr/texbin:/Applications/dssp:/Library/Frameworks/PROJ.framework/:/Library/Frameworks/PROJ. framework/Programs:/Library/Frameworks/PROJ.framework/Versions/4.6/Headers:/Library/Frameworks/GDAL.framework/Versions/1.6/Programs sessionInfo() R version 2.10.1 (2009-12-14) i386-apple-darwin8.11.1 locale: [1] C/en_US.UTF-8/C/C/C/C attached base packages: [1] stats grDevices utils datasets graphics methods base quit() Save workspace image? [y/n/c]: n mws2:~/Desktop/downloads nick$ [install attempt with R CMD INSTALL] mws2:~/Desktop/downloads nick$ R CMD INSTALL ~/Desktop/downloads/phylobase_0.6.2 Loading ~/.Rprofile... Currently viewed PATH: /opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/soylatte16-i386/bin:/Applications/muscle:/Applications/dssp:/opt/local/include:/Library/Frameworks/GDAL.framework/Programs:/Library/Frameworks/PROJ.framework/Programs:/sw/include/wx-2.8:/Library/Frameworks/PROJ.framework/Programs:_njm:/opt/git/bin:/Users/nick/gtk/inst/bin:/Users/nick/bin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/bioinformatics/ncbi_execs/sap:/bioinformatics/ncbi_execs/tcoffee565/bin:/usr/local/ActivePerl-5.10/bin:/bioinformatics/ncbi_execs/bin:/Users/nick:/bioinformatics:/bioinformatics/ncbi_execs/ncbi_tools/:/bioinformatics/pythonstuff/soylatte16-i386-1.0.3/bin:/bioinformatics/diva_mac:/usr/texbin/usr/ebiotools/staden/macosx-bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/ebiotools/ncbi/bin:/usr/ebiotools/bin:/usr/local/bin:/usr/texbin:/usr/X11R6/bin:/usr/texbin:/Applications/dssp:/Library/Frameworks/PROJ.framework/:/Library/Frameworks/PROJ. framework/Programs:/Library/Frameworks/PROJ.framework/Versions/4.6/Headers:/Library/Frameworks/GDAL.framework/Versions/1.6/Programs * installing to library ‘/Users/nick/Library/R/2.10/library’ * installing *source* package ‘phylobase’ ... ** libs ** arch - i386 g++ -arch i386 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/i386 -I. -DHAVE_INTTYPES_H -I/usr/local/include -I/Library/Frameworks/R.framework/Resources/library/Rcpp/include -fPIC -g -O2 -c GetNCL.cpp -o
Re: [R] Email out of R (code)
The various suggestions seem kind of complex to me, at least on a unix-like system (including Mac OS X). This is what I do: sink('tmp.txt') cat('This is the body of the message\n') sink() system('cat tmp.txt | mail -s A test email macque...@llnl.gov') One could probably avoid the temporary external text file using connections, but I haven't had that need. For attachments, the following approach works on at least some systems (RHEL for one): pdf('temp.pdf') ## create a plot dev.off() sink('tmp.txt') ## print() and cat() commands sink() cmd - '/bin/mailx -s Subject line text -a temp.pdf -S replyto=macque...@llnl.gov recipi...@some.host tmp.txt' system(cmd) It's not hard, of course, to wrap such a thing up in a function with arguments for various elements such as the subject, the file names, the email address(es), and then construct the cmd using paste(). -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 10/28/11 7:28 AM, nutterb nutt...@ccf.org wrote: Thanks for posting this. If anyone is interested in a short extension to include an attachment, try the function below. I make no guarantees though. Also, note that winDialog() is used in a couple places, so it may need some therapy before working outside of Windows. send.email - function(to, from, subject, message, attachment=NULL, username, password, server=smtp.gmail.com:587, confirmBeforeSend=TRUE){ # to: a list object of length 1. Using list(Recipient = re...@somewhere.net) will send the message to the address but # the name will appear instead of the address. # from: a list object of length 1. Same behavior as 'to' # subject: Character(1) giving the subject line. # message: Character(1) giving the body of the message # attachment: Character(1) giving the location of the attachment # username: character(1) giving the username. If missing and you are using Windows, R will prompt you for the username. # password: character(1) giving the password. If missing and you are using Windows, R will prompt you for the password. # server: character(1) giving the smtp server. # confirmBeforeSend: Logical. If True, a dialog box appears seeking confirmation before sending the e-mail. This is to #prevent me to send multiple updates to a collaborator while I am working interactively. if (!is.list(to) | !is.list(from)) stop('to' and 'from' must be lists) if (length(from) 1) stop('from' must have length 1) if (length(to) 1) stop('send.email' currently only supports one recipient e-mail address) if (length(attachment) 1) stop('send.email' can currently send only one attachment) if (length(message) 1){ stop('message' must be of length 1) message - paste(message, collapse=\\n\\n) } if (is.null(names(to))) names(to) - to if (is.null(names(from))) names(from) - from if (!is.null(attachment)) if (!file.exists(attachment)) stop(paste(', attachment, ' does not exist!, sep=)) if (missing(username)) username - winDialogString(Please enter your e-mail username, ) if (missing(password)) password - winDialogString(Please enter your e-mail password, ) require(rJython) rJython - rJython() rJython$exec(import smtplib) rJython$exec(import os) rJython$exec(from email.MIMEMultipart import MIMEMultipart) rJython$exec(from email.MIMEBase import MIMEBase) rJython$exec(from email.MIMEText import MIMEText) rJython$exec(from email.Utils import COMMASPACE, formatdate) rJython$exec(from email import Encoders) rJython$exec(import email.utils) mail-c( #Email settings paste(fromaddr = ', from, ', sep=), paste(toaddrs = ', to, ', sep=), msg = MIMEMultipart(), paste(msg.attach(MIMEText(', message, ')), sep=), paste(msg['From'] = email.utils.formataddr((', names(from), ', fromaddr)), sep=), paste(msg['To'] = email.utils.formataddr((', names(to), ', toaddrs)), sep=), paste(msg['Subject'] = ', subject, ', sep=)) if (!is.null(attachment)){ mail - c(mail, paste(f = ', attachment, ', sep=), part=MIMEBase('application', 'octet-stream'), part.set_payload(open(f, 'rb').read()), Encoders.encode_base64(part), part.add_header('Content-Disposition', 'attachment; filename=\%s\' % os.path.basename(f)), msg.attach(part)) } #SMTP server credentials mail - c(mail, paste(username = ', username, ', sep=), paste(password = ', password, ', sep=), #Set SMTP server and send email, e.g., google mail SMTP server paste(server = smtplib.SMTP(', server, '), sep=), server.ehlo(), server.starttls(), server.ehlo(), server.login(username,password), server.sendmail(fromaddr, toaddrs, msg.as_string()), server.quit()) message.details - paste(To: , names(to), (, unlist(to), ), \n, From: , names(from), (, unlist(from), ), \n, Using
[R] Contrasts with an interaction. How does one specify the dummy variables for the interaction
Forgive my resending this post. To data I have received only one response (thank you Bert Gunter), and I still do not have an answer to my question. Respectfully, John Windows XP R 2.12.1 contrast package. I am trying to understand how to create contrasts for a model that contatains an interaction. I can get contrasts to work for a model without interaction, but not after adding the interaction. Please see code below. The last two contrast statements show the problem. I would appreciate someone letting me know what is wrong with the syntax of my contrast statements. Thank you, John library(contrast) # Create 2x2 contingency table. counts=c(50,50,30,70) row -gl(2,2,4) column - gl(2,1,4) mydata - data.frame(row,column,counts) print(mydata) # Show levels of 2x2 table levels(mydata$row) levels(mydata$column) # Models, no interaction, and interaction fitglm0 - glm(counts ~ row + column, family=poisson(link=log)) fitglm - glm(counts ~ row + column + row*column, family=poisson(link=log)) # Contrasts for model without interaction works fine! anova(fitglm0) summary(fitglm0) con0-contrast(fitglm0,list(row=1,column=1)) print(con0,X=TRUE) # Contrast for model with interaction does not work. anova(fitglm) summary(fitglm) con-contrast(fitglm,list(row=1,column=1) print(con,X=TRUE) # Nor does this work. con-contrast(fitglm,list(row=1,column=1,row:column=c(0,0))) print(con,X=TRUE) 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] Faster process for creating a matrix based on matrix element comparison
I have matrix data data-matrix(cbind(c(0,0,0),c(NA,0,1),c(1,1,1),c(0,1,1)),ncol=3) and I want to create a new matrix by checking each element of the data and put value 0 if i have NA and 1 otherwise. For this reason i made the function below pdata-matrix(NA,ncol=ncol(data),nrow=nrow(data)) pdata-sapply(1:nrow(data),function(i) sapply (1:ncol(data),function(j) if (is.na(data[i,j])) {pdata[i,j]-0} else {pdata[i,j]-1} )) pdata-matrix(t(pdata),ncol=ncol(data),nrow=nrow(data)) with pdata pdata [,1] [,2] [,3] [1,]111 [2,]111 [3,]111 [4,]011 But in my case I have a matrix with 5 rows and 10 colums and the creation of pdata takes alot of time. Could anyone have any suggestion to make pdata faster? Thanks -- View this message in context: http://r.789695.n4.nabble.com/Faster-process-for-creating-a-matrix-based-on-matrix-element-comparison-tp3948841p3948841.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] xtable with \begin{tabular} and only.contents
I have found that I like having my captions and labels in my latex document rather than having them contained in my xtable output file (I haven't fully gone to sweave yet). I know I can do something like this by using the 'only.contents' argument in xtable. Unfortunately, the only.contents argument also removes the \begin{tabular}{rr} \end{tabular} (in the example below) of the table.This means that I have to go look up each table to determine the number of columns. Is there a more automated way that I am missing? i.e only.contents but with tabular headers (but not \begin{table})? Thank you. CODE: ## Demonstrate include.rownames, include.colnames, ## only.contents and add.to.row arguments set.seed(2345) res - matrix(sample(0:9, size=6*9, replace=TRUE), ncol=6, nrow=9) xres - xtable(res) digits(xres) - rep(0, 7) addtorow - list() addtorow$pos - list() addtorow$pos[[1]] - c(0, 2) addtorow$pos[[2]] - 4 addtorow$command - c('\vspace{2mm} \n', '\vspace{10mm} \n') print(xres, add.to.row=addtorow, include.rownames=FALSE, include.colnames=TRUE, only.contents=TRUE, hline.after=c(0, 0, 9, 9)) Output (only.contents=TRUE) % latex table generated in R 2.13.2 by xtable 1.6-0 package % Fri Oct 28 11:38:10 2011 1 2 3 4 5 6 \\ space{2mm} \hline \hline 1 7 6 6 5 9 \\ 1 1 1 5 7 7 \\ space{2mm} 7 3 9 8 0 5 \\ 0 0 4 1 5 2 \\ space{10mm} 4 1 8 5 7 1 \\ 2 4 5 9 5 4 \\ 6 3 3 5 5 8 \\ 7 6 1 0 7 6 \\ 4 4 8 8 3 2 \\ \hline \hline Output (only.contents=FALSE) % latex table generated in R 2.13.2 by xtable 1.6-0 package % Fri Oct 28 11:39:23 2011 \begin{table}[ht] \begin{center} \begin{tabular}{rr} 1 2 3 4 5 6 \\ space{2mm} \hline \hline 1 7 6 6 5 9 \\ 1 1 1 5 7 7 \\ space{2mm} 7 3 9 8 0 5 \\ 0 0 4 1 5 2 \\ space{10mm} 4 1 8 5 7 1 \\ 2 4 5 9 5 4 \\ 6 3 3 5 5 8 \\ 7 6 1 0 7 6 \\ 4 4 8 8 3 2 \\ \hline \hline \end{tabular} \end{center} \end{table} [[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] xtable with \begin{tabular} and only.contents
On 28/10/2011 2:40 PM, Trevor Davies wrote: I have found that I like having my captions and labels in my latex document rather than having them contained in my xtable output file (I haven't fully gone to sweave yet). The remark in the parens is the problem here. Use Sweave. Duncan Murdoch I know I can do something like this by using the 'only.contents' argument in xtable. Unfortunately, the only.contents argument also removes the \begin{tabular}{rr} \end{tabular} (in the example below) of the table.This means that I have to go look up each table to determine the number of columns. Is there a more automated way that I am missing? i.e only.contents but with tabular headers (but not \begin{table})? Thank you. CODE: ## Demonstrate include.rownames, include.colnames, ## only.contents and add.to.row arguments set.seed(2345) res- matrix(sample(0:9, size=6*9, replace=TRUE), ncol=6, nrow=9) xres- xtable(res) digits(xres)- rep(0, 7) addtorow- list() addtorow$pos- list() addtorow$pos[[1]]- c(0, 2) addtorow$pos[[2]]- 4 addtorow$command- c('\vspace{2mm} \n', '\vspace{10mm} \n') print(xres, add.to.row=addtorow, include.rownames=FALSE, include.colnames=TRUE, only.contents=TRUE, hline.after=c(0, 0, 9, 9)) Output (only.contents=TRUE) % latex table generated in R 2.13.2 by xtable 1.6-0 package % Fri Oct 28 11:38:10 2011 1 2 3 4 5 6 \\ space{2mm} \hline \hline 1 7 6 6 5 9 \\ 1 1 1 5 7 7 \\ space{2mm} 7 3 9 8 0 5 \\ 0 0 4 1 5 2 \\ space{10mm} 4 1 8 5 7 1 \\ 2 4 5 9 5 4 \\ 6 3 3 5 5 8 \\ 7 6 1 0 7 6 \\ 4 4 8 8 3 2 \\ \hline \hline Output (only.contents=FALSE) % latex table generated in R 2.13.2 by xtable 1.6-0 package % Fri Oct 28 11:39:23 2011 \begin{table}[ht] \begin{center} \begin{tabular}{rr} 1 2 3 4 5 6 \\ space{2mm} \hline \hline 1 7 6 6 5 9 \\ 1 1 1 5 7 7 \\ space{2mm} 7 3 9 8 0 5 \\ 0 0 4 1 5 2 \\ space{10mm} 4 1 8 5 7 1 \\ 2 4 5 9 5 4 \\ 6 3 3 5 5 8 \\ 7 6 1 0 7 6 \\ 4 4 8 8 3 2 \\ \hline \hline \end{tabular} \end{center} \end{table} [[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] Faster process for creating a matrix based on matrix element comparison
(!is.na(data)) + 0 -- Bert On Fri, Oct 28, 2011 at 11:40 AM, Evgenia ev...@aueb.gr wrote: I have matrix data data-matrix(cbind(c(0,0,0),c(NA,0,1),c(1,1,1),c(0,1,1)),ncol=3) and I want to create a new matrix by checking each element of the data and put value 0 if i have NA and 1 otherwise. For this reason i made the function below pdata-matrix(NA,ncol=ncol(data),nrow=nrow(data)) pdata-sapply(1:nrow(data),function(i) sapply (1:ncol(data),function(j) if (is.na(data[i,j])) {pdata[i,j]-0} else {pdata[i,j]-1} )) pdata-matrix(t(pdata),ncol=ncol(data),nrow=nrow(data)) with pdata pdata [,1] [,2] [,3] [1,]111 [2,]111 [3,]111 [4,]011 But in my case I have a matrix with 5 rows and 10 colums and the creation of pdata takes alot of time. Could anyone have any suggestion to make pdata faster? Thanks -- View this message in context: http://r.789695.n4.nabble.com/Faster-process-for-creating-a-matrix-based-on-matrix-element-comparison-tp3948841p3948841.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. -- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm [[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] Faster process for creating a matrix based on matrix element comparison
dat [,1] [,2] [,3] [1,]001 [2,]010 [3,]011 [4,] NA11 1 - is.na(dat) [,1] [,2] [,3] [1,]111 [2,]111 [3,]111 [4,]011 D. On Fri, Oct 28, 2011 at 11:40 AM, Evgenia ev...@aueb.gr wrote: I have matrix data data-matrix(cbind(c(0,0,0),c(NA,0,1),c(1,1,1),c(0,1,1)),ncol=3) and I want to create a new matrix by checking each element of the data and put value 0 if i have NA and 1 otherwise. For this reason i made the function below pdata-matrix(NA,ncol=ncol(data),nrow=nrow(data)) pdata-sapply(1:nrow(data),function(i) sapply (1:ncol(data),function(j) if (is.na(data[i,j])) {pdata[i,j]-0} else {pdata[i,j]-1} )) pdata-matrix(t(pdata),ncol=ncol(data),nrow=nrow(data)) with pdata pdata [,1] [,2] [,3] [1,] 1 1 1 [2,] 1 1 1 [3,] 1 1 1 [4,] 0 1 1 But in my case I have a matrix with 5 rows and 10 colums and the creation of pdata takes alot of time. Could anyone have any suggestion to make pdata faster? Thanks -- View this message in context: http://r.789695.n4.nabble.com/Faster-process-for-creating-a-matrix-based-on-matrix-element-comparison-tp3948841p3948841.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] About the statistics for ratio comparison
Hi I have a table with four columns and 3 rows. I calculated the average for each columns as average (A), average (B), average (C) and average (D), then calculate the relative ratio as average (A)/average (B), and average (C)/average (D). I would like to know how can I calculate the significance between the two ratios. Thanks, Meng [[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] Graphics Reciprocal labeling
Does R graphics have a way to easily label the horizontal axis by the reciprocal of the scaled value? -- View this message in context: http://r.789695.n4.nabble.com/Graphics-Reciprocal-labeling-tp3949054p3949054.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] Contrasts with an interaction. How does one specify the dummy variables for the interaction
Is there a specific reason why you insist on using the contrast library? If not: # Create 2x2 contingency table. counts=c(50,50,30,70) row -gl(2,2,4) column - gl(2,1,4) mydata - data.frame(row,column,counts) print(mydata) #Create contrasts row-factor(row) column-factor(column) contrasts(row)-contr.treatment(levels(row)) contrasts(column)-contr.treatment(levels(column)) # Works for Terps fit.terp-glm(counts ~ row + column + row*column, family=poisson(link=log)) summary(fit.terp) HTH, Daniel Malter University of Maryland, College Park John Sorkin wrote: Forgive my resending this post. To data I have received only one response (thank you Bert Gunter), and I still do not have an answer to my question. Respectfully, John Windows XP R 2.12.1 contrast package. I am trying to understand how to create contrasts for a model that contatains an interaction. I can get contrasts to work for a model without interaction, but not after adding the interaction. Please see code below. The last two contrast statements show the problem. I would appreciate someone letting me know what is wrong with the syntax of my contrast statements. Thank you, John library(contrast) # Create 2x2 contingency table. counts=c(50,50,30,70) row -gl(2,2,4) column - gl(2,1,4) mydata - data.frame(row,column,counts) print(mydata) # Show levels of 2x2 table levels(mydata$row) levels(mydata$column) # Models, no interaction, and interaction fitglm0 - glm(counts ~ row + column, family=poisson(link=log)) fitglm - glm(counts ~ row + column + row*column, family=poisson(link=log)) # Contrasts for model without interaction works fine! anova(fitglm0) summary(fitglm0) con0-contrast(fitglm0,list(row=1,column=1)) print(con0,X=TRUE) # Contrast for model with interaction does not work. anova(fitglm) summary(fitglm) con-contrast(fitglm,list(row=1,column=1) print(con,X=TRUE) # Nor does this work. con-contrast(fitglm,list(row=1,column=1,row:column=c(0,0))) print(con,X=TRUE) 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@ mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://r.789695.n4.nabble.com/Contrasts-with-an-interaction-How-does-one-specify-the-dummy-variables-for-the-interaction-tp3948792p3949071.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] quick matching question
Thanks! On Fri, Oct 28, 2011 at 10:59 AM, Marc Schwartz marc_schwa...@me.comwrote: On Oct 28, 2011, at 9:49 AM, Ben Ganzfried wrote: Hey, I'm trying to match patient identifiers from two separate input files, and then add information from one of the input files to the corresponding output file. I'd greatly appreciate any help! More specifically, Input_File_1 has a column header bcr_patient_barcode Input_File_2 has a column header Barcode and a column header Batch I want my script to match the appropriate patient identifiers since bcr_patient_barcode and Barcode are not in the same order. Then I want to add the information from Batch to the corresponding patient. My (incorrect) code is below: #batch tmp - Input_File_2$Barcode tmp1 - Input_File_1$bcr_patient_barcode for i in tmp for item in tmp1 if (tmp == tmp1) { curated$batch - Input_File_2$Batch } Thanks! See ?merge and then use something like: newDF - merge(Input_File_2, Input_File_1, by.x = Barcode, by.y = bcr_patient_barcode) Also, pay attention to the 'all', 'all.x' and 'all.y' arguments, which control whether or not only matching records are retained or non-matching records are retained from one or both datasets. merge() performs an SQL-like join operation. HTH, Marc Schwartz [[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] file name too long error during R CMD INSTALL
A correspondant suggests it would help if I said the OS, it's Intel Mac OS X 10.4...yes I should update but I'm trying to hold off a little longer due to numerous other things I don't want to have to reinstall just yet... On 10/28/11 10:54 AM, Nick Matzke wrote: Hi all, I am attempting to install a package called phylobase from source directory. It all seems to work until the end, at which point it looks like the last compile command fails because the line is too long...perhaps because the g++ command line also includes Loading ~/.Rprofile..., like this: g++ -arch i386 -dynamiclib -Wl,-headerpad_max_install_names -mmacosx-version-min=10.4 -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o phylobase.so GetNCL.o ancestors.o descendants.o nxsassumptionsblock.o nxsblock.o [etc] reorderRobust.o Loading ~/.Rprofile... Currently viewed PATH: /opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/Library/Frameworks/Python.framework/Versions/Current/bin:[...etc...] Any hints on what might be going on? Is there a way to access the makefile directly so that I can tinker with it? Or tell INSTALL to not bother with .Rprofile? I get similar errors when installing from zipfile, or from using install.packages within R. Cheers, Nick Full output: === [getting sessionInfo()] mws2:~/Desktop/downloads nick$ R R version 2.10.1 (2009-12-14) Copyright (C) 2009 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. Natural language support but running in an English locale R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Loading ~/.Rprofile... Currently viewed PATH: /opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/soylatte16-i386/bin:/Applications/muscle:/Applications/dssp:/opt/local/include:/Library/Frameworks/GDAL.framework/Programs:/Library/Frameworks/PROJ.framework/Programs:/sw/include/wx-2.8:/Library/Frameworks/PROJ.framework/Programs:_njm:/opt/git/bin:/Users/nick/gtk/inst/bin:/Users/nick/bin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/bioinformatics/ncbi_execs/sap:/bioinformatics/ncbi_execs/tcoffee565/bin:/usr/local/ActivePerl-5.10/bin:/bioinformatics/ncbi_execs/bin:/Users/nick:/bioinformatics:/bioinformatics/ncbi_execs/ncbi_tools/:/bioinformatics/pythonstuff/soylatte16-i386-1.0.3/bin:/bioinformatics/diva_mac:/usr/texbin/usr/ebiotools/staden/macosx-bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/ebiotools/ncbi/bin:/usr/ebiotools/bin:/usr/local/bin:/usr/texbin:/usr/X11R6/bin:/usr/texbin:/Applications/dssp:/Library/Frameworks/PROJ.framework/:/Library/Frameworks/PRO J. framework/Programs:/Library/Frameworks/PROJ.framework/Versions/4.6/Headers:/Library/Frameworks/GDAL.framework/Versions/1.6/Programs sessionInfo() R version 2.10.1 (2009-12-14) i386-apple-darwin8.11.1 locale: [1] C/en_US.UTF-8/C/C/C/C attached base packages: [1] stats grDevices utils datasets graphics methods base quit() Save workspace image? [y/n/c]: n mws2:~/Desktop/downloads nick$ [install attempt with R CMD INSTALL] mws2:~/Desktop/downloads nick$ R CMD INSTALL ~/Desktop/downloads/phylobase_0.6.2 Loading ~/.Rprofile... Currently viewed PATH: /opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/soylatte16-i386/bin:/Applications/muscle:/Applications/dssp:/opt/local/include:/Library/Frameworks/GDAL.framework/Programs:/Library/Frameworks/PROJ.framework/Programs:/sw/include/wx-2.8:/Library/Frameworks/PROJ.framework/Programs:_njm:/opt/git/bin:/Users/nick/gtk/inst/bin:/Users/nick/bin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/bioinformatics/ncbi_execs/sap:/bioinformatics/ncbi_execs/tcoffee565/bin:/usr/local/ActivePerl-5.10/bin:/bioinformatics/ncbi_execs/bin:/Users/nick:/bioinformatics:/bioinformatics/ncbi_execs/ncbi_tools/:/bioinformatics/pythonstuff/soylatte16-i386-1.0.3/bin:/bioinformatics/diva_mac:/usr/texbin/usr/ebiotools/staden/macosx-bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/ebiotools/ncbi/bin:/usr/ebiotools/bin:/usr/local/bin:/usr/texbin:/usr/X11R6/bin:/usr/texbin:/Applications/dssp:/Library/Frameworks/PROJ.framework/:/Library/Frameworks/PRO J. framework/Programs:/Library/Frameworks/PROJ.framework/Versions/4.6/Headers:/Library/Frameworks/GDAL.framework/Versions/1.6/Programs * installing to library ‘/Users/nick/Library/R/2.10/library’ * installing *source* package ‘phylobase’ ... ** libs ** arch - i386 g++ -arch i386
Re: [R] Graphics Reciprocal labeling
On Oct 28, 2011, at 3:57 PM, Hurr wrote: Does R graphics have a way to easily label the horizontal axis by the reciprocal of the scaled value? plot(x-1:10,y-1:10, xaxt=n) axis(1, at=1:10, labels=round(1/x, 3) ) It is a bit more difficult to do it as a fractional label but possible: rm(x) plot(x-1:10,y-1:10, xaxt=n) xepr - as.expression( sapply(x, function(y) bquote(frac(1, .(y) )) )) axis(1, at=1:10, labels=xepr ) -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] reordering densrograms in a heatplot
Hi. I have generated a heatplot and also added a colour bar (using classvec) under the dendrogram that clusters the column subjects. These subjects are divided into four groups, each with a different colour. I have been trying to find a way to reorder the dendrogram by rotating some of the branches so that the colours on the colour bar group together a bit better (just for visual display). Colv seems to fit that purpose, but I can't get it to work. Any suggestions or alternative solutions would be much appreciated. - Hugh Harris [[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] vis.gam zlab problem
Thanks for your assistance David, I'll run your code and see how it goes. Take care. -- View this message in context: http://r.789695.n4.nabble.com/vis-gam-zlab-problem-tp3946213p3948313.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] program never enters browser mode when I add browser()
Dear All I have a program that breaks at the following lines of code: bigfunction = { ... object1 = myfunction(x) object2 = strsplit(object1, ,)[[1]] ... } where myfunction is defined elsewhere outside of bigfunction. The error I get is error in strsplit() -- object1 not found. However, when I insert browser() into my code so that the above reads, bigfunction = { ... browser() object1 = myfunction(x) object2 = strsplit(object1, ,)[[1]] ... } my entire program runs successfully, and oddly *never enters browser mode*. Has anyone encountered a similar problem? Any advice would be greatly appreciated. Thank you, Michelle -- View this message in context: http://r.789695.n4.nabble.com/program-never-enters-browser-mode-when-I-add-browser-tp3948920p3948920.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] Error in optim
I am trying to run this code and obtain the MLEs for my parameters. However I am getting this error at the end. Error in optim(c(1.4, 1.1, 0.8, 0.92, 0.4), poisson.lik, v = v) : objective function in *optim evaluates to length 100 not 1* Code: poisson.lik - function(theta,v){ v=matrix(c(1,3,2,0),nrow=2) n-nrow(v) alpha1 - theta[1] alpha2 - theta[2] beta1 - theta[3] beta2 - theta[4] gamma - theta[5] log.lik - v[1]*log(alpha1*beta2*gamma)-alpha1*beta2*gamma-log(factorial(v[1]))+y*log(alpha2*beta1)-alpha2*beta1-log(factorial(v[2])) return(-log.lik) } optim(c(1.4,1.1,0.8,0.92,0.4),poisson.lik,v=v) Can anyone let me know what I am doing wrong please? Thanks, DJ -- View this message in context: http://r.789695.n4.nabble.com/Error-in-optim-tp3948980p3948980.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] 3d graph to show matrix of z matrix values
Hello, I'm not getting a great looking 3d graph when plotting my z values: x- seq(0.0, max(d1), max(d1)/20) y- seq(0.0, max(d2), max(d2)/20) z- matrix(NA, length(x), length(y)) persp3d(x, y, z, phi=30, theta=30, scale=TRUE,shade = 0.75, col=pal[col.ind], xlab=var.name[1], ylab=var.name[2], main=3d plot) Your z values are all NA. What are you expecting to see? *z values*: i - 0 for (el.x in x) { i - i+1 j - 1 for (el.y in y) { if( el.x==0 el.y==0) *z[i,j]* - Emax + B if(!(el.x==0 el.y==0)) *z[i,j]* - model(el.x, el.y, m1, m2, dm1, dm2, alpha) j - j+1 } } -- View this message in context: http://r.789695.n4.nabble.com/3d-graph-to-show-matrix-of-z-matrix-values-tp3948174p3948273.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 install rJava
Hello. I have this error: install.packages(rJava) Installing package(s) into ‘C:/PROGRA~1/R/R-212~1.0/library’ (as ‘lib’ is unspecified) Warning in install.packages : package ‘rJava’ is not available Does this mean that rJava is not available at all? -- View this message in context: http://r.789695.n4.nabble.com/Can-t-install-rJava-tp3948460p3948460.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] Error in optim
The likelihood function is a product. Thus, the log likelihood function is a sum. Your log.lik statement, however, fails to compute the sum, which it should minimize. Hence your optim statement does not know what to optimize because log.lik is a vector of the length of the number of observations in your data (100) when it should be of length (1), i.e., the sum of the former. If you define log.lik as the appropriate sum, you should be successful. HTH. Daniel djbanana wrote: I am trying to run this code and obtain the MLEs for my parameters. However I am getting this error at the end. Error in optim(c(1.4, 1.1, 0.8, 0.92, 0.4), poisson.lik, v = v) : objective function in *optim evaluates to length 100 not 1* Code: poisson.lik - function(theta,v){ v=matrix(c(1,3,2,0),nrow=2) n-nrow(v) alpha1 - theta[1] alpha2 - theta[2] beta1 - theta[3] beta2 - theta[4] gamma - theta[5] log.lik - v[1]*log(alpha1*beta2*gamma)-alpha1*beta2*gamma-log(factorial(v[1]))+y*log(alpha2*beta1)-alpha2*beta1-log(factorial(v[2])) return(-log.lik) } optim(c(1.4,1.1,0.8,0.92,0.4),poisson.lik,v=v) Can anyone let me know what I am doing wrong please? Thanks, DJ -- View this message in context: http://r.789695.n4.nabble.com/Error-in-optim-tp3948980p3949006.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] model frame problem
Dear R community: I am working on a model frame problem which is important for my data analysis. What I am trying to get is to get data set d3 through the model formula ff=y~a+b+a*b and data set d1 to generate a new data set d3 rather than d2. I have tried several ways but did not get that done. I would greatly appreciate any help. The codes are listed as follows: Jixiang Wu a=c(1:10) b=c(1:10) ab=paste(a,b,sep=*) d1=data.frame(y=rnorm(10),a=a,b=b) ff=y~a+b+a*b d2=model.frame(ff,d1) ## this generate from model.frame d2 d3=data.frame(y=rnorm(10),a=a,b=b,ab=ab) ## this is what I need d3 [[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] GLM Help
Hey all, I am attempting to replicate my results achieved in another program within R (so I can expand my options for methods). I am trying to run a GLM (Family = Poisson) for count data in R. Some of my variables are factors and I am under the impression that the function glm() cannot run a model with Poisson dist and factors?? Here is why I think this, if I run two models using glm(), one treating a variable (e.g., Harvest.Factor) as a Factor and the other treating a variable as continuous (e.g., Harvest.Cont) I get the same results in R. Is there a package that will allow me to run a GLM using a Poisson dist and factor variables? Thanks for any help! -Chris -- View this message in context: http://r.789695.n4.nabble.com/GLM-Help-tp3949104p3949104.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] model frame problem
Dear R community: I am working on a model frame problem which is important for my data analysis. What I am trying to get is to get data set d3 through the model formula ff=y~a+b+a*b and data set d1 to generate a new data set d3 which includes a interaction column between a and b rather than d2. I have tried several ways but did not get that done. I would greatly appreciate any help. The codes are listed as follows: Jixiang Wu a=c(1:10) b=c(1:10) ab=paste(a,b,sep=*) d1=data.frame(y=rnorm(10),a=a,b=b) ff=y~a+b+a*b d2=model.frame(ff,d1) ## this generate from model.frame d2 d3=data.frame(y=rnorm(10),a=a,b=b,ab=ab) ## this is what I need d3 -- View this message in context: http://r.789695.n4.nabble.com/model-frame-problem-tp3948602p3948602.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] Split an array into arbirtary sizes
Hi there, I have a ts object that I would like wo split into arbirary sizes. Can'tfind how to do this? I realise its probaly very simple buy I can't sem to find the right function? -- View this message in context: http://r.789695.n4.nabble.com/Split-an-array-into-arbirtary-sizes-tp3948938p3948938.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] Contrasts with an interaction. How does one specify the dummy variables for the interaction
Daniel, I want to use the contrast library because I want to be able to specify any arbitrary post-hoc contrast, e.g. Given a 3x2 table describing smoking (never, former, current) by sex (male,female), I can use a post-hoc contrast to compare the fraction of female former smokers to the fraction of male former smokers, or the fraction of male former smokers to the fraction of male current smokers, etc. To the best of my knowledge, post-hoc contrasts are the most flexible, and easiest way to specify arbitrary pre-specified comparisons. John John David Sorkin M.D., Ph.D. Chief, Biostatistics and Informatics University of Maryland School of Medicine Division of Gerontology Baltimore VA Medical Center 10 North Greene Street GRECC (BT/18/GR) Baltimore, MD 21201-1524 (Phone) 410-605-7119 (Fax) 410-605-7913 (Please call phone number above prior to faxing) Daniel Malter dan...@umd.edu 10/28/2011 4:02 PM Is there a specific reason why you insist on using the contrast library? If not: # Create 2x2 contingency table. counts=c(50,50,30,70) row -gl(2,2,4) column - gl(2,1,4) mydata - data.frame(row,column,counts) print(mydata) #Create contrasts row-factor(row) column-factor(column) contrasts(row)-contr.treatment(levels(row)) contrasts(column)-contr.treatment(levels(column)) # Works for Terps fit.terp-glm(counts ~ row + column + row*column, family=poisson(link=log)) summary(fit.terp) HTH, Daniel Malter University of Maryland, College Park John Sorkin wrote: Forgive my resending this post. To data I have received only one response (thank you Bert Gunter), and I still do not have an answer to my question. Respectfully, John Windows XP R 2.12.1 contrast package. I am trying to understand how to create contrasts for a model that contatains an interaction. I can get contrasts to work for a model without interaction, but not after adding the interaction. Please see code below. The last two contrast statements show the problem. I would appreciate someone letting me know what is wrong with the syntax of my contrast statements. Thank you, John library(contrast) # Create 2x2 contingency table. counts=c(50,50,30,70) row -gl(2,2,4) column - gl(2,1,4) mydata - data.frame(row,column,counts) print(mydata) # Show levels of 2x2 table levels(mydata$row) levels(mydata$column) # Models, no interaction, and interaction fitglm0 - glm(counts ~ row + column, family=poisson(link=log)) fitglm - glm(counts ~ row + column + row*column, family=poisson(link=log)) # Contrasts for model without interaction works fine! anova(fitglm0) summary(fitglm0) con0-contrast(fitglm0,list(row=1,column=1)) print(con0,X=TRUE) # Contrast for model with interaction does not work. anova(fitglm) summary(fitglm) con-contrast(fitglm,list(row=1,column=1) print(con,X=TRUE) # Nor does this work. con-contrast(fitglm,list(row=1,column=1,row:column=c(0,0))) print(con,X=TRUE) 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 ...{{dropped:31}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] program never enters browser mode when I add browser()
Short answer: I have not. Long answer: Read the posting guide. Provide a reproducible example. Show actual error messages. Identify your operating system and version of R. Read the posting guide. Then try posting again. --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. M. Tran michellev.t...@gmail.com wrote: Dear All I have a program that breaks at the following lines of code: bigfunction = { ... object1 = myfunction(x) object2 = strsplit(object1, ,)[[1]] ... } where myfunction is defined elsewhere outside of bigfunction. The error I get is error in strsplit() -- object1 not found. However, when I insert browser() into my code so that the above reads, bigfunction = { ... browser() object1 = myfunction(x) object2 = strsplit(object1, ,)[[1]] ... } my entire program runs successfully, and oddly *never enters browser mode*. Has anyone encountered a similar problem? Any advice would be greatly appreciated. Thank you, Michelle -- View this message in context: http://r.789695.n4.nabble.com/program-never-enters-browser-mode-when-I-add-browser-tp3948920p3948920.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. [[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] Error in optim
I understand that the likelihood function is a product and hence the log likelihood function is a sum. However I can't figure out what the problem is. Here's the likelihood function: [(alpha1*beta2*gamma)^v1 exp^(-alpha1*beta2*gamma)]/v1! * [(alpha2*beta1)^v2 exp^(-alpha2*beta1)]/v2! Isn't the log-likelihood function as I calculated before? Thanks, DJ -- View this message in context: http://r.789695.n4.nabble.com/Error-in-optim-tp3948980p3949218.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] About the statistics for ratio comparison
Ask a psychic? Perhaps show your real problem (not this vague handwaving) to a statistician? If you are in a statistics course, talk to your instructor or teaching assistant? This is R-help, not a statistics helpline, or a homework helpline. You are expected to know at least the basic statistics theory you need to implement, and provide a reproducible example using R syntax to get your helpers started in the right direction. Some points you should try to clarify: what do you mean by average? What distribution(s) does your data follow? What is your null hypothesis? --- Jeff Newmiller The . . Go Live... DCN:jdnew...@dcn.davis.ca.us Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. Meng Wu mengwu1...@gmail.com wrote: Hi I have a table with four columns and 3 rows. I calculated the average for each columns as average (A), average (B), average (C) and average (D), then calculate the relative ratio as average (A)/average (B), and average (C)/average (D). I would like to know how can I calculate the significance between the two ratios. Thanks, Meng [[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] Graphics Reciprocal labeling
Can I also label selected reciprocal numbers easily either alongside or without the automatic ones, and have them automatically in their correct spots. Sorry, I really don't know R now. -- View this message in context: http://r.789695.n4.nabble.com/Graphics-Reciprocal-labeling-tp3949054p3949357.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] GLM Help
Are you sure your variables are categorical or numeric? Of course, glm differentiates these two kinds of variables. For example, I ran the same variable with different modes, the results are very different. dat-data.frame(y=rpois(100,5),xf=as.factor(sample(1:4,100,replace=T))) glm(y~xf,data=dat,family=poisson) Call: glm(formula = y ~ xf, family = poisson, data = dat) Coefficients: (Intercept) xf2 xf3 xf4 1.60944 -0.12783 -0.11878 -0.09746 ... glm(y~as.numeric(xf),data=dat,family=poisson) Call: glm(formula = y ~ as.numeric(xf), family = poisson, data = dat) Coefficients: (Intercept) as.numeric(xf) 1.59047-0.02673 Weidong Gu On Fri, Oct 28, 2011 at 4:21 PM, CES smit4...@umn.edu wrote: Hey all, I am attempting to replicate my results achieved in another program within R (so I can expand my options for methods). I am trying to run a GLM (Family = Poisson) for count data in R. Some of my variables are factors and I am under the impression that the function glm() cannot run a model with Poisson dist and factors?? Here is why I think this, if I run two models using glm(), one treating a variable (e.g., Harvest.Factor) as a Factor and the other treating a variable as continuous (e.g., Harvest.Cont) I get the same results in R. Is there a package that will allow me to run a GLM using a Poisson dist and factor variables? Thanks for any help! -Chris -- View this message in context: http://r.789695.n4.nabble.com/GLM-Help-tp3949104p3949104.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Error in optim
Why don't you try substituting your vector of values and see what comes out...once you figure out what happened, the sum() command will solve your problems. Michael On Oct 28, 2011, at 5:10 PM, djbanana karl79264...@gmail.com wrote: I understand that the likelihood function is a product and hence the log likelihood function is a sum. However I can't figure out what the problem is. Here's the likelihood function: [(alpha1*beta2*gamma)^v1 exp^(-alpha1*beta2*gamma)]/v1! * [(alpha2*beta1)^v2 exp^(-alpha2*beta1)]/v2! Isn't the log-likelihood function as I calculated before? Thanks, DJ -- View this message in context: http://r.789695.n4.nabble.com/Error-in-optim-tp3948980p3949218.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Split an array into arbirtary sizes
[ perhaps? You really need to say more about what you are looking to do if you want a more informative answer M On Oct 28, 2011, at 3:11 PM, Bazman76 h_a_patie...@hotmail.com wrote: Hi there, I have a ts object that I would like wo split into arbirary sizes. Can'tfind how to do this? I realise its probaly very simple buy I can't sem to find the right function? -- View this message in context: http://r.789695.n4.nabble.com/Split-an-array-into-arbirtary-sizes-tp3948938p3948938.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 3d graph to show matrix of z matrix values
On 11-10-28 11:34 AM, playballa23 wrote: Hello, I'm not getting a great looking 3d graph when plotting my z values: x- seq(0.0, max(d1), max(d1)/20) y- seq(0.0, max(d2), max(d2)/20) z- matrix(NA, length(x), length(y)) persp3d(x, y, z, phi=30, theta=30, scale=TRUE,shade = 0.75, col=pal[col.ind], xlab=var.name[1], ylab=var.name[2], main=3d plot) Your z values are all NA. What are you expecting to see? *z values*: i- 0 for (el.x in x) { i- i+1 j- 1 for (el.y in y) { if( el.x==0 el.y==0) *z[i,j]*- Emax + B if(!(el.x==0 el.y==0)) *z[i,j]*- model(el.x, el.y, m1, m2, dm1, dm2, alpha) j- j+1 } } Is that supposed to respond to my statement or my question? It doesn't seem to do either... Duncan Murdoch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] program never enters browser mode when I add browser()
Hi Michelle, In addition to Jeff's advice, can you now reproduce the original error? What you are describing is highly improbable if everything is properly executed. It becomes more likely if more was chagned between running than just inserting browser(). For example, if you reran/had made changes in other code you forgot to run and then sourced that into R in addition to having added browser() to bigfunction. If browser() was really run, it should have come up, perhaps somewhere in is something made the function return a value and terminate or your code is written in such a way that the portion that browser() was in was not run. Right now this is all just speculation, further help will really require more details to work with. Cheers, Josh On Fri, Oct 28, 2011 at 12:04 PM, M. Tran michellev.t...@gmail.com wrote: Dear All I have a program that breaks at the following lines of code: bigfunction = { ... object1 = myfunction(x) object2 = strsplit(object1, ,)[[1]] ... } where myfunction is defined elsewhere outside of bigfunction. The error I get is error in strsplit() -- object1 not found. However, when I insert browser() into my code so that the above reads, bigfunction = { ... browser() object1 = myfunction(x) object2 = strsplit(object1, ,)[[1]] ... } my entire program runs successfully, and oddly *never enters browser mode*. Has anyone encountered a similar problem? Any advice would be greatly appreciated. Thank you, Michelle -- View this message in context: http://r.789695.n4.nabble.com/program-never-enters-browser-mode-when-I-add-browser-tp3948920p3948920.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. -- Joshua Wiley Ph.D. Student, Health Psychology Programmer Analyst II, ATS Statistical Consulting Group University of California, Los Angeles https://joshuawiley.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] Graphics Reciprocal labeling
On Oct 28, 2011, at 6:23 PM, Hurr wrote: Can I also label selected reciprocal numbers easily either alongside or without the automatic ones, and have them automatically in their correct spots. Sorry, I really don't know R now. I am unable to parse your request into standard English. Please post a reproducible example of a data situation and specify what you want to see. -- David Winsemius, MD West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Graphics Reciprocal labeling
On 10/29/2011 09:23 AM, Hurr wrote: Can I also label selected reciprocal numbers easily either alongside or without the automatic ones, and have them automatically in their correct spots. Sorry, I really don't know R now. Hi Hurr, What you want is probably achievable with the axis function. The idea is not to display the X axis (xaxt=n) in the initial plot command and then add the custom axis later. To give a simple example: plot(1:10,xaxt=n) axis(side=1,at=1:10,round(labels=1/1:10,2)) or if you want fraction notation: axis(side=1,at=1:10,labels=paste(1,1:10,sep=/)) If you want to have both the original numbers and the fractions: axis(side=1,at=1:10,padj=0.3, labels=paste(1:10,paste(1,1:10,sep=/),sep=\n)) and so on. The important things to remember are, at is where the labels will be placed and labels is what they will look like. Jim __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ACE/AVAS with bootstrap
require(Hmisc) ?areg.boot Frank Mishra, Srikanta wrote: I am using ACE/AVAS to fit a non-parametric regression model to a multivariate data set. Is there a way to add confidence intervals to the fit and predictions by using bootstrap? Thanks for any suggestions. [[alternative HTML version deleted]] __ R-help@ mailing list https://stat.ethz.ch/mailman/listinfo/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 Harrell Department of Biostatistics, Vanderbilt University -- View this message in context: http://r.789695.n4.nabble.com/ACE-AVAS-with-bootstrap-tp3948613p3950068.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] xtable with \begin{tabular} and only.contents
As suggested I switched over to sweave. Not to bore you with the details but I have a lot of .tex tables that I have already created that I was previously inserting into my tex document (using \input). The journal I plan on submitting to eventually wants the final .tex file so I thought it would be a good idea to use Sweave, it makes a tex doc with my tables generated and it should be all good. I just spend a few hours trying to get the \SweaveInput commant to work properly. I finally determined that I couldn't put the file in as an absolute path but it had to be a relative path. I.e \SweaveInput{/home/tdavies/Dropbox/CollapseRecovery_Shared/trevor/afterAFS/writing/sweave/blah.tex} gave the error: R CMD Sweave hitmiss.Rnw Error in SweaveReadFile(c(ifile, file), syntax, encoding = encoding) : no Sweave file with name './/home/tdavies/Dropbox/CollapseRecovery_Shared/trevor/afterAFS/writing/sweave/blah.tex' found Calls: Anonymous - Sweave - SweaveReadFile - SweaveReadFile Execution halted make: *** [hitmiss.tex] Error 1 However, when i use: \SweaveInput{../../../../../../../../home/tdavies/Dropbox/CollapseRecovery_Shared/trevor/afterAFS/writing/sweave/blah.tex} It works fine. What am I missing here? Thanks. On Fri, Oct 28, 2011 at 11:48 AM, Duncan Murdoch murdoch.dun...@gmail.comwrote: On 28/10/2011 2:40 PM, Trevor Davies wrote: I have found that I like having my captions and labels in my latex document rather than having them contained in my xtable output file (I haven't fully gone to sweave yet). The remark in the parens is the problem here. Use Sweave. Duncan Murdoch I know I can do something like this by using the 'only.contents' argument in xtable. Unfortunately, the only.contents argument also removes the \begin{tabular}{rr} \end{tabular} (in the example below) of the table.This means that I have to go look up each table to determine the number of columns. Is there a more automated way that I am missing? i.e only.contents but with tabular headers (but not \begin{table})? Thank you. CODE: ## Demonstrate include.rownames, include.colnames, ## only.contents and add.to.row arguments set.seed(2345) res- matrix(sample(0:9, size=6*9, replace=TRUE), ncol=6, nrow=9) xres- xtable(res) digits(xres)- rep(0, 7) addtorow- list() addtorow$pos- list() addtorow$pos[[1]]- c(0, 2) addtorow$pos[[2]]- 4 addtorow$command- c('\vspace{2mm} \n', '\vspace{10mm} \n') print(xres, add.to.row=addtorow, include.rownames=FALSE, include.colnames=TRUE, only.contents=TRUE, hline.after=c(0, 0, 9, 9)) Output (only.contents=TRUE) % latex table generated in R 2.13.2 by xtable 1.6-0 package % Fri Oct 28 11:38:10 2011 1 2 3 4 5 6 \\ space{2mm} \hline \hline 1 7 6 6 5 9 \\ 1 1 1 5 7 7 \\ space{2mm} 7 3 9 8 0 5 \\ 0 0 4 1 5 2 \\ space{10mm} 4 1 8 5 7 1 \\ 2 4 5 9 5 4 \\ 6 3 3 5 5 8 \\ 7 6 1 0 7 6 \\ 4 4 8 8 3 2 \\ \hline \hline Output (only.contents=FALSE) % latex table generated in R 2.13.2 by xtable 1.6-0 package % Fri Oct 28 11:39:23 2011 \begin{table}[ht] \begin{center} \begin{tabular}{rr} 1 2 3 4 5 6 \\ space{2mm} \hline \hline 1 7 6 6 5 9 \\ 1 1 1 5 7 7 \\ space{2mm} 7 3 9 8 0 5 \\ 0 0 4 1 5 2 \\ space{10mm} 4 1 8 5 7 1 \\ 2 4 5 9 5 4 \\ 6 3 3 5 5 8 \\ 7 6 1 0 7 6 \\ 4 4 8 8 3 2 \\ \hline \hline \end{tabular} \end{center} \end{table} [[alternative HTML version deleted]] __** R-help@r-project.org mailing list https://stat.ethz.ch/mailman/**listinfo/r-helphttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/** posting-guide.html 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.