Re: [R] I want to use Sweave, but only sometimes
cls59 wrote: Currently pgfSweave is only available from rforge.net and is very much in beta. Well, that said, you can install the latest build using: install.packages(pgfSweave, repos=http://R-Forge.R-project.org;) then for the documentation: ?pgfSweave AND vignette(pgfSweave) -- View this message in context: http://www.nabble.com/I-want-to-use-Sweave%2C-but-only-sometimes-tp23026260p23033700.html Sent from the R help mailing list archive at Nabble.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] I want to use Sweave, but only sometimes
P.S. pgfSweave does include caching of figures as a feature. See the vignette for details. -- View this message in context: http://www.nabble.com/I-want-to-use-Sweave%2C-but-only-sometimes-tp23026260p23033731.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] Building GUI for custom R application
HI R users, I would appreciate information/examples/suggestions on building GUIs for R applications. I am currently working on a project that would require the following functionalities : 1) Display a window to the user. Provide a function to scan local drive and choose dataset file. 2) Display the column names for the user to choose the dependent variable and the independent variables. 3) Fit regression and display statistics. While researching the possibility of creating a GUI which would allow for the above mentioned computations, I came across: 1) rpanel: Simple Interactive Controls for R Functions Using the tcltk Package Found In: Journal of Statistical Software, January 2007, Volume 17, Issue 9. 2) Putting RGtk to Work, James Robison-Cox Found In:Proceedings of the 3rd International Workshop on Distributed Statistical Computing (DSC 2003),March 20–22, Vienna, Austria ISSN 1609-395X http://www.ci.tuwien.ac.at/Conferences/DSC-2003/ Item 2 provides an example of creating a regression application with slider controls for a parameter in loess function used in the example application in that paper. For documentation on RGtk the author recommends reading the Gtk tutorial and documentation. I seem to have difficulty in making sense of the Gtk documentation since most of it is in C and documentation is available for use of Gtk with Perl and Python. I am not a C/Perl/Python programmer. Moreover, I am creating a Windows Application and is using RGtk2 the only way to create a GUI for an R application? Or should I use the the VB approach and create the GUI separately and call R scripts where required to do the back-end computation? Another approach (to make the visualization more rich and dynamic) is to use Adobe FLEX front end and communicate with R using the RSOAP library. There is very sparse documentation relevant to using RSOAP. I have not been able to find examples or tutorials using RSOAP. Any information in this regard will be highly appreciated. The Biocep project provides 'R for cloud computing' but unfortunately I have not been able to extract relevant 'juice' from their webpage. What i did get is their R workbench, but that has not answered my above mentioned queries. Regards, Harsh Singhal __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Fedora 10 KDE plasma font rendering issue
On Sun, 2009-04-12 at 13:19 +0100, Paul Bivand wrote: I checked with my KDE 4.2 (Mandriva 2009 system, kde.org binaries) with no font rendering issues in running demo(graphics). It is quite possible that pango was not installed with Fedora (as it is unnecessary for KDE 4.2 systems). Installing the relevant rpm may fix things. The pango RPM should have been installed with R, as R requires the pango and pangocairo libraries that it provides: [mar...@seurat ~]$ rpm -q --requires R-core | grep pango - libpango-1.0.so.0()(64bit) libpangocairo-1.0.so.0()(64bit) The packaging of the Fedora 2.8.1 rpm may need to take this into account - if compiling, you'd have discovered at configure stage. Paul Bivand Paul Bivand 2009/4/1 Martyn Plummer plum...@iarc.fr: On Tue, 2009-03-31 at 18:36 -0700, dfermin wrote: Nope. I checked this. Both those fonts are installed. Well it is some kind of font rendering problem. The default device is the Cairo X11 device, which uses the Pango layout engine for font rendering. If you set the environment variable FC_DEBUG to 1 before launching your R session, you will get some debugging information. It is very verbose, but we only need to see this bit: First font Pattern has 15 elts (size 15) family: Nimbus Sans L(w) style: Regular(w) slant: 0(i)(w) weight: 80(i)(w) width: 100(i)(w) foundry: urw(w) file: /usr/share/fonts/default/Type1/n019003l.pfb(w) index: 0(i)(w) outline: FcTrue(w) scalable: FcTrue(w) Martyn Plummer-2 wrote: Quoting dfermin dfer...@umich.edu: Hello. I've got a new workstation running Fedora 10 linux and I use the KDE 4.2 desktop which uses some kind of new desktop environment called 'plasma'. If I start up R and generate a plot (for example: hist(rnorm(1, mean=0, sd=1), breaks=100) ). The plot appears but all text (the x/y axes, title, etc..) is replaced by a square box. No font is rendered at all. Has anyone else got this problem? If so do you have a work around or a solution? I'm using R version 2.8.1 installed from the Fedora 10 repositories if that helps. Thanks in advance. It sounds like you are missing some fonts. Check that the urw-fonts and liberation-fonts RPMs are installed. --- This message and its attachments are strictly confidenti...{{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. --- This message and its attachments are strictly confidenti...{{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] any other fast method for median calculation
Sorting with an appropriate algorithm is nlog(n), so it's very hard to get the 'exact' median any faster. However, if you can cope with a less precise median, you could use a binary search between max(x) and min(x) with low tolerance or comparatively few iterations. In native R, though, that isn;t going to be fast; interpreter overhead will likely more than wipe out any reduction in number of comparisons. In any case, it looks like you are not constrained by the median algorithm, but by the number of calls. You might do a lot better with apply, though apply(df,2,median) On my system 200k columns were processed in negligible time by apply and I'm still waiting for mapply. S Zheng, Xin (NIH) [C] zheng...@mail.nih.gov 14/04/2009 05:29:40 Hi there, I got a data frame with more than 200k columns. How could I get median of each column fast? mapply is the fastest function I know for that, it's not yet satisfied though. It seems function median in R calculates median by sort and mean. I am wondering if there is another function with better algorithm. Any hint? Thanks, Xin Zheng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] any other fast method for median calculation
there is function rowMedians in Bioconductor package Biobase which works for numeric matrices and might help. Matthias Dimitris Rizopoulos wrote: S Ellison wrote: Sorting with an appropriate algorithm is nlog(n), so it's very hard to get the 'exact' median any faster. However, if you can cope with a less precise median, you could use a binary search between max(x) and min(x) with low tolerance or comparatively few iterations. In native R, though, that isn;t going to be fast; interpreter overhead will likely more than wipe out any reduction in number of comparisons. In any case, it looks like you are not constrained by the median algorithm, but by the number of calls. You might do a lot better with apply, though apply(df,2,median) well, for data frames, I think sapply(...) or even unlist(lapply(...)) will be faster, e.g., mat - matrix(rnorm(50*2e05), 50, 2e05) DF - as.data.frame(mat) invisible({gc(); gc()}) system.time(apply(DF, 2, median)) invisible({gc(); gc()}) system.time(sapply(DF, median)) invisible({gc(); gc()}) system.time(unlist(lapply(DF, median), use.names = FALSE)) Best, Dimitris On my system 200k columns were processed in negligible time by apply and I'm still waiting for mapply. S Zheng, Xin (NIH) [C] zheng...@mail.nih.gov 14/04/2009 05:29:40 Hi there, I got a data frame with more than 200k columns. How could I get median of each column fast? mapply is the fastest function I know for that, it's not yet satisfied though. It seems function median in R calculates median by sort and mean. I am wondering if there is another function with better algorithm. Any hint? Thanks, Xin Zheng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dr. Matthias Kohl www.stamats.de __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Odp: Plot legend
Hi When I tried to make a plot according to your code I got plot(CO2ppm_1$CO2_ppm,ylim=c(-7,10), + axes = FALSE,type=b,pch=16,cex=1,col=skyblue4,main=TC (Model AM2t) SPL Mean Diurnal Cycle,xlab=Hours (GMT),ylab=CO2(ppm),col.main=black,font.main=4,lwd=1.8,col.lab=black,col.sub=Black) Error in plot(CO2ppm_1$CO2_ppm, ylim = c(-7, 10), axes = FALSE, type = b, : object 'CO2ppm_1' not found so it can be that you use some data I do not have available. Anyvey you can vectorize your specification of legend like that plot(1,1) legend(topright, legend=letters[1:3], pch=c(19,19,NA), lty=c(NA,1,2)) and use NA when you do not want this symbol plotted. Regards Petr r-help-boun...@r-project.org napsal dne 11.04.2009 00:59:55: Dear All- I am trying to create a legend where the first 9 terms are represented as pch=16 in one column (which I am able to do); but, I would like the last two terms in that column to be 'lines (which are black and red - just as it looks like in the plot). I have read through many help pages and searched the help listserv, but haven't figured this one out yet. Does anyone have any suggestions or if you could point me to a help page that i may have missed, I would greatly appreciate it. a bit of my code is below: thanks- sherri plot(CO2ppm_1$CO2_ppm,ylim=c(-7,10), axes = FALSE,type=b,pch=16,cex=1,col=skyblue4,main=TC (Model AM2t) SPL Mean Diurnal Cycle,xlab=Hours (GMT),ylab=CO2 (ppm),col.main=black,font.main=4,lwd=1.8,col.lab=black,col.sub=Black) points(CO2ppm_2$CO2_ppm,type=b,pch=16,col=green) points(CO2ppm_3$CO2_ppm,type=b,pch=16,col=dark orange) points(CO2ppm_4$CO2_ppm,type=b,pch=16,col=light green) points(CO2ppm_5$CO2_ppm,type=b,pch=16,col=dark green) points(CO2ppm_6$CO2_ppm,type=b,pch=16,col=yellow) points(CO2ppm_7$CO2_ppm,type=b,pch=16,col=dark blue) points(CO2ppm_8$CO2_ppm,type=b,pch=16,col=purple) points(CO2ppm_9$CO2_ppm,type=b,pch=16,col=dark red) lines(sub_dlyavg_w[,1],type=l,lwd=3,col=black) lines(sub_dlyavg_p[,1],type=l,lwd=3,col=red) axis(1, at=1:23, labels=as.character(seq(1,23)), cex.axis=.7) axis(2, at=-7:10, labels=as.character(seq(-7,10)), cex.axis=.7) box(col = 'black') mtext(June - August, font=2,side=3,cex=1,col=black) legend(topright,c('Level 1','Level 2','Level 3', 'Level 4','Level 5', 'Level 6','Level 7','Level 8','Level 9','RAC UNFILT','RAC FILT 1 sig'),lty=1,pch=c(16,16,16,16,16,16,16,16,16),col=c('skyblue4','green','orange', 'light green','dark green','yellow','dark blue','purple','dark red','black', 'red'),ncol=1) legend(bottomleft,c('Model: 2002-2003','RACCOON: 2005-2008'), cex = 1,col = c('black'),ncol=1) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] any other fast method for median calculation
S Ellison wrote: Sorting with an appropriate algorithm is nlog(n), so it's very hard to get the 'exact' median any faster. However, if you can cope with a less precise median, you could use a binary search between max(x) and min(x) with low tolerance or comparatively few iterations. In native R, though, that isn;t going to be fast; interpreter overhead will likely more than wipe out any reduction in number of comparisons. In any case, it looks like you are not constrained by the median algorithm, but by the number of calls. You might do a lot better with apply, though apply(df,2,median) well, for data frames, I think sapply(...) or even unlist(lapply(...)) will be faster, e.g., mat - matrix(rnorm(50*2e05), 50, 2e05) DF - as.data.frame(mat) invisible({gc(); gc()}) system.time(apply(DF, 2, median)) invisible({gc(); gc()}) system.time(sapply(DF, median)) invisible({gc(); gc()}) system.time(unlist(lapply(DF, median), use.names = FALSE)) Best, Dimitris On my system 200k columns were processed in negligible time by apply and I'm still waiting for mapply. S Zheng, Xin (NIH) [C] zheng...@mail.nih.gov 14/04/2009 05:29:40 Hi there, I got a data frame with more than 200k columns. How could I get median of each column fast? mapply is the fastest function I know for that, it's not yet satisfied though. It seems function median in R calculates median by sort and mean. I am wondering if there is another function with better algorithm. Any hint? Thanks, Xin Zheng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. *** This email and any attachments are confidential. Any use...{{dropped:8}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] using Sweave, how to save a plot in a given size
Hi, I'm trying to realise a repport with R and Latex (TeXnicCenter and Miktex for Windows) using Sweave(). I'd like to save my plots in a given size. How can I do that ? The code is : \SweaveOpts{prefix.string = figs/plot, eps = FALSE, pdf = TRUE} partI, echo=FALSE ,fig=TRUE, include=FALSE= plotFunction() @ \includepdf[pages=-]{figs/plot-partI} When I use par(pin=c(width,height)), I get the plot with the right size but saved in a too big pdf page (7in x 7in, the default size of the window). So I tried to change the size of the window with the command windows() but then, Sweave can't save the plot correctly. Thanks everyone. Lore. _ ? Lancez-vous ! [[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] Building GUI for custom R application
On Tue, Apr 14, 2009 at 9:23 AM, Harsh singhal...@gmail.com wrote: HI R users, I would appreciate information/examples/suggestions on building GUIs for R applications. I am currently working on a project that would require the following functionalities : 1) Display a window to the user. Provide a function to scan local drive and choose dataset file. 2) Display the column names for the user to choose the dependent variable and the independent variables. 3) Fit regression and display statistics. Item 2 provides an example of creating a regression application with slider controls for a parameter in loess function used in the example application in that paper. For documentation on RGtk the author recommends reading the Gtk tutorial and documentation. I seem to have difficulty in making sense of the Gtk documentation since most of it is in C and documentation is available for use of Gtk with Perl and Python. I am not a C/Perl/Python programmer. You should say I am not _yet_ a C/Perl/Python programmer. Don't limit yourself :) Moreover, I am creating a Windows Application and is using RGtk2 the only way to create a GUI for an R application? Or should I use the the VB approach and create the GUI separately and call R scripts where required to do the back-end computation? If you are to admit the possibility of becoming a Python programmer (strongly recommended) I'd say you could do it with Python, Rpy, and the Qt library. The basic example you've outlined (choose file, select X and Y values, plot, display stats) would take about twenty minutes. In fact, I've done half the work already, in adding almost just such functionality to Quantum GIS. See here: http://www.maths.lancs.ac.uk/~rowlings/Software/Spqr/ where the second screenshot shows variable selection and diagnostic plots of an lm from data in the GIS. Distributing such an application might be tricky since it requires R, Rpy, PyQt4 to be installed or available, but it can be possible to build Python code into Windows .exe files with some effort. Don't get the fear of learning Python - it's easy, and working with R in Python is easy too. Guess what this does: from rpy import r x = r.rnorm(1000) r.hist(x) The tricky part of your problem is probably going to be understanding whatever GUI system you end up using - they tend to all have different ideas of callbacks, events, signals and so on. In the past I've played with Tcl/Tk a bit and Gtk a teeny bit, but found Qt really easy and cleanly designed. Once you go beyond the simple examples you appreciate this. Okay, obligatory 'use a better language and gui system' rant over :) If you want it done with as little extras as possible, then it can probably be done purely using R's tcltk package. I've just found loads of examples here: http://bioinf.wehi.edu.au/~wettenhall/RTclTkExamples/ Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Faster Solution for a simple code?
Hi this one could be slightly quicker but i am not completely sure because it gives me different results from yours set.seed(111) x-x1-x2- data.frame(a=sample(1:50, 1, replace=T), b=sample(100:500, 1, replace=T)) y- data.frame(a=sample(1:50, 1, replace=T), b=sample(100:500, 1, replace=T)) system.time({ one-paste(x[,1], x[,2], sep=.) two-paste(y[,1], y[,2], sep=.) tab-table(two[two %in% one]) x1[match(names(tab), one),3]-tab }) system.time({ z - merge(x, y, by=c(a, b), all.x=TRUE) x2-t(sapply(split(z, z[,1:2], drop=TRUE), function(.grp){ if (any(is.na(.grp))) return(c(.grp[1,1], .grp[1,2], 0)) c(.grp[1,1], .grp[1,2], nrow(.grp)) })) }) head(x2) head(x1[order(x1[,1], x1[,2]),]) Regards Petr r-help-boun...@r-project.org napsal dne 13.04.2009 21:51:18: try this: x V1 V2 V3 1 500 320 0 2 510 310 0 3 520 310 0 4 520 320 0 y V1 V2 V3 1 500 320 1 2 500 320 1 3 520 310 1 4 520 300 1 z - merge(x, y, by=c(V1, V2), all.x=TRUE) t(sapply(split(z, z[,1:2], drop=TRUE), function(.grp){ + if (any(is.na(.grp))) return(c(.grp[1,1], .grp[1,2], 0)) + c(.grp[1,1], .grp[1,2], nrow(.grp)) + })) [,1][,2] [,3] 510.310 510 3100 520.310 520 3101 500.320 500 3202 520.320 520 3200 On Mon, Apr 13, 2009 at 1:06 PM, Chris82 rubenba...@gmx.de wrote: Hi R-users, I create a simple code to check out how often the same numbers in y occur in x. For example 500 32 occurs two times. But the code with the loop is extremly slow. x have 6100 lines and y sometimes more than 5 lines. Is there any alternative code to create with R? thanks. x 500 320 0 510 310 0 520 310 0 520 320 0 lengthx - length(x[,1]) y 500 320 1 500 320 1 520 310 1 520 300 1 langthy - length(y[,1]) for (i in 1:lengthx){ for (j in 1:lengthy){ if (x[i,1] == y[j,1]){ if (x[i,2] == y[j,2]){ x[i,3] - x[i,3] + 1 } } } } x 1 500320 2 2 510310 0 3 520310 1 4 520320 0 -- View this message in context: http://www.nabble.com/Faster-Solution-for-a- simple-code--tp23024985p23024985.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building GUI for custom R application
On Tue, Apr 14, 2009 at 6:54 AM, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Tue, Apr 14, 2009 at 9:23 AM, Harsh singhal...@gmail.com wrote: HI R users, I would appreciate information/examples/suggestions on building GUIs for R applications. I am currently working on a project that would require the following functionalities : 1) Display a window to the user. Provide a function to scan local drive and choose dataset file. 2) Display the column names for the user to choose the dependent variable and the independent variables. 3) Fit regression and display statistics. Item 2 provides an example of creating a regression application with slider controls for a parameter in loess function used in the example application in that paper. For documentation on RGtk the author recommends reading the Gtk tutorial and documentation. I seem to have difficulty in making sense of the Gtk documentation since most of it is in C and documentation is available for use of Gtk with Perl and Python. I am not a C/Perl/Python programmer. You should say I am not _yet_ a C/Perl/Python programmer. Don't limit yourself :) Moreover, I am creating a Windows Application and is using RGtk2 the only way to create a GUI for an R application? Or should I use the the VB approach and create the GUI separately and call R scripts where required to do the back-end computation? If you are to admit the possibility of becoming a Python programmer (strongly recommended) I'd say you could do it with Python, Rpy, and the Qt library. The basic example you've outlined (choose file, select X and Y values, plot, display stats) would take about twenty minutes. In fact, I've done half the work already, in adding almost just such functionality to Quantum GIS. See here: http://www.maths.lancs.ac.uk/~rowlings/Software/Spqr/ where the second screenshot shows variable selection and diagnostic plots of an lm from data in the GIS. Distributing such an application might be tricky since it requires R, Rpy, PyQt4 to be installed or available, but it can be possible to build Python code into Windows .exe files with some effort. Since you are using Windows (based on the fact you are considering VB) note that rpy2 does not work with the recent versions of python (as of a few months ago when I checked). __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Histogram and moving average
Hi everyone, I have a 'basic' issue and hope someone has a bit of code to solve it. I have two populations plotted as histograms on the same figure. Basically I want to add the moving average (based on hist) for both populations on my graph. I'm also interested in the x coordinate of the curves intersection. Any thoughts? Your help would be much appreciated! Thanks, Gan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] matching lists
Dear All, Here's my problem. I have two lists: v [[1]] [1] five [[2]] [1] four [[3]] [1] three [[4]] [1] two [[5]] [1] one [[6]] [1] six [[7]] [1] five four three two one six [[8]] [1] four three two one six [[9]] [1] three two one six [[10]] [1] two one six and the other is something like: values numbers five 50 four 40 three 30 two 10 one 10 six 10 I'm trying to get a list similar to v, but in which the entries three, two, and so on are replaced by the values in the second list. Any help will be greatly appreciated. best regards, Manoel [[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] Decomposition of time series with forecast package
Hi! I am exploring the forecast package (http://www.robjhyndman.com/ index.php?option=com_contenttask=viewid=55Itemid=71). I am doing ARIMA modelling with auto.arima() function. Is it possible to get the decomposition of a time series using the model found by auto.arima()? I would like to decompose a time series in trend, seasonal and irregular components according to the model. I have looked at the decompose() and stl() functions. But these function do not take into account the specific model found by auto.arima(). Thanks! Martins __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on zero-inflated Poisson count data with r epeated measures design - glmm.ADMB
Strubbe Diederik diederik.strubbe at ua.ac.be writes: Dear R community, I have some questions regarding the analysis of a zero-inflated count dataset and repeated measures design. The dataset is arranged as follows : Unit of analysis: point - these are points were bird were counted during a certain amount of time. In total we have about 175 points. Each point is located within a certain habitat fragment (here: site = A-B-C-D-..., in reality we have 25 sites,i.e. forest fragments). All points were counted five times during three years ( thus in total, each point was counted 15 times). We want to relate the bird abundance to a number of habitat variables (here: X1-X2-X3) collected at the site level. Abundance: this is the number of birds counted at a point. In most cases ( 90%), no birds were detected and the abundance dataset is thus zero-inflated. I have been looking for a code to analyze this zero-inflated poisson distributed dataset with a repeated measures design, and I have arrived at the glmmADMB package. library(glmmADMB) data - read.table(D:/Boris/Borisdataset.csv,sep=,,header=TRUE) count - data$count site - data$site abundance - data$abundance test-glmm.admb(abundance~data$X1+data$X2+data$year,random=~count, group=site,data=data,family=poisson,zeroInflation=TRUE) [ for clarity: in the above syntax: count ranges from 1-5 as each site has been counted 5 times in a year, site refers to one of the 25 forest fragments in which the point counts were conducted, Xi are the habitat variables]. My questions are: - does it make sense to analyze these data at the point level, as all habitat variables are collected at the site level, meaning that for all points belonging to a certain forest fragment, the habitat variables have the same value. If it does make sense, is the proposed syntax ok? Is there any option to include year as a random effect, as I am not especially interested in differences between years. -it looks appealing to average the point count values for each forest fragment, and to analyze the data with forest fragment as unit of analysis. However, also when averaging across fragments, the dataset is still zero-inflated. It is however impossible to a zero-inflated Poisson distribution for this analysis, as the averaged forest fragment values are not always discrete values. Rather than averaging, one can side-step that problem by instead summing over points within sites and using a log(time) offset for any fixed differences in time of observation across sites. It sounds sensible to me to take the approach of a site-level analysis, but my credentials are not in statistics so it's possible that a more authoritative answer would be offered. -- David Winsemius __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] using Sweave, how to save a plot in a given size
Hi I do somthing like: \SweaveOpts{prefix.string=proj1} label=fig1,fig=T,include=F,width=8, height=12= plot(1:10) @ \begin{figure} \includegraphics {proj1-fig1} %% show \label{..} \end{figure} Wolfgang Lore M a écrit : Hi, I'm trying to realise a repport with R and Latex (TeXnicCenter and Miktex for Windows) using Sweave(). I'd like to save my plots in a given size. How can I do that ? The code is : \SweaveOpts{prefix.string = figs/plot, eps = FALSE, pdf = TRUE} partI, echo=FALSE ,fig=TRUE, include=FALSE= plotFunction() @ \includepdf[pages=-]{figs/plot-partI} When I use par(pin=c(width,height)), I get the plot with the right size but saved in a too big pdf page (7in x 7in, the default size of the window). So I tried to change the size of the window with the command windows() but then, Sweave can't save the plot correctly. Thanks everyone. Lore. _ ? Lancez-vous ! [[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. -- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wolfgang Raffelsberger, PhD Laboratoire de BioInformatique et Génomique Intégratives CNRS UMR7104, IGBMC 1 rue Laurent Fries, 67404 Illkirch Strasbourg, France Tel (+33) 388 65 3300 Fax (+33) 388 65 3276 wolfgang.raffelsberger (at) igbmc.fr __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building GUI for custom R application
It hasn't been updated in years but this page lists some possibilities for R GUI's: http://www.sciviews.org/_rgui/ On Tue, Apr 14, 2009 at 4:23 AM, Harsh singhal...@gmail.com wrote: HI R users, I would appreciate information/examples/suggestions on building GUIs for R applications. I am currently working on a project that would require the following functionalities : 1) Display a window to the user. Provide a function to scan local drive and choose dataset file. 2) Display the column names for the user to choose the dependent variable and the independent variables. 3) Fit regression and display statistics. While researching the possibility of creating a GUI which would allow for the above mentioned computations, I came across: 1) rpanel: Simple Interactive Controls for R Functions Using the tcltk Package Found In: Journal of Statistical Software, January 2007, Volume 17, Issue 9. 2) Putting RGtk to Work, James Robison-Cox Found In:Proceedings of the 3rd International Workshop on Distributed Statistical Computing (DSC 2003),March 20–22, Vienna, Austria ISSN 1609-395X http://www.ci.tuwien.ac.at/Conferences/DSC-2003/ Item 2 provides an example of creating a regression application with slider controls for a parameter in loess function used in the example application in that paper. For documentation on RGtk the author recommends reading the Gtk tutorial and documentation. I seem to have difficulty in making sense of the Gtk documentation since most of it is in C and documentation is available for use of Gtk with Perl and Python. I am not a C/Perl/Python programmer. Moreover, I am creating a Windows Application and is using RGtk2 the only way to create a GUI for an R application? Or should I use the the VB approach and create the GUI separately and call R scripts where required to do the back-end computation? Another approach (to make the visualization more rich and dynamic) is to use Adobe FLEX front end and communicate with R using the RSOAP library. There is very sparse documentation relevant to using RSOAP. I have not been able to find examples or tutorials using RSOAP. Any information in this regard will be highly appreciated. The Biocep project provides 'R for cloud computing' but unfortunately I have not been able to extract relevant 'juice' from their webpage. What i did get is their R workbench, but that has not answered my above mentioned queries. Regards, Harsh Singhal __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] cbind
I have a list of numbers with NAs as below: A[,1] [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [19] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [37] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [55] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [73] NA NA NA 62 78 98 73 57 63 56 88 77 151 165 129 78 83 63 [91] 72 68 61 89 95 74 53 77 90 106 114 113 84 59 60 77 46 91 [109] 108 111 76 75 70 61 65 61 52 94 71 67 52 86 79 97 80 101 [127] 87 53 85 79 86 104 153 128 155 148 NA NA NA NA NA NA NA NA [145] NA NA NA NA NA NA NA I would like to bind a column to this list which begins at 0 when the first number has occured, but provides negative numbers prior to this as below: [1,] -75 NA [2,] -74 NA [3,] -73 NA [4,] -72 NA [5,] -71 NA [6,] -70 NA [7,] -69 NA [8,] -68 NA [9,] -67 NA [10,] -66 NA [11,] -65 NA [12,] -64 NA [13,] -63 NA [14,] -62 NA [15,] -61 NA [16,] -60 NA [17,] -59 NA [18,] -58 NA [19,] -57 NA [20,] -56 NA [21,] -55 NA [22,] -54 NA [23,] -53 NA [24,] -52 NA [25,] -51 NA [26,] -50 NA [27,] -49 NA [28,] -48 NA [29,] -47 NA [30,] -46 NA [31,] -45 NA [32,] -44 NA [33,] -43 NA [34,] -42 NA [35,] -41 NA [36,] -40 NA [37,] -39 NA [38,] -38 NA [39,] -37 NA [40,] -36 NA [41,] -35 NA [42,] -34 NA [43,] -33 NA [44,] -32 NA [45,] -31 NA [46,] -30 NA [47,] -29 NA [48,] -28 NA [49,] -27 NA [50,] -26 NA [51,] -25 NA [52,] -24 NA [53,] -23 NA [54,] -22 NA [55,] -21 NA [56,] -20 NA [57,] -19 NA [58,] -18 NA [59,] -17 NA [60,] -16 NA [61,] -15 NA [62,] -14 NA [63,] -13 NA [64,] -12 NA [65,] -11 NA [66,] -10 NA [67,] -9 NA [68,] -8 NA [69,] -7 NA [70,] -6 NA [71,] -5 NA [72,] -4 NA [73,] -3 NA [74,] -2 NA [75,] -1 NA [76,] 0 62 [77,] 1 78 [78,] 2 98 [79,] 3 73 [80,] 4 57 [81,] 5 63 [82,] 6 56 [83,] 7 88 [84,] 8 77 [85,] 9 151 [86,] 10 165 [87,] 11 129 [88,] 12 78 [89,] 13 83 [90,] 14 63 [91,] 15 72 [92,] 16 68 [93,] 17 61 [94,] 18 89 [95,] 19 95 [96,] 20 74 [97,] 21 53 [98,] 22 77 [99,] 23 90 [100,] 24 106 [101,] 25 114 [102,] 26 113 [103,] 27 84 [104,] 28 59 [105,] 29 60 [106,] 30 77 [107,] 31 46 [108,] 32 91 [109,] 33 108 [110,] 34 111 [111,] 35 76 [112,] 36 75 [113,] 37 70 [114,] 38 61 [115,] 39 65 [116,] 40 61 [117,] 41 52 [118,] 42 94 [119,] 43 71 [120,] 44 67 [121,] 45 52 [122,] 46 86 [123,] 47 79 [124,] 48 97 [125,] 49 80 [126,] 50 101 [127,] 51 87 [128,] 52 53 [129,] 53 85 [130,] 54 79 [131,] 55 86 [132,] 56 104 [133,] 57 153 [134,] 58 128 [135,] 59 155 [136,] 60 148 [137,] 61 NA [138,] 62 NA [139,] 63 NA [140,] 64 NA [141,] 65 NA [142,] 66 NA [143,] 67 NA [144,] 68 NA [145,] 69 NA [146,] 70 NA [147,] 71 NA [148,] 72 NA [149,] 73 NA [150,] 74 NA [151,] 75 NA could anyone help me to with a function that would be able to calculate the sequence I require to bind to the initial sequence? thanks emma -- View this message in context: http://www.nabble.com/cbind-tp23036759p23036759.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] Schoenfeld residuals
Hi, Thank you for your comments and apologies for the delay in replying. rem.Rcens =1 for the censored variables. The problem arises because I am not strictly looking at time to death. Instead I am looking at time to 12-month remission in epilepsy. Therefore a lot of people have the same event i.e. they successfully achieve 12-month remission from day 1 of the treatment. I think I shall avoid the problem by 'excluding' patients with immediate 12-month remission i.e. I will look at patients with immediate success in a separate analysis to patients with delayed success. Thanks for your help, Laura 2009/4/6 Terry Therneau thern...@mayo.edu: Laura Bonnett was kind enough to send me a copy of the data that caused the plotting error, since it was an error I had not seen before. 1. The latest version of survival gives a nicer error message: fit - coxph(Surv(rem.Remtime, rem.Rcens) ~ all.sex, nearma) cfit - cox.zph(fit) plot(cfit) Error in plot.cox.zph(cfit) : Spline fit is singular, try a smaller degrees of freedom 2. What's the problem? There are 1085 events in the data set (rem.Rcens==1), and of these 502 are tied events on exactly day 365. The plot.cox.zph function tries to fit a smoothing spline to the data to help the eye; the fit gives weight 1 to each death and having this high a proportion of ties creates problems for the underlying regression. 3. plot(cfit, df=2) Warning messages: 1: In approx(xx, xtime, seq(min(xx), max(xx), length = 17)[2 * (1:8)]) : collapsing to unique 'x' values 2: In approx(xtime, xx, temp) : collapsing to unique 'x' values These warning messages are ignorable. I'll work on making them go away. 4. A shot in the dark -- is perchance the variable rem.Rcens=1 a marker of a censored observation, and the events are 0? (A whole lot of events at 1 year is suspicious, but half censored at one year is believable.) Then the proper coxph code is fit2 - coxph(Surv(rem.Remtime, rem.Rcens==0) ~ all.sex, nearma) Terry Therneau __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] any other fast method for median calculation
There is a slightly faster algorithm in my quantreg package, see kuantile() but this is only significant when sample sizes are very large. In your case you really need a wrapper that keeps the loop over columns within some lower level language. url:www.econ.uiuc.edu/~rogerRoger Koenker emailrkoen...@uiuc.eduDepartment of Economics vox: 217-333-4558University of Illinois fax: 217-244-6678Champaign, IL 61820 On Apr 13, 2009, at 11:29 PM, Zheng, Xin (NIH) [C] wrote: Hi there, I got a data frame with more than 200k columns. How could I get median of each column fast? mapply is the fastest function I know for that, it's not yet satisfied though. It seems function median in R calculates median by sort and mean. I am wondering if there is another function with better algorithm. Any hint? Thanks, Xin Zheng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Odp: matching lists
Hi lapply should do it if values is a data frame with first column of names and second column numbers. lapply(v, function(x) values[match(x, values[ ,1]), 2]) Regards Petr r-help-boun...@r-project.org napsal dne 14.04.2009 14:01:50: Dear All, Here's my problem. I have two lists: v [[1]] [1] five [[2]] [1] four [[3]] [1] three [[4]] [1] two [[5]] [1] one [[6]] [1] six [[7]] [1] five four three two one six [[8]] [1] four three two one six [[9]] [1] three two one six [[10]] [1] two one six and the other is something like: values numbers five 50 four 40 three 30 two10 one10 six10 I'm trying to get a list similar to v, but in which the entries three, two, and so on are replaced by the values in the second list. Any help will be greatly appreciated. best regards, Manoel [[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] cbind
try this: x - c(rep(NA, 20), sample(100, 25)) n.na - sum(is.na(x)) cbind(seq(-n.na, length(x) - n.na - 1), x) I hope it helps. Best, Dimitris emj83 wrote: I have a list of numbers with NAs as below: A[,1] [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [19] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [37] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [55] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [73] NA NA NA 62 78 98 73 57 63 56 88 77 151 165 129 78 83 63 [91] 72 68 61 89 95 74 53 77 90 106 114 113 84 59 60 77 46 91 [109] 108 111 76 75 70 61 65 61 52 94 71 67 52 86 79 97 80 101 [127] 87 53 85 79 86 104 153 128 155 148 NA NA NA NA NA NA NA NA [145] NA NA NA NA NA NA NA I would like to bind a column to this list which begins at 0 when the first number has occured, but provides negative numbers prior to this as below: [1,] -75 NA [2,] -74 NA [3,] -73 NA [4,] -72 NA [5,] -71 NA [6,] -70 NA [7,] -69 NA [8,] -68 NA [9,] -67 NA [10,] -66 NA [11,] -65 NA [12,] -64 NA [13,] -63 NA [14,] -62 NA [15,] -61 NA [16,] -60 NA [17,] -59 NA [18,] -58 NA [19,] -57 NA [20,] -56 NA [21,] -55 NA [22,] -54 NA [23,] -53 NA [24,] -52 NA [25,] -51 NA [26,] -50 NA [27,] -49 NA [28,] -48 NA [29,] -47 NA [30,] -46 NA [31,] -45 NA [32,] -44 NA [33,] -43 NA [34,] -42 NA [35,] -41 NA [36,] -40 NA [37,] -39 NA [38,] -38 NA [39,] -37 NA [40,] -36 NA [41,] -35 NA [42,] -34 NA [43,] -33 NA [44,] -32 NA [45,] -31 NA [46,] -30 NA [47,] -29 NA [48,] -28 NA [49,] -27 NA [50,] -26 NA [51,] -25 NA [52,] -24 NA [53,] -23 NA [54,] -22 NA [55,] -21 NA [56,] -20 NA [57,] -19 NA [58,] -18 NA [59,] -17 NA [60,] -16 NA [61,] -15 NA [62,] -14 NA [63,] -13 NA [64,] -12 NA [65,] -11 NA [66,] -10 NA [67,] -9 NA [68,] -8 NA [69,] -7 NA [70,] -6 NA [71,] -5 NA [72,] -4 NA [73,] -3 NA [74,] -2 NA [75,] -1 NA [76,] 0 62 [77,] 1 78 [78,] 2 98 [79,] 3 73 [80,] 4 57 [81,] 5 63 [82,] 6 56 [83,] 7 88 [84,] 8 77 [85,] 9 151 [86,] 10 165 [87,] 11 129 [88,] 12 78 [89,] 13 83 [90,] 14 63 [91,] 15 72 [92,] 16 68 [93,] 17 61 [94,] 18 89 [95,] 19 95 [96,] 20 74 [97,] 21 53 [98,] 22 77 [99,] 23 90 [100,] 24 106 [101,] 25 114 [102,] 26 113 [103,] 27 84 [104,] 28 59 [105,] 29 60 [106,] 30 77 [107,] 31 46 [108,] 32 91 [109,] 33 108 [110,] 34 111 [111,] 35 76 [112,] 36 75 [113,] 37 70 [114,] 38 61 [115,] 39 65 [116,] 40 61 [117,] 41 52 [118,] 42 94 [119,] 43 71 [120,] 44 67 [121,] 45 52 [122,] 46 86 [123,] 47 79 [124,] 48 97 [125,] 49 80 [126,] 50 101 [127,] 51 87 [128,] 52 53 [129,] 53 85 [130,] 54 79 [131,] 55 86 [132,] 56 104 [133,] 57 153 [134,] 58 128 [135,] 59 155 [136,] 60 148 [137,] 61 NA [138,] 62 NA [139,] 63 NA [140,] 64 NA [141,] 65 NA [142,] 66 NA [143,] 67 NA [144,] 68 NA [145,] 69 NA [146,] 70 NA [147,] 71 NA [148,] 72 NA [149,] 73 NA [150,] 74 NA [151,] 75 NA could anyone help me to with a function that would be able to calculate the sequence I require to bind to the initial sequence? thanks emma -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] matching lists
Try this, numbers - c(one,two,three,four) values - c(10,20,30,40) v - list(sample(numbers,3),sample(numbers,2)) v sapply(v,function(.l) values[match(.l, numbers)] ) HTH, baptiste On 14 Apr 2009, at 13:01, Manoel Silva wrote: Dear All, Here's my problem. I have two lists: v [[1]] [1] five [[2]] [1] four [[3]] [1] three [[4]] [1] two [[5]] [1] one [[6]] [1] six [[7]] [1] five four three two one six [[8]] [1] four three two one six [[9]] [1] three two one six [[10]] [1] two one six and the other is something like: values numbers five 50 four 40 three 30 two10 one10 six10 I'm trying to get a list similar to v, but in which the entries three, two, and so on are replaced by the values in the second list. Any help will be greatly appreciated. best regards, Manoel [[alternative HTML version deleted]] ATT1.txt _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cbind
a=c(NA,NA,2,3,NA,NA,NA) which.min(is.na(a)) [1] 3 b=1:length(a) b-3 [1] -2 -1 0 1 2 3 4 cbind(b=b-3,a=a) b a [1,] -2 NA [2,] -1 NA [3,] 0 2 [4,] 1 3 [5,] 2 NA [6,] 3 NA [7,] 4 NA On Tue, Apr 14, 2009 at 7:20 AM, emj83 stp08...@shef.ac.uk wrote: I have a list of numbers with NAs as below: A[,1] [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [19] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [37] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [55] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [73] NA NA NA 62 78 98 73 57 63 56 88 77 151 165 129 78 83 63 [91] 72 68 61 89 95 74 53 77 90 106 114 113 84 59 60 77 46 91 [109] 108 111 76 75 70 61 65 61 52 94 71 67 52 86 79 97 80 101 [127] 87 53 85 79 86 104 153 128 155 148 NA NA NA NA NA NA NA NA [145] NA NA NA NA NA NA NA I would like to bind a column to this list which begins at 0 when the first number has occured, but provides negative numbers prior to this as below: [1,] -75 NA [2,] -74 NA [3,] -73 NA [4,] -72 NA [5,] -71 NA [6,] -70 NA [7,] -69 NA [8,] -68 NA [9,] -67 NA [10,] -66 NA [11,] -65 NA [12,] -64 NA [13,] -63 NA [14,] -62 NA [15,] -61 NA [16,] -60 NA [17,] -59 NA [18,] -58 NA [19,] -57 NA [20,] -56 NA [21,] -55 NA [22,] -54 NA [23,] -53 NA [24,] -52 NA [25,] -51 NA [26,] -50 NA [27,] -49 NA [28,] -48 NA [29,] -47 NA [30,] -46 NA [31,] -45 NA [32,] -44 NA [33,] -43 NA [34,] -42 NA [35,] -41 NA [36,] -40 NA [37,] -39 NA [38,] -38 NA [39,] -37 NA [40,] -36 NA [41,] -35 NA [42,] -34 NA [43,] -33 NA [44,] -32 NA [45,] -31 NA [46,] -30 NA [47,] -29 NA [48,] -28 NA [49,] -27 NA [50,] -26 NA [51,] -25 NA [52,] -24 NA [53,] -23 NA [54,] -22 NA [55,] -21 NA [56,] -20 NA [57,] -19 NA [58,] -18 NA [59,] -17 NA [60,] -16 NA [61,] -15 NA [62,] -14 NA [63,] -13 NA [64,] -12 NA [65,] -11 NA [66,] -10 NA [67,] -9 NA [68,] -8 NA [69,] -7 NA [70,] -6 NA [71,] -5 NA [72,] -4 NA [73,] -3 NA [74,] -2 NA [75,] -1 NA [76,] 0 62 [77,] 1 78 [78,] 2 98 [79,] 3 73 [80,] 4 57 [81,] 5 63 [82,] 6 56 [83,] 7 88 [84,] 8 77 [85,] 9 151 [86,] 10 165 [87,] 11 129 [88,] 12 78 [89,] 13 83 [90,] 14 63 [91,] 15 72 [92,] 16 68 [93,] 17 61 [94,] 18 89 [95,] 19 95 [96,] 20 74 [97,] 21 53 [98,] 22 77 [99,] 23 90 [100,] 24 106 [101,] 25 114 [102,] 26 113 [103,] 27 84 [104,] 28 59 [105,] 29 60 [106,] 30 77 [107,] 31 46 [108,] 32 91 [109,] 33 108 [110,] 34 111 [111,] 35 76 [112,] 36 75 [113,] 37 70 [114,] 38 61 [115,] 39 65 [116,] 40 61 [117,] 41 52 [118,] 42 94 [119,] 43 71 [120,] 44 67 [121,] 45 52 [122,] 46 86 [123,] 47 79 [124,] 48 97 [125,] 49 80 [126,] 50 101 [127,] 51 87 [128,] 52 53 [129,] 53 85 [130,] 54 79 [131,] 55 86 [132,] 56 104 [133,] 57 153 [134,] 58 128 [135,] 59 155 [136,] 60 148 [137,] 61 NA [138,] 62 NA [139,] 63 NA [140,] 64 NA [141,] 65 NA [142,] 66 NA [143,] 67 NA [144,] 68 NA [145,] 69 NA [146,] 70 NA [147,] 71 NA [148,] 72 NA [149,] 73 NA [150,] 74 NA [151,] 75 NA could anyone help me to with a function that would be able to calculate the sequence I require to bind to the initial sequence? thanks emma -- View this message in context: http://www.nabble.com/cbind-tp23036759p23036759.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. -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cbind
oops, of course I meant: a=c(NA,NA,2,3,NA,NA,NA) b=1:length(a) cbind(b=b-which.min(is.na(a)),a=a) On Tue, Apr 14, 2009 at 9:43 AM, Mike Lawrence mike.lawre...@dal.ca wrote: a=c(NA,NA,2,3,NA,NA,NA) which.min(is.na(a)) [1] 3 b=1:length(a) b-3 [1] -2 -1 0 1 2 3 4 cbind(b=b-3,a=a) b a [1,] -2 NA [2,] -1 NA [3,] 0 2 [4,] 1 3 [5,] 2 NA [6,] 3 NA [7,] 4 NA On Tue, Apr 14, 2009 at 7:20 AM, emj83 stp08...@shef.ac.uk wrote: I have a list of numbers with NAs as below: A[,1] [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [19] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [37] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [55] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [73] NA NA NA 62 78 98 73 57 63 56 88 77 151 165 129 78 83 63 [91] 72 68 61 89 95 74 53 77 90 106 114 113 84 59 60 77 46 91 [109] 108 111 76 75 70 61 65 61 52 94 71 67 52 86 79 97 80 101 [127] 87 53 85 79 86 104 153 128 155 148 NA NA NA NA NA NA NA NA [145] NA NA NA NA NA NA NA I would like to bind a column to this list which begins at 0 when the first number has occured, but provides negative numbers prior to this as below: [1,] -75 NA [2,] -74 NA [3,] -73 NA [4,] -72 NA [5,] -71 NA [6,] -70 NA [7,] -69 NA [8,] -68 NA [9,] -67 NA [10,] -66 NA [11,] -65 NA [12,] -64 NA [13,] -63 NA [14,] -62 NA [15,] -61 NA [16,] -60 NA [17,] -59 NA [18,] -58 NA [19,] -57 NA [20,] -56 NA [21,] -55 NA [22,] -54 NA [23,] -53 NA [24,] -52 NA [25,] -51 NA [26,] -50 NA [27,] -49 NA [28,] -48 NA [29,] -47 NA [30,] -46 NA [31,] -45 NA [32,] -44 NA [33,] -43 NA [34,] -42 NA [35,] -41 NA [36,] -40 NA [37,] -39 NA [38,] -38 NA [39,] -37 NA [40,] -36 NA [41,] -35 NA [42,] -34 NA [43,] -33 NA [44,] -32 NA [45,] -31 NA [46,] -30 NA [47,] -29 NA [48,] -28 NA [49,] -27 NA [50,] -26 NA [51,] -25 NA [52,] -24 NA [53,] -23 NA [54,] -22 NA [55,] -21 NA [56,] -20 NA [57,] -19 NA [58,] -18 NA [59,] -17 NA [60,] -16 NA [61,] -15 NA [62,] -14 NA [63,] -13 NA [64,] -12 NA [65,] -11 NA [66,] -10 NA [67,] -9 NA [68,] -8 NA [69,] -7 NA [70,] -6 NA [71,] -5 NA [72,] -4 NA [73,] -3 NA [74,] -2 NA [75,] -1 NA [76,] 0 62 [77,] 1 78 [78,] 2 98 [79,] 3 73 [80,] 4 57 [81,] 5 63 [82,] 6 56 [83,] 7 88 [84,] 8 77 [85,] 9 151 [86,] 10 165 [87,] 11 129 [88,] 12 78 [89,] 13 83 [90,] 14 63 [91,] 15 72 [92,] 16 68 [93,] 17 61 [94,] 18 89 [95,] 19 95 [96,] 20 74 [97,] 21 53 [98,] 22 77 [99,] 23 90 [100,] 24 106 [101,] 25 114 [102,] 26 113 [103,] 27 84 [104,] 28 59 [105,] 29 60 [106,] 30 77 [107,] 31 46 [108,] 32 91 [109,] 33 108 [110,] 34 111 [111,] 35 76 [112,] 36 75 [113,] 37 70 [114,] 38 61 [115,] 39 65 [116,] 40 61 [117,] 41 52 [118,] 42 94 [119,] 43 71 [120,] 44 67 [121,] 45 52 [122,] 46 86 [123,] 47 79 [124,] 48 97 [125,] 49 80 [126,] 50 101 [127,] 51 87 [128,] 52 53 [129,] 53 85 [130,] 54 79 [131,] 55 86 [132,] 56 104 [133,] 57 153 [134,] 58 128 [135,] 59 155 [136,] 60 148 [137,] 61 NA [138,] 62 NA [139,] 63 NA [140,] 64 NA [141,] 65 NA [142,] 66 NA [143,] 67 NA [144,] 68 NA [145,] 69 NA [146,] 70 NA [147,] 71 NA [148,] 72 NA [149,] 73 NA [150,] 74 NA [151,] 75 NA could anyone help me to with a function that would be able to calculate the sequence I require to bind to the initial sequence? thanks emma -- View this message in context: http://www.nabble.com/cbind-tp23036759p23036759.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. -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~ -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~ __ R-help@r-project.org mailing list https://stat.ethz.ch/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] cbind
Unfortunately Dimitris' solution fails in the face of NA padding on both sides of the numeric data, as in Emma's original example. x - c(rep(NA, 20), sample(100, 25), rep(NA,20)) On Tue, Apr 14, 2009 at 9:40 AM, Dimitris Rizopoulos d.rizopou...@erasmusmc.nl wrote: try this: x - c(rep(NA, 20), sample(100, 25)) n.na - sum(is.na(x)) cbind(seq(-n.na, length(x) - n.na - 1), x) I hope it helps. Best, Dimitris emj83 wrote: I have a list of numbers with NAs as below: A[,1] [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [19] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [37] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [55] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [73] NA NA NA 62 78 98 73 57 63 56 88 77 151 165 129 78 83 63 [91] 72 68 61 89 95 74 53 77 90 106 114 113 84 59 60 77 46 91 [109] 108 111 76 75 70 61 65 61 52 94 71 67 52 86 79 97 80 101 [127] 87 53 85 79 86 104 153 128 155 148 NA NA NA NA NA NA NA NA [145] NA NA NA NA NA NA NA I would like to bind a column to this list which begins at 0 when the first number has occured, but provides negative numbers prior to this as below: [1,] -75 NA [2,] -74 NA [3,] -73 NA [4,] -72 NA [5,] -71 NA [6,] -70 NA [7,] -69 NA [8,] -68 NA [9,] -67 NA [10,] -66 NA [11,] -65 NA [12,] -64 NA [13,] -63 NA [14,] -62 NA [15,] -61 NA [16,] -60 NA [17,] -59 NA [18,] -58 NA [19,] -57 NA [20,] -56 NA [21,] -55 NA [22,] -54 NA [23,] -53 NA [24,] -52 NA [25,] -51 NA [26,] -50 NA [27,] -49 NA [28,] -48 NA [29,] -47 NA [30,] -46 NA [31,] -45 NA [32,] -44 NA [33,] -43 NA [34,] -42 NA [35,] -41 NA [36,] -40 NA [37,] -39 NA [38,] -38 NA [39,] -37 NA [40,] -36 NA [41,] -35 NA [42,] -34 NA [43,] -33 NA [44,] -32 NA [45,] -31 NA [46,] -30 NA [47,] -29 NA [48,] -28 NA [49,] -27 NA [50,] -26 NA [51,] -25 NA [52,] -24 NA [53,] -23 NA [54,] -22 NA [55,] -21 NA [56,] -20 NA [57,] -19 NA [58,] -18 NA [59,] -17 NA [60,] -16 NA [61,] -15 NA [62,] -14 NA [63,] -13 NA [64,] -12 NA [65,] -11 NA [66,] -10 NA [67,] -9 NA [68,] -8 NA [69,] -7 NA [70,] -6 NA [71,] -5 NA [72,] -4 NA [73,] -3 NA [74,] -2 NA [75,] -1 NA [76,] 0 62 [77,] 1 78 [78,] 2 98 [79,] 3 73 [80,] 4 57 [81,] 5 63 [82,] 6 56 [83,] 7 88 [84,] 8 77 [85,] 9 151 [86,] 10 165 [87,] 11 129 [88,] 12 78 [89,] 13 83 [90,] 14 63 [91,] 15 72 [92,] 16 68 [93,] 17 61 [94,] 18 89 [95,] 19 95 [96,] 20 74 [97,] 21 53 [98,] 22 77 [99,] 23 90 [100,] 24 106 [101,] 25 114 [102,] 26 113 [103,] 27 84 [104,] 28 59 [105,] 29 60 [106,] 30 77 [107,] 31 46 [108,] 32 91 [109,] 33 108 [110,] 34 111 [111,] 35 76 [112,] 36 75 [113,] 37 70 [114,] 38 61 [115,] 39 65 [116,] 40 61 [117,] 41 52 [118,] 42 94 [119,] 43 71 [120,] 44 67 [121,] 45 52 [122,] 46 86 [123,] 47 79 [124,] 48 97 [125,] 49 80 [126,] 50 101 [127,] 51 87 [128,] 52 53 [129,] 53 85 [130,] 54 79 [131,] 55 86 [132,] 56 104 [133,] 57 153 [134,] 58 128 [135,] 59 155 [136,] 60 148 [137,] 61 NA [138,] 62 NA [139,] 63 NA [140,] 64 NA [141,] 65 NA [142,] 66 NA [143,] 67 NA [144,] 68 NA [145,] 69 NA [146,] 70 NA [147,] 71 NA [148,] 72 NA [149,] 73 NA [150,] 74 NA [151,] 75 NA could anyone help me to with a function that would be able to calculate the sequence I require to bind to the initial sequence? thanks emma -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Mike Lawrence Graduate Student Department of Psychology Dalhousie University Looking to arrange a meeting? Check my public calendar: http://tr.im/mikes_public_calendar ~ Certainty is folly... I think. ~ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] cbind
Yes, indeed! Best, Dimitris Mike Lawrence wrote: Unfortunately Dimitris' solution fails in the face of NA padding on both sides of the numeric data, as in Emma's original example. x - c(rep(NA, 20), sample(100, 25), rep(NA,20)) On Tue, Apr 14, 2009 at 9:40 AM, Dimitris Rizopoulos d.rizopou...@erasmusmc.nl wrote: try this: x - c(rep(NA, 20), sample(100, 25)) n.na - sum(is.na(x)) cbind(seq(-n.na, length(x) - n.na - 1), x) I hope it helps. Best, Dimitris emj83 wrote: I have a list of numbers with NAs as below: A[,1] [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [19] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [37] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [55] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [73] NA NA NA 62 78 98 73 57 63 56 88 77 151 165 129 78 83 63 [91] 72 68 61 89 95 74 53 77 90 106 114 113 84 59 60 77 46 91 [109] 108 111 76 75 70 61 65 61 52 94 71 67 52 86 79 97 80 101 [127] 87 53 85 79 86 104 153 128 155 148 NA NA NA NA NA NA NA NA [145] NA NA NA NA NA NA NA I would like to bind a column to this list which begins at 0 when the first number has occured, but provides negative numbers prior to this as below: [1,] -75 NA [2,] -74 NA [3,] -73 NA [4,] -72 NA [5,] -71 NA [6,] -70 NA [7,] -69 NA [8,] -68 NA [9,] -67 NA [10,] -66 NA [11,] -65 NA [12,] -64 NA [13,] -63 NA [14,] -62 NA [15,] -61 NA [16,] -60 NA [17,] -59 NA [18,] -58 NA [19,] -57 NA [20,] -56 NA [21,] -55 NA [22,] -54 NA [23,] -53 NA [24,] -52 NA [25,] -51 NA [26,] -50 NA [27,] -49 NA [28,] -48 NA [29,] -47 NA [30,] -46 NA [31,] -45 NA [32,] -44 NA [33,] -43 NA [34,] -42 NA [35,] -41 NA [36,] -40 NA [37,] -39 NA [38,] -38 NA [39,] -37 NA [40,] -36 NA [41,] -35 NA [42,] -34 NA [43,] -33 NA [44,] -32 NA [45,] -31 NA [46,] -30 NA [47,] -29 NA [48,] -28 NA [49,] -27 NA [50,] -26 NA [51,] -25 NA [52,] -24 NA [53,] -23 NA [54,] -22 NA [55,] -21 NA [56,] -20 NA [57,] -19 NA [58,] -18 NA [59,] -17 NA [60,] -16 NA [61,] -15 NA [62,] -14 NA [63,] -13 NA [64,] -12 NA [65,] -11 NA [66,] -10 NA [67,] -9 NA [68,] -8 NA [69,] -7 NA [70,] -6 NA [71,] -5 NA [72,] -4 NA [73,] -3 NA [74,] -2 NA [75,] -1 NA [76,] 0 62 [77,] 1 78 [78,] 2 98 [79,] 3 73 [80,] 4 57 [81,] 5 63 [82,] 6 56 [83,] 7 88 [84,] 8 77 [85,] 9 151 [86,] 10 165 [87,] 11 129 [88,] 12 78 [89,] 13 83 [90,] 14 63 [91,] 15 72 [92,] 16 68 [93,] 17 61 [94,] 18 89 [95,] 19 95 [96,] 20 74 [97,] 21 53 [98,] 22 77 [99,] 23 90 [100,] 24 106 [101,] 25 114 [102,] 26 113 [103,] 27 84 [104,] 28 59 [105,] 29 60 [106,] 30 77 [107,] 31 46 [108,] 32 91 [109,] 33 108 [110,] 34 111 [111,] 35 76 [112,] 36 75 [113,] 37 70 [114,] 38 61 [115,] 39 65 [116,] 40 61 [117,] 41 52 [118,] 42 94 [119,] 43 71 [120,] 44 67 [121,] 45 52 [122,] 46 86 [123,] 47 79 [124,] 48 97 [125,] 49 80 [126,] 50 101 [127,] 51 87 [128,] 52 53 [129,] 53 85 [130,] 54 79 [131,] 55 86 [132,] 56 104 [133,] 57 153 [134,] 58 128 [135,] 59 155 [136,] 60 148 [137,] 61 NA [138,] 62 NA [139,] 63 NA [140,] 64 NA [141,] 65 NA [142,] 66 NA [143,] 67 NA [144,] 68 NA [145,] 69 NA [146,] 70 NA [147,] 71 NA [148,] 72 NA [149,] 73 NA [150,] 74 NA [151,] 75 NA could anyone help me to with a function that would be able to calculate the sequence I require to bind to the initial sequence? thanks emma -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Dimitris Rizopoulos Assistant Professor Department of Biostatistics Erasmus University Medical Center Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands Tel: +31/(0)10/7043478 Fax: +31/(0)10/7043014 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Histogram and moving average
Vallat Morgan morgan.vallat at epfl.ch writes: I have a 'basic' issue and hope someone has a bit of code to solve it. I have two populations plotted as histograms on the same figure. Basically I want to add the moving average (based on hist) for both populations on my graph. I'm also interested in the x coordinate of the curves intersection. Moving averages are fine if you do not have future data (such as stock markets or temperatures), but suboptimal for densities. R has powerful methods for these: If you have MASS (the book, check ch. 5.6). Or the examples in library/MASS/scripts/ch05.R Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] fractal vs. Fractal packages
google gives nothing, and the archive section on CRAN has no Fractal. On Mon, Apr 13, 2009 at 10:31 PM, Erin Hodgess erinm.hodg...@gmail.comwrote: Dear R People: At one time, there were packages called fractal and Fractal, respectively, which had different functions. I can't seem to find Fractal any more. Does it still exist somewhere, please? Thanks in advance for any help! Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on zero-inflated Poisson count data with repeatedmeasures design - glmm.ADMB
Dear Diederik, If you revisited the same points then it makes sense to use the data at the point level. But then I would mke that explicit by using a nested random effect. In the nlme/lme4 syntax: 1|Site/Point. Make shure that each point has a unique ID. Naming a variable count is not a very good idea unless it is something you counted. I would suggest to rename it to visit. That would cause less confugion. It looks to me like you have in your model a crossed random effect: Visit and Site. Was that intended? Furthermore you assume that the first visit in year 1 has the same effect as the first visit in year 2 and 3. And the same goes for the other visits. Is that a valid assumption for your data? Including year as a random effect is not a good idea since is has only three levels. Douglas Bates recommends at least six levels for a random effect. Otherwise you don't get a good estimate of its variance. You could number the visits from 1 to 15 instead of restarting from 1 each year. Then you make less assumitions about your model. As this random effect would incorporate the effects of year, visit and their interaction. HTH, Thierry PS R-Sig-mixed models is a mailing list dedicated to mixed models. That is more appropriate for this kind of questions. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Strubbe Diederik Verzonden: maandag 13 april 2009 22:35 Aan: r-help@r-project.org Onderwerp: [R] Question on zero-inflated Poisson count data with repeatedmeasures design - glmm.ADMB Dear R community, I have some questions regarding the analysis of a zero-inflated count dataset and repeated measures design. The dataset is arranged as follows : Unit of analysis: point - these are points were bird were counted during a certain amount of time. In total we have about 175 points. Each point is located within a certain habitat fragment (here: site= A-B-C-D-..., in reality we have 25 sites,i.e. forest fragments). All points were counted five times during three years ( thus in total, each point was counted 15 times). We want to relate the bird abundance to a number of habitat variables (here: X1-X2-X3) collected at the site level. Abundance: this is the number of birds counted at a point. In most cases ( 90%), no birds were detected and the abundance dataset is thus zero-inflated. I have been looking for a code to analyze this zero-inflated poisson distributed dataset with a repeated measures design, and I have arrived at the glmmADMB package. library(glmmADMB) data - read.table(D:/Boris/Borisdataset.csv,sep=,,header=TRUE) count - data$count site - data$site abundance - data$abundance test-glmm.admb(abundance~data$X1+data$X2+data$year,random=~count,group= site,data=data,family=poisson,zeroInflation=TRUE) [ for clarity: in the above syntax: count ranges from 1-5 as each site has been counted 5 times in a year, site refers to one of the 25 forest fragments in which the point counts were conducted, Xi are the habitat variables]. My questions are: - does it make sense to analyze these data at the point level, as all habitat variables are collected at the site level, meaning that for all points belonging to a certain forest fragment, the habitat variables have the same value. If it does make sense, is the proposed syntax ok? Is there any option to include year as a random effect, as I am not especially interested in differences between years. -it looks appealing to average the point count values for each forest fragment, and to analyze the data with forest fragment as unit of analysis. However, also when averaging across fragments, the dataset is still zero-inflated. It is however impossible to a zero-inflated Poisson distribution for this analysis, as the averaged forest fragment values are not always discrete values. Many thanks in advance, Diederik {example of dataset reproduced below} X1 X2 X3 point sitecount yearabundance 1.23598 0.2777650.8617941 A 1 2001 0 1.23598 0.2777650.8617941 A 2 2001 0 1.23598 0.2777650.8617941 A 3
Re: [R] Factor to continuous
Hi, You'll need to be more specific about the nature of your problem. Could you describe what exactly you're trying to do and why you need to transform factors into continuous variables? Could you also provide a small subsample of the data you're working with? Without such information, I doubt that even the most knowledgeable specialists of R might be able to provide meaningful assistance. Best of luck, Luc joewest wrote: Hi I am really struggling with changing my factors into continuous variables. There is plenty of information on changing continuous to a factor which is the opposite of what i need to do. I would be soo grateful for any help Thanks Joe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] subset dataframe by rows using character vector?
Dear List, I'm stuck on what seems like a simple indexing problem, I'd be very grateful to anyone willing to help me out. I queried a dataframe which returns a character vector called plot. I have another dataframe from which I want to subset or select only those rows that match plot. I've tried subset, and also the which command. plot - c(plot1, plot2, plot3) # character vector used to select rows from data # create fake data from to try out subset v1 - c(2,5,6,4,3) PLOTID - c(plot1, plot2, plot3, plot4, plot5) full.data - cbind(v1, PLOTID) full.data - as.data.frame(full.data) # first attempt test - which(full.data$PLOTID == plot) # second attempt test - full.data[full.data$PLOTID == plot] I'm sure there is a simple solution here, but I'm unable to figure it out. Thanks for any suggestions, Zack __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Factor to continuous
I suspect the OP is looking for FAQ 7.10 http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-do-I-convert-factors-to-numeric_003f HTH Keith J Luc Villandre villa...@dms.umontreal.ca wrote in message news:49e495fe.1090...@dms.umontreal.ca... Hi, You'll need to be more specific about the nature of your problem. Could you describe what exactly you're trying to do and why you need to transform factors into continuous variables? Could you also provide a small subsample of the data you're working with? Without such information, I doubt that even the most knowledgeable specialists of R might be able to provide meaningful assistance. Best of luck, Luc joewest wrote: Hi I am really struggling with changing my factors into continuous variables. There is plenty of information on changing continuous to a factor which is the opposite of what i need to do. I would be soo grateful for any help Thanks Joe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] fractal vs. Fractal packages
Dear Erin: 'RSiteSearch.function(Fractal)' [using the RSiteSearch package available via 'install.packages(packagename,repos=http://R-Forge.R-project.org;)'] returned 61 hits, 41 for fractal, 6 for RandomFields, 4 for ProbForecastGOP, 3 each for fdim and FieldSim, 2 for adehabitat and 1 each for fArma, mboost, rgr, dti, ifultools, RcppTemplate, RTisean, and SoPhy. Hope this helps. Spencer Kjetil Halvorsen wrote: google gives nothing, and the archive section on CRAN has no Fractal. On Mon, Apr 13, 2009 at 10:31 PM, Erin Hodgess erinm.hodg...@gmail.comwrote: Dear R People: At one time, there were packages called fractal and Fractal, respectively, which had different functions. I can't seem to find Fractal any more. Does it still exist somewhere, please? Thanks in advance for any help! Sincerely, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Lattice xyplot with two y axis
Hi All, I have some data which needs to be plotted with lattice. library(lattice) cars - c(0.1, 0.3, 0.6, 0.4, 0.9) trucks - c(0.2, 0.5, 0.4, 0.5, 0.1) drivers-c(121,145,167,200, 210) year-c(2005,2006,2007,2008,2009) type-c(local,local,foreign,foreign,foreign) xyplot(cars+trucks~year|type, data=df3, type=o) Basically, I need to show drivers as well on a secondary y-axis. Is this possible with lattice and xyplot? Any ideas and help would be much appreciated. Thanks. -- View this message in context: http://www.nabble.com/Lattice-xyplot-with-two-y-axis-tp23040657p23040657.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] disappearing dialog boxes when using tcltk
Dear all, I'm trying to use tcltk to build a small user-interface and couter the problem: It seems that sometimes the dialog box will be minimized automatically though I want it to be on top of the screen all the time. For example, when runing the following code, if you type in a1, a2, a3, etc when being asked for an integer, the program is supposed to keeping asking you until you give an integer. The program runs fine, but the dialog box is not always on top, and it is annoying having to maximized it every time (the wierd thing is that sometimes it is Ok, sometimes it is not. So I don't know the problem.) Millions of thanks! Hua ##=== ## Add Dialog Box (with only OK button) ##=== modalDialogOK - function(title,question,entryInit,entryWidth=10) { returnValOnCancel=ID_CANCEL dlg - tktoplevel() tkwm.deiconify(dlg) tkgrab.set(dlg) tkfocus(dlg) tkwm.title(dlg,title) textEntryVarTcl - tclVar(paste(entryInit)) textEntryWidget - tkentry(dlg,width=paste(entryWidth),textvariable=textEntryVarTcl) tkgrid(tklabel(dlg,text= )) tkgrid(tklabel(dlg,text=question),textEntryWidget) tkgrid(tklabel(dlg,text= )) ReturnVal - returnValOnCancel onOK - function() { ReturnVal - tclvalue(textEntryVarTcl) tkgrab.release(dlg) tkdestroy(dlg) # tkfocus(dlg) tkfocus(ttMain) } OK.but -tkbutton(dlg,text= OK ,command=onOK) tkgrid(OK.but) tkgrid(tklabel(dlg,text=)) tkfocus(dlg) tkbind(dlg, Destroy, function() {tkgrab.release(dlg);tkfocus(ttMain)}) tkbind(textEntryWidget, Return, onOK) tkwait.window(dlg) return(ReturnVal) } ##=== ## main function ##=== require(tcltk) ttMain - tktoplevel() tkwm.title(ttMain,Number) tkdestroy(ttMain) #initial values are set numAll = speAll = NULL yrunit = ttMain - tktoplevel() tkfocus(ttMain) numAll - as.numeric(modalDialogOK(Number,Put in an integer greater than 1:,entryInit=numAll)) tkdestroy(ttMain) while (is.na(numAll) || numAll==0 || numAll==1) { ttMain - tktoplevel() tkfocus(ttMain) ReturnVal - tkmessageBox(title=Number,message=Error! The number of should be NUMERICAL and be greater than 1!,icon=info,type=ok) tkdestroy(ttMain) ttMain - tktoplevel() tkfocus(ttMain) numAll - as.numeric(modalDialogOK(Number,Put in an integer greater than 1:,entryInit=numAll)) tkdestroy(ttMain) } ##=== ## end of 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] cbind
Hi Emma, Here's what I suggest: na.vec = is.na(A[,1]) ; first.num.pos = min(which(na.vec==FALSE)) ; first.part = (-first.num.pos+1):(-1) ; second.part = 0:(length(A[,1])-length(first.part)-1) ; Result.mat = cbind(c(first.part,second.part),A[,1]) ; I hope this is what you want. HTH, Luc emj83 wrote: I have a list of numbers with NAs as below: A[,1] [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [19] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [37] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [55] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA [73] NA NA NA 62 78 98 73 57 63 56 88 77 151 165 129 78 83 63 [91] 72 68 61 89 95 74 53 77 90 106 114 113 84 59 60 77 46 91 [109] 108 111 76 75 70 61 65 61 52 94 71 67 52 86 79 97 80 101 [127] 87 53 85 79 86 104 153 128 155 148 NA NA NA NA NA NA NA NA [145] NA NA NA NA NA NA NA I would like to bind a column to this list which begins at 0 when the first number has occured, but provides negative numbers prior to this as below: [1,] -75 NA [2,] -74 NA [3,] -73 NA [4,] -72 NA [5,] -71 NA [6,] -70 NA [7,] -69 NA [8,] -68 NA [9,] -67 NA [10,] -66 NA [11,] -65 NA [12,] -64 NA [13,] -63 NA [14,] -62 NA [15,] -61 NA [16,] -60 NA [17,] -59 NA [18,] -58 NA [19,] -57 NA [20,] -56 NA [21,] -55 NA [22,] -54 NA [23,] -53 NA [24,] -52 NA [25,] -51 NA [26,] -50 NA [27,] -49 NA [28,] -48 NA [29,] -47 NA [30,] -46 NA [31,] -45 NA [32,] -44 NA [33,] -43 NA [34,] -42 NA [35,] -41 NA [36,] -40 NA [37,] -39 NA [38,] -38 NA [39,] -37 NA [40,] -36 NA [41,] -35 NA [42,] -34 NA [43,] -33 NA [44,] -32 NA [45,] -31 NA [46,] -30 NA [47,] -29 NA [48,] -28 NA [49,] -27 NA [50,] -26 NA [51,] -25 NA [52,] -24 NA [53,] -23 NA [54,] -22 NA [55,] -21 NA [56,] -20 NA [57,] -19 NA [58,] -18 NA [59,] -17 NA [60,] -16 NA [61,] -15 NA [62,] -14 NA [63,] -13 NA [64,] -12 NA [65,] -11 NA [66,] -10 NA [67,] -9 NA [68,] -8 NA [69,] -7 NA [70,] -6 NA [71,] -5 NA [72,] -4 NA [73,] -3 NA [74,] -2 NA [75,] -1 NA [76,] 0 62 [77,] 1 78 [78,] 2 98 [79,] 3 73 [80,] 4 57 [81,] 5 63 [82,] 6 56 [83,] 7 88 [84,] 8 77 [85,] 9 151 [86,] 10 165 [87,] 11 129 [88,] 12 78 [89,] 13 83 [90,] 14 63 [91,] 15 72 [92,] 16 68 [93,] 17 61 [94,] 18 89 [95,] 19 95 [96,] 20 74 [97,] 21 53 [98,] 22 77 [99,] 23 90 [100,] 24 106 [101,] 25 114 [102,] 26 113 [103,] 27 84 [104,] 28 59 [105,] 29 60 [106,] 30 77 [107,] 31 46 [108,] 32 91 [109,] 33 108 [110,] 34 111 [111,] 35 76 [112,] 36 75 [113,] 37 70 [114,] 38 61 [115,] 39 65 [116,] 40 61 [117,] 41 52 [118,] 42 94 [119,] 43 71 [120,] 44 67 [121,] 45 52 [122,] 46 86 [123,] 47 79 [124,] 48 97 [125,] 49 80 [126,] 50 101 [127,] 51 87 [128,] 52 53 [129,] 53 85 [130,] 54 79 [131,] 55 86 [132,] 56 104 [133,] 57 153 [134,] 58 128 [135,] 59 155 [136,] 60 148 [137,] 61 NA [138,] 62 NA [139,] 63 NA [140,] 64 NA [141,] 65 NA [142,] 66 NA [143,] 67 NA [144,] 68 NA [145,] 69 NA [146,] 70 NA [147,] 71 NA [148,] 72 NA [149,] 73 NA [150,] 74 NA [151,] 75 NA could anyone help me to with a function that would be able to calculate the sequence I require to bind to the initial sequence? thanks emma __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subset dataframe by rows using character vector?
Is this what you want? plotNames - c(plot1, plot2, plot3) # plot is probably best left as the name of the base function full.data[full.data$PLOTID %in% plotNames, ] # note the comma HTH, baptiste On 14 Apr 2009, at 15:20, zack holden wrote: Dear List, I'm stuck on what seems like a simple indexing problem, I'd be very grateful to anyone willing to help me out. I queried a dataframe which returns a character vector called plot. I have another dataframe from which I want to subset or select only those rows that match plot. I've tried subset, and also the which command. plot - c(plot1, plot2, plot3) # character vector used to select rows from data # create fake data from to try out subset v1 - c(2,5,6,4,3) PLOTID - c(plot1, plot2, plot3, plot4, plot5) full.data - cbind(v1, PLOTID) full.data - as.data.frame(full.data) # first attempt test - which(full.data$PLOTID == plot) # second attempt test - full.data[full.data$PLOTID == plot] I'm sure there is a simple solution here, but I'm unable to figure it out. Thanks for any suggestions, Zack __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with ANOVA p-values
Hi I have done ANOVA on a dataset (See Below) but am having problems retreiving the p-value. I am assuming that Pr(F) is the p-value but cannot get this value or in fact any other value (e.g. DF) from the summary.Any suggestions?? I have tried sum-summary(zzz.aov) sum$Pr(F) Error: unexpected '' in sum$Pr( sum$Pr(F) NULL sum$Df NULL zzz.aov - aov(Intensity ~ Group + Error(Sample), data = zzzanova) summary(zzz.aov) Error: Sample Df Sum SqMean Sq Group 1 6.0313e+10 6.0313e+10 Error: Within Df Sum SqMean Sq F value Pr(F) Group 3 2.6012e+10 8.6707e+09 0.2934 0.8299 Residuals 34 1.0049e+12 2.9556e+10 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] subset dataframe by rows using character vector?
glad it was helpful. %in% is a logical operator, so you can use ! to negate the result (with parentheses), ! ( 4 %in% 1:3) Alternatively, define a new operator, `%ni%` - Negate(`%in%`) 1 %ni% c(2,1) Next time you ask a follow-up question please send it to the r-help list so others can help you too. HTH, baptiste On 14 Apr 2009, at 16:03, zack holden wrote: Yes! that's it. Any chance you can tell me how to select everything but those plotNames? Basically a reverse subset? I don't know these character matching functions very well. I very much appreciate your help, thanks again. Zack CC: r-help@r-project.org From: ba...@exeter.ac.uk To: zack_hol...@hotmail.com Subject: Re: [R] subset dataframe by rows using character vector? Date: Tue, 14 Apr 2009 15:56:45 +0100 Is this what you want? plotNames - c(plot1, plot2, plot3) # plot is probably best left as the name of the base function full.data[full.data$PLOTID %in% plotNames, ] # note the comma HTH, baptiste On 14 Apr 2009, at 15:20, zack holden wrote: Dear List, I'm stuck on what seems like a simple indexing problem, I'd be very grateful to anyone willing to help me out. I queried a dataframe which returns a character vector called plot. I have another dataframe from which I want to subset or select only those rows that match plot. I've tried subset, and also the which command. plot - c(plot1, plot2, plot3) # character vector used to select rows from data # create fake data from to try out subset v1 - c(2,5,6,4,3) PLOTID - c(plot1, plot2, plot3, plot4, plot5) full.data - cbind(v1, PLOTID) full.data - as.data.frame(full.data) # first attempt test - which(full.data$PLOTID == plot) # second attempt test - full.data[full.data$PLOTID == plot] I'm sure there is a simple solution here, but I'm unable to figure it out. Thanks for any suggestions, Zack __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Help with ANOVA p-values
Hi, you can try something like: summary( zzz.aov )[[1]][ Pr(F) ] Regards 2009/4/14 Amit Patel amitrh...@yahoo.co.uk Hi I have done ANOVA on a dataset (See Below) but am having problems retreiving the p-value. I am assuming that Pr(F) is the p-value but cannot get this value or in fact any other value (e.g. DF) from the summary.Any suggestions?? I have tried sum-summary(zzz.aov) sum$Pr(F) Error: unexpected '' in sum$Pr( sum$Pr(F) NULL sum$Df NULL zzz.aov - aov(Intensity ~ Group + Error(Sample), data = zzzanova) summary(zzz.aov) Error: Sample Df Sum SqMean Sq Group 1 6.0313e+10 6.0313e+10 Error: Within Df Sum SqMean Sq F value Pr(F) Group 3 2.6012e+10 8.6707e+09 0.2934 0.8299 Residuals 34 1.0049e+12 2.9556e+10 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Two functions plotted in wireframe
Hi together, I have some graphical problems. I would like to add a semi-transparent surface at z=1 to an existing lattice wireframe plotting a general function z=f(x,y). Any suggestions on how this can be done? Thanks, Alrik [[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] any other fast method for median calculation
On Tue, 14 Apr 2009, S Ellison wrote: Sorting with an appropriate algorithm is nlog(n), so it's very hard to get the 'exact' median any faster. There actually are linear-time algorithms for the median, but n has to be very large before they are worth using, and by then you have to start considering locality of reference and other issues. In any case, it looks like you are not constrained by the median algorithm, but by the number of calls. You might do a lot better with apply, though apply(df,2,median) On my system 200k columns were processed in negligible time by apply and I'm still waiting for mapply. I'd also note that this is the sort of problem where the profiler is useful: you can see on a smaller subset whether R is spending most of its time in median() or somewhere else. I wouldn't be surprised if a while() loop was even faster than apply() in this setting, but probably not enough to care about. -thomas Thomas Lumley Assoc. Professor, Biostatistics tlum...@u.washington.eduUniversity of Washington, Seattle __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Jacobian
First, why do you want the jacobian? Assuming you have a good reason for wanting jacobian, Is this want you want to do? require(numDeriv) func2 - function(z) { x - z[1] y - z[2] c(sin(x*y), cos(x^2*y)) } x - seq(0, 1, length=5) *2*pi y - seq(0, 1, length=5) *2*pi z - cbind(x, y) jac - vector(list) for (i in 1:nrow(z)) { jac[[i]] - jacobian(func=func2, x=z[i, ]) } jac Ravi. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: rvarad...@jhmi.edu Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Roslina Zakaria Sent: Monday, April 13, 2009 9:48 PM To: r-help@r-project.org; r-help-boun...@r-project.org Subject: [R] Jacobian Hi R-users, I would like to use jacobian function from numDeriv package. If I have more than one parameters how do I modify it? This is the example given in the package: func2 - function(x) c(sin(x), cos(x)) x - (0:1)*2*pi jacobian(func2, x) Can I do the following: z - c(x,y) func2 - function(z) c(sin(xy), cos(x^2*y)) x - (0:1)*2*pi y - (0:1)*2*pi jacobian(func2, z) output: jacobian(func2, z) Error in func(x, ...) : object xy not found Thank you so much for any help given. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Legend: different family for title and labels
Hello All, I am attempting to create a legend where the title has font family sans (or Helvetica in PS), and the labels (entries in the legend) have font family mono (or Courier). Would anyone be able to offer help on this? I have successfully changed the entire legend family to mono using par() after the plot and before the legend, and I can change the title face using expression(), but not its family. Is there a way to do this without separately placing the title inside the legend via text()? Regards, Marc __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Building GUI for custom R application
Duncan Murdoch and Brian Ripley (I believe) have provided some limited but serviceable native Windows GUI functionality within R for Windows. See ?winMenuAdd, ?choose.files , ?select.list, ?getGraphicsEvent,?winProgressBar for examples and further links. Everything that you mention can be rather simply done using this functionality (I've done it). As others have said, much more extensive and powerful GUI functionality is available through tcltk and associated packages like gWidgets,TkWidgets, and others (including much stuff on Bioconductor). But beware! -- writing GUI's that provide complex functionality is difficult. Computer scientists, web designers, etc. have whole curricula devoted to this. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics 650-467-7374 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gabor Grothendieck Sent: Tuesday, April 14, 2009 4:17 AM To: Barry Rowlingson Cc: r-help@r-project.org; Harsh Subject: Re: [R] Building GUI for custom R application On Tue, Apr 14, 2009 at 6:54 AM, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Tue, Apr 14, 2009 at 9:23 AM, Harsh singhal...@gmail.com wrote: HI R users, I would appreciate information/examples/suggestions on building GUIs for R applications. I am currently working on a project that would require the following functionalities : 1) Display a window to the user. Provide a function to scan local drive and choose dataset file. 2) Display the column names for the user to choose the dependent variable and the independent variables. 3) Fit regression and display statistics. Item 2 provides an example of creating a regression application with slider controls for a parameter in loess function used in the example application in that paper. For documentation on RGtk the author recommends reading the Gtk tutorial and documentation. I seem to have difficulty in making sense of the Gtk documentation since most of it is in C and documentation is available for use of Gtk with Perl and Python. I am not a C/Perl/Python programmer. You should say I am not _yet_ a C/Perl/Python programmer. Don't limit yourself :) Moreover, I am creating a Windows Application and is using RGtk2 the only way to create a GUI for an R application? Or should I use the the VB approach and create the GUI separately and call R scripts where required to do the back-end computation? If you are to admit the possibility of becoming a Python programmer (strongly recommended) I'd say you could do it with Python, Rpy, and the Qt library. The basic example you've outlined (choose file, select X and Y values, plot, display stats) would take about twenty minutes. In fact, I've done half the work already, in adding almost just such functionality to Quantum GIS. See here: http://www.maths.lancs.ac.uk/~rowlings/Software/Spqr/ where the second screenshot shows variable selection and diagnostic plots of an lm from data in the GIS. Distributing such an application might be tricky since it requires R, Rpy, PyQt4 to be installed or available, but it can be possible to build Python code into Windows .exe files with some effort. Since you are using Windows (based on the fact you are considering VB) note that rpy2 does not work with the recent versions of python (as of a few months ago when I checked). __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Search for a graph package - see link
Gábor Csárdi schrieb: Hmmm, how should 'plot' know automatically what size/width you want? Sorry, I don't really know what you want to achieve here. If you want to calculate the width from some properties of the graph, then simply do that and assign it as the 'width' argument. Hi Gábor, the radius of the circle is representing the numbers of actions of the node to all other nodes. I need an additionally information about the numbers of actions *between* the nodes differentiated by the direction from and to the nodes. Example Node 1 - 2 1 actions Node 2 - 125 actions Node 3 - 1 4 actions Node 1 - 3 10 actions Node 2 - 3 5 actions Node 3 - 2 2 actions I am looking for any graph which shows the direction and counts of the actions with f.e different thickness of the arrows, It must be viewable http://dict.leo.org/ende?lp=endep=thMx..search=viewable that the actions from Node 2 to Node 1 are much more than from Node 1 to 2 and also more then from node 3 to three, and so on. Maximum nodes: about 20 Regards Knut __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Search for a graph package - see link
On Tue, Apr 14, 2009 at 6:07 PM, Knut Krueger r...@krueger-family.de wrote: Gábor Csárdi schrieb: Hmmm, how should 'plot' know automatically what size/width you want? Sorry, I don't really know what you want to achieve here. If you want to calculate the width from some properties of the graph, then simply do that and assign it as the 'width' argument. Hi Gábor, the radius of the circle is representing the numbers of actions of the node to all other nodes. I need an additionally information about the numbers of actions *between* the nodes differentiated by the direction from and to the nodes. Example Node 1 - 2 1 actions Node 2 - 1 25 actions Node 3 - 1 4 actions Node 1 - 3 10 actions Node 2 - 3 5 actions Node 3 - 2 2 actions I am looking for any graph which shows the direction and counts of the actions with f.e different thickness of the arrows, It must be viewable http://dict.leo.org/ende?lp=endep=thMx..search=viewable that the actions from Node 2 to Node 1 are much more than from Node 1 to 2 and also more then from node 3 to three, and so on. Maximum nodes: about 20 Follow along these lines: http://lists.gnu.org/archive/html/igraph-help/2009-04/msg00104.html plus set the 'width' edge attribute to represent the number of actions. Best, Gabor Regards Knut __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Gabor Csardi gabor.csa...@unil.ch UNIL DGM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice xyplot with two y axis
I have some data which needs to be plotted with lattice. library(lattice) cars - c(0.1, 0.3, 0.6, 0.4, 0.9) trucks - c(0.2, 0.5, 0.4, 0.5, 0.1) drivers-c(121,145,167,200, 210) year-c(2005,2006,2007,2008,2009) type-c(local,local,foreign,foreign,foreign) xyplot(cars+trucks~year|type, data=df3, type=o) Basically, I need to show drivers as well on a secondary y-axis. Is this possible with lattice and xyplot? The trick is to use a custom y-scale component to draw the second axis. You also need to manually make space between panels using the between argument. #Your data, as before library(lattice) cars - c(0.1, 0.3, 0.6, 0.4, 0.9) trucks - c(0.2, 0.5, 0.4, 0.5, 0.1) drivers-c(121,145,167,200, 210) year-c(2005,2006,2007,2008,2009) type-c(local,local,foreign,foreign,foreign) #Custom y-scale component myyscale.component - function(...) { ans - yscale.components.default(...) ans$right - ans$left foo - ans$right$labels$at ans$right$labels$labels - as.character(200*foo) #200 is the scale factor difference between axes, adjust as necessary ans } #The plot xyplot(cars+trucks+drivers/200~year|type, type=o, scales=list( x=list(alternating=FALSE), y=list(relation=free, rot=0)), # relation=free separates the panels yscale.component=myyscale.component, between=list(x=2), #between creates more space between the panels - you may need to adjust this value par.settings=list(layout.widths=list(right.padding=6)), #this creates more space on the right hand side of the plot ylab=NULL, key=simpleKey(text=c(cars, trucks, drivers))) Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential inform...{{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] Function call error in cph/survest (package Design)
Dear UseR, I do not know if this a problem with me, my data or cph/survest in package design. The example below works with a standard data set, but not with my data, but I cannot locate the problem. Note that I am using an older package of survival to avoid a problem with the newly renamed function in survival meeting Design. Dieter # First, check standard example to make sure library(Design) data(ovarian) dd = datadist(ovarian) options(datadist=dd) ovarian$rx = as.factor(ovarian$rx) cp = cph(Surv(futime,fustat)~rx,data=ovarian,surv=TRUE,x=TRUE,y=TRUE) summary(cp) # works ok survest(cp,levels(ovarian$rx),times=500) # Small data set, 223 rows, 3650 bytes cc = read.table(http://www.menne-biomed.de/uni/cc.csv,header=TRUE) #cc = read.table(cc.csv,header=TRUE) dd = datadist(cc) cp = cph(Surv(DaysToEvent,event)~ITTGroup,data=cc,surv=TRUE,x=TRUE,y=TRUE) survest(cp,levels(cc$ITTGroup),times=100) #Error in survfit.cph(list(coefficients = c(0.435291247251185, -0.143015493753166 : # NA/NaN/Inf in foreign function call (arg 13) #In addition: Warning message: #NAs introduced by coercion #--- summary(cc) DaysToEvent event ITTGroup Min. : 3.0 Mode :logical Anti:76 1st Qu.: 22.0 FALSE:89Con :76 Median : 70.0 TRUE :134 Pla :71 Mean :108.3 NA's :0 3rd Qu.:224.0 Max. :261.0 # sessionInfo() R version 2.9.0 Under development (unstable) (2009-03-13 r48127) i386-pc-mingw32 locale: LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=Germ an_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252 attached base packages: [1] splines stats graphics grDevices datasets utils methods base other attached packages: (Note: older version of survival to avoid problems with Design) [1] Design_2.1-2 survival_2.34 Hmisc_3.5-2 loaded via a namespace (and not attached): [1] cluster_1.11.12 grid_2.9.0 lattice_0.17-20 tools_2.9.0 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice xyplot with two y axis
taz9 alienz747 at gmail.com writes: I have some data which needs to be plotted with lattice. library(lattice) cars - c(0.1, 0.3, 0.6, 0.4, 0.9) trucks - c(0.2, 0.5, 0.4, 0.5, 0.1) drivers-c(121,145,167,200, 210) year-c(2005,2006,2007,2008,2009) type-c(local,local,foreign,foreign,foreign) xyplot(cars+trucks~year|type, data=df3, type=o) Basically, I need to show drivers as well on a secondary y-axis. Is this possible with lattice and xyplot? Ugly, therefore not officially supported, but possible: http://markmail.org/message/zap4t22er3aoqhcz Omit the data=df3 in your example, otherwise it does not run. Dieter __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice xyplot with two y axis
Richie, this is perfect! Thank you so much. All the best, Kate On Tue, Apr 14, 2009 at 12:16 PM, richard.cot...@hsl.gov.uk wrote: I have some data which needs to be plotted with lattice. library(lattice) cars - c(0.1, 0.3, 0.6, 0.4, 0.9) trucks - c(0.2, 0.5, 0.4, 0.5, 0.1) drivers-c(121,145,167,200, 210) year-c(2005,2006,2007,2008,2009) type-c(local,local,foreign,foreign,foreign) xyplot(cars+trucks~year|type, data=df3, type=o) Basically, I need to show drivers as well on a secondary y-axis. Is this possible with lattice and xyplot? The trick is to use a custom y-scale component to draw the second axis. You also need to manually make space between panels using the between argument. #Your data, as before library(lattice) cars - c(0.1, 0.3, 0.6, 0.4, 0.9) trucks - c(0.2, 0.5, 0.4, 0.5, 0.1) drivers-c(121,145,167,200, 210) year-c(2005,2006,2007,2008,2009) type-c(local,local,foreign,foreign,foreign) #Custom y-scale component myyscale.component - function(...) { ans - yscale.components.default(...) ans$right - ans$left foo - ans$right$labels$at ans$right$labels$labels - as.character(200*foo) #200 is the scale factor difference between axes, adjust as necessary ans } #The plot xyplot(cars+trucks+drivers/200~year|type, type=o, scales=list( x=list(alternating=FALSE), y=list(relation=free, rot=0)), # relation=free separates the panels yscale.component=myyscale.component, between=list(x=2), #between creates more space between the panels - you may need to adjust this value par.settings=list(layout.widths=list(right.padding=6)), #this creates more space on the right hand side of the plot ylab=NULL, key=simpleKey(text=c(cars, trucks, drivers))) Regards, Richie. Mathematical Sciences Unit HSL ATTENTION: This message contains privileged and confidential information intended for the addressee(s) only. If this message was sent to you in error, you must not disseminate, copy or take any action in reliance on it and we request that you notify the sender immediately by return email. Opinions expressed in this message and any attachments are not necessarily those held by the Health and Safety Laboratory or any person connected with the organisation, save those by whom the opinions were expressed. Please note that any messages sent or received by the Health and Safety Laboratory email system may be monitored and stored in an information retrieval system. Scanned by MailMarshal - Marshal's comprehensive email content security solution. Download a free evaluation of MailMarshal at www.marshal.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] Search for a graph package - see link
Follow along these lines: http://lists.gnu.org/archive/html/igraph-help/2009-04/msg00104.html plus set the 'width' edge attribute to represent the number of actions. Thanks,Gabor this was my first solution, but unfortunately the data are very complicated to visualize. let me expand the example: Example Node 1 - 2 1 actions Node 2 - 125 actions Node 3 - 1 4 actions Node 1 - 325 actions Node 2 - 3 5 actions Node 3 - 225 actions In that case all lines would be thick and the actions Node 1 - 2 ,Node 3 - 1,Node 2 - 3 would be invisible, so I tried the narrow arrows to get above the thick arrows in an other colour, but I found no rule to order them that the are always on the top ... and the team was not satisfied with this suggestion ;-) The would prefer two parallel arrows one for each direction. Its a very long mathematical formula to display those arrows, depending on the radius of the circles, and there is a ...hidden...error in the formula. So I tried to ask again if there is another solution. By the way: Do you know such arrow funtion: arrow(starting_point, angle, length) ? Thanks's for your patient Knut __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Search for a graph package - see link
On Tue, Apr 14, 2009 at 6:46 PM, Knut Krueger r...@krueger-family.de wrote: [...] In that case all lines would be thick and the actions Node 1 - 2 ,Node 3 - 1,Node 2 - 3 would be invisible, so I tried the narrow arrows to get above the thick arrows in an other colour, but I found no rule to order them that the are always on the top ... and the team was not satisfied with this suggestion ;-) Then make the arrows narrower. Or assign the arrow width logarithmically to you edge weight. I.e. something like E(g)$width - log(E(g)$weight)+1 The would prefer two parallel arrows one for each direction. You can set 'curved' to a value close to zero and then the arrows will be only a bit curved. Its a very long mathematical formula to display those arrows, depending on the radius of the circles, and there is a ...hidden...error in the formula. I am a bit lost. What formula are we talking about? So I tried to ask again if there is another solution. By the way: Do you know such arrow funtion: arrow(starting_point, angle, length) ? I know igraph:::igraph.Arrows, there might be others as well, G. [...] -- Gabor Csardi gabor.csa...@unil.ch UNIL DGM __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Forcing the extrapolation of loess through the origin
Hi all, I'm fitting a line to my dataset. Later I want to predict missing values that exceed the [min,max] interval of my empirical data, therefore I choose surface=direct for extrapolation. l1-loess(y1~x1,span=0.1,data.frame(x=x1,y=y1),control=loess.control(surface=direct)) In my application it is highly important that the fitted line intercepts at the point of origin. Is it possible to do this in R? Thanks in advance. Cheers, Torsten -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Forcing the extrapolation of loess through the origin
Below. Bert Gunter Genentech Nonclinical Biostatistics 650-467-7374 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of jimm-pa...@gmx.de Sent: Tuesday, April 14, 2009 10:08 AM To: r-help@r-project.org Subject: [R] Forcing the extrapolation of loess through the origin Hi all, I'm fitting a line to my dataset. Later I want to predict missing values that exceed the [min,max] interval of my empirical data, therefore I choose surface=direct for extrapolation. l1-loess(y1~x1,span=0.1,data.frame(x=x1,y=y1),control=loess.control(surface =direct)) In my application it is highly important that the fitted line intercepts at the point of origin. Is it possible to do this in R? -- No. Indeed, this appears to me to contradict the nature of loess as a locally adaptive fit. Bert Thanks in advance. Cheers, Torsten -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Automating object creation
I am new to R. I would like to automate the creation of a number of vectors but can't seem to get the string formatting to work. Here's what I would like to be able to do: Suppose we have a vector: x - c(2,4,5) I would like to be able to create a set of vectors whose names are associated with the values in x - e.g. x2 - 0 x4 - 0 x5 - 0 I have tried with a for loop and eval and sprintf, paste, etc. but end up with the following error: Error in sprintf(%s%i, x, 1) - 0 : target of assignment expands to non-language object How can I assign a string formatted name to a vector? Any help appreciated, Zak __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Automating object creation
?assign (but are you sure you really want to name all these objects separately? Usually in R you would put them together in a list or a data.frame, it is much more convenient for later manipulations) On 14 Apr 2009, at 18:32, Zachary Patterson wrote: I am new to R. I would like to automate the creation of a number of vectors but can't seem to get the string formatting to work. Here's what I would like to be able to do: Suppose we have a vector: x - c(2,4,5) I would like to be able to create a set of vectors whose names are associated with the values in x - e.g. x2 - 0 x4 - 0 x5 - 0 I have tried with a for loop and eval and sprintf, paste, etc. but end up with the following error: Error in sprintf(%s%i, x, 1) - 0 : target of assignment expands to non-language object How can I assign a string formatted name to a vector? Any help appreciated, Zak __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. _ Baptiste Auguié School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Automating object creation
On Tue, Apr 14, 2009 at 6:32 PM, Zachary Patterson zak.patter...@gmail.com wrote: I am new to R. I would like to automate the creation of a number of vectors but can't seem to get the string formatting to work. Here's what I would like to be able to do: Suppose we have a vector: x - c(2,4,5) I would like to be able to create a set of vectors whose names are associated with the values in x - e.g. x2 - 0 x4 - 0 x5 - 0 I have tried with a for loop and eval and sprintf, paste, etc. but end up with the following error: Error in sprintf(%s%i, x, 1) - 0 : target of assignment expands to non-language object How can I ***assign*** a string formatted name to a vector? Ooh, you're so close. Read the help page for assign perhaps? help(assign) and hence enlightenment. Also note it's not normally a good thing to do. Better to stick these things in a list, because your next question is going to be 'how do I **get** the value of x1, x2, x3 etc in a loop if i is 1,2 or 3?'. The answer to that one is 'Read the help page for get'. But if you stick your stuff in a list object the answer is simply x[[i]]. See also FAQ 7.21: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-I-turn-a-string-into-a-variable_003f But really, use a list :) Barry __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Automating object creation
It is certainly possible to create x2, x4, etc. using something like assign( sprintf(x%d,i), ...value... ). But are you sure you need separate *variables* x2, x4, etc.? Why not create a list of vectors addressible as x[2] etc.? You can do that with x - list() (to define the data type of x as allowing generic objects) then x[2] - ... value ... etc. -s On Tue, Apr 14, 2009 at 1:32 PM, Zachary Patterson zak.patter...@gmail.com wrote: I am new to R. I would like to automate the creation of a number of vectors but can't seem to get the string formatting to work. Here's what I would like to be able to do: Suppose we have a vector: x - c(2,4,5) I would like to be able to create a set of vectors whose names are associated with the values in x - e.g. x2 - 0 x4 - 0 x5 - 0 I have tried with a for loop and eval and sprintf, paste, etc. but end up with the following error: Error in sprintf(%s%i, x, 1) - 0 : target of assignment expands to non-language object How can I assign a string formatted name to a vector? Any help appreciated, Zak __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Forcing the extrapolation of loess through the origin
On Tue, Apr 14, 2009 at 1:08 PM, jimm-pa...@gmx.de wrote: I'm fitting a line to my dataset. Later I want to predict missing values that exceed the [min,max] interval of my empirical data, therefore I choose surface=direct for extrapolation. l1-loess(y1~x1,span=0.1,data.frame(x=x1,y=y1),control=loess.control(surface=direct)) In my application it is highly important that the fitted line intercepts at the point of origin. Is it possible to do this in R? Well, you could always add lots of artificial data points x=0, y=0 ..., like this: l1-loess(y1~x1,span=0.1,data.frame(x=c(rep(0,100),x1),y=c(rep(0,100),y1)),control=loess.control(surface=direct)) which will eventually drive f(0) to near 0, but surely that will create fitting artifacts. -s __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Forcing the extrapolation of loess through the origin
Hi Torsten, If you are fitting a line, why are you using loess? Why not simply use lm to fit a regression line that goes through the origin? (i.e. with no intercept). Julian jimm-pa...@gmx.de wrote: Hi all, I'm fitting a line to my dataset. Later I want to predict missing values that exceed the [min,max] interval of my empirical data, therefore I choose surface=direct for extrapolation. l1-loess(y1~x1,span=0.1,data.frame(x=x1,y=y1),control=loess.control(surface=direct)) In my application it is highly important that the fitted line intercepts at the point of origin. Is it possible to do this in R? Thanks in advance. Cheers, Torsten -- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Automating object creation
Wow! I wasn't expecting such quick and helpful responses. I will see which of these suggestions works best for what I am doing. Thanks very much to all of you. Zak On Tue, Apr 14, 2009 at 1:58 PM, Stavros Macrakis macra...@alum.mit.edu wrote: It is certainly possible to create x2, x4, etc. using something like assign( sprintf(x%d,i), ...value... ). But are you sure you need separate *variables* x2, x4, etc.? Why not create a list of vectors addressible as x[2] etc.? You can do that with x - list() (to define the data type of x as allowing generic objects) then x[2] - ... value ... etc. -s On Tue, Apr 14, 2009 at 1:32 PM, Zachary Patterson zak.patter...@gmail.com wrote: I am new to R. I would like to automate the creation of a number of vectors but can't seem to get the string formatting to work. Here's what I would like to be able to do: Suppose we have a vector: x - c(2,4,5) I would like to be able to create a set of vectors whose names are associated with the values in x - e.g. x2 - 0 x4 - 0 x5 - 0 I have tried with a for loop and eval and sprintf, paste, etc. but end up with the following error: Error in sprintf(%s%i, x, 1) - 0 : target of assignment expands to non-language object How can I assign a string formatted name to a vector? Any help appreciated, Zak __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Fitted values and MSE of individual fits in lmList
Dear useRs, I am working on a series of field experiments (159 in total) carried out in different years in several locations. The cultivars in each experiment are not always the same, in fact they change over time. I would like to get the fitted values and MSE of the individual fits from the following lmList object, so I can use them to fit a mixed model using the fitted values and weight each environment with (number of reps/MSE)/Average MSE. library(nlme) yield.list - lmList(yield ~ as.factor(rep) + id | yearloc, data = df1, na.action = na.omit) then I do yield.fitted - fitted(yield.list) yield.fitted Akron1999 Akron1999 Akron1999 Akron1999 Akron1999 45.06508 61.29841 63.73175 61.16508 63.53175 Akron1999 Akron1999 Akron1999 Akron1999 Akron1999 64.63175 53.09841 60.66508 70.36508 57.19841 Akron1999 Akron1999 Akron1999 Akron1999 Akron1999 55.33175 60.79841 54.79841 56.46508 64.99841 Akron1999 Akron1999 Akron1999 Akron1999 Akron1999 57.56508 58.59841 57.86508 56.43175 51.79841 The label of each value is the yearloc, I also need to know their id. Is there a way to ad this info? I have not figured out how to obtain individual mean square errors from an lmList object. However, I can do it with: res - as.data.frame(matrix(NA, ncol = 3, nrow = length(levels(yieldh$yearloc)), dimnames = list(NULL, c(yearloc, MSE, rep for (i in 1:length(levels(yieldh$yearloc))) { dta - subset(yieldh,yieldh$yearloc==levels(yieldh$yearloc)[i], drop = T) x - anova(lm(yield ~ factor(rep) + id, data = dta, na.actio = na.omit))$Mean Sq[3] res[i,] - c(levels(yieldh$yearloc)[i],x, length(levels(dta$rep))) } Can anybody give me directions to solve this? Thanks, Marc [[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] Physical Units in Calculations
On Mon, 13-Apr-2009 at 09:15PM +0100, S Ellison wrote: | bill.venab...@csiro.au 04/13/09 4:01 AM | The UK uses metres for most lengths but miles for road distances - | the worst of all worlds. They even measure fuel performance in | litres per 100 *miles*, if you can believe it. | No, we don't. We use miles per (Imperial) gallon. But petrol is priced by the litre. -- ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. ___Patrick Connolly {~._.~} Great minds discuss ideas _( Y )_ Average minds discuss events (:_~*~_:) Small minds discuss people (_)-(_) . Eleanor Roosevelt ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] matrix merge problem
Dear r-help contributors, I have two questions: first: I have a matrix A and a vector B. I want to make a new matrix C, which is made of the rows of A having a value included in B. Second: I have two matrixes A and B, of different dimensions. B has unique values in column 2 and A has not unique values on column 2. I want to merge this two matrixes by the values in the columns 2 of B and 2 of A in such a way that the resulting matrix will be C: A: 1 2 2 2 3 3 4 3 5 4 6 4 7 5 8 5 B: 1 2 x c d 2 3 y f g C: 1 2 x c d 2 2 x c d 3 3 y f g 4 3 y f g 5 4 NA NA 6 4 NA NA 7 5 NA NA 8 5 NA NA Can you help me? Many thanks in advance. [[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] Building GUI for custom R application
If the desired end-state is a regression model and the appropriate diagnostics, the Rcmdr package contains the necessary tools. Rcmdr is available for many Linux distribuitons as well as for Windows, and it is able to do much more than import-and-regress. I think the package was built from Tcl/Tk. If the goals, however, are learning to build a GUI and incorporating custom features within it, then the other posts are pointing in the appropriate direction. Mike On Apr 14, 10:40 am, Bert Gunter gunter.ber...@gene.com wrote: Duncan Murdoch and Brian Ripley (I believe) have provided some limited but serviceable native Windows GUI functionality within R for Windows. See ?winMenuAdd, ?choose.files , ?select.list, ?getGraphicsEvent,?winProgressBar for examples and further links. Everything that you mention can be rather simply done using this functionality (I've done it). As others have said, much more extensive and powerful GUI functionality is available through tcltk and associated packages like gWidgets,TkWidgets, and others (including much stuff on Bioconductor). But beware! -- writing GUI's that provide complex functionality is difficult. Computer scientists, web designers, etc. have whole curricula devoted to this. Cheers, Bert Bert Gunter Genentech Nonclinical Biostatistics 650-467-7374 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Gabor Grothendieck Sent: Tuesday, April 14, 2009 4:17 AM To: Barry Rowlingson Cc: r-h...@r-project.org; Harsh Subject: Re: [R] Building GUI for custom R application On Tue, Apr 14, 2009 at 6:54 AM, Barry Rowlingson b.rowling...@lancaster.ac.uk wrote: On Tue, Apr 14, 2009 at 9:23 AM, Harsh singhal...@gmail.com wrote: HI R users, I would appreciate information/examples/suggestions on building GUIs for R applications. I am currently working on a project that would require the following functionalities : 1) Display a window to the user. Provide a function to scan local drive and choose dataset file. 2) Display the column names for the user to choose the dependent variable and the independent variables. 3) Fit regression and display statistics. Item 2 provides an example of creating a regression application with slider controls for a parameter in loess function used in the example application in that paper. For documentation on RGtk the author recommends reading the Gtk tutorial and documentation. I seem to have difficulty in making sense of the Gtk documentation since most of it is in C and documentation is available for use of Gtk with Perl and Python. I am not a C/Perl/Python programmer. You should say I am not _yet_ a C/Perl/Python programmer. Don't limit yourself :) Moreover, I am creating a Windows Application and is using RGtk2 the only way to create a GUI for an R application? Or should I use the the VB approach and create the GUI separately and call R scripts where required to do the back-end computation? If you are to admit the possibility of becoming a Python programmer (strongly recommended) I'd say you could do it with Python, Rpy, and the Qt library. The basic example you've outlined (choose file, select X and Y values, plot, display stats) would take about twenty minutes. In fact, I've done half the work already, in adding almost just such functionality to Quantum GIS. See here: http://www.maths.lancs.ac.uk/~rowlings/Software/Spqr/ where the second screenshot shows variable selection and diagnostic plots of an lm from data in the GIS. Distributing such an application might be tricky since it requires R, Rpy, PyQt4 to be installed or available, but it can be possible to build Python code into Windows .exe files with some effort. Since you are using Windows (based on the fact you are considering VB) note that rpy2 does not work with the recent versions of python (as of a few months ago when I checked). __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ r-h...@r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.- Hide quoted text - - Show quoted text - __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] method ML
Hi I am doing lme models and they are coming out using the REML method, can anyone please tell me how i use the ML method and exactly what i put in to R to do this? Just wanted to say thanks for everyone who helped with my last question. Thanks Joe -- View this message in context: http://www.nabble.com/method-ML-tp23040635p23040635.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] scatterplot3d
Dear R-help, I am having trouble with your scatterplot3d program. For help with this problem I was directed to your address by Martin Maechler at r-core-boun...@r-project.org. I'm also sending a CC to r-core-ow...@r-project.org as I'm not yet certain of the proper address to use for this. I have R version 2.8.1 and have downloaded 'scatterplot3d.' I can generate the points with the cube defined by the baselines. However *there are no lines connecting the points with one of the planes*; therefore the locations of the points are indeterminate; this is my problem. Could you tell me how to include the lines from the points to a plane - preferably the base plane? I am a computer-incompetent biological scientist, and would learn quicker if you gave me instructions using my data as an example. Thus I am attaching some sample data (Moraceae for MDS.txt.doc) and the instructions I am using (format.doc). I hope you can provide an example. Thank you very much. Robert P. Erickson, Duke University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] import from stata
Dear R users, I am trying to import a table from STATA, a dta file. With a table called table, this is what I do : library(foreign) read.dta(table) It does not work. What am I doing wrong ? Best Regards, Dwayne [[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] method ML
Hi Joe, You're using the lme() function? If so, then adding /method = ML / to the argument list should do the trick. Cheers, Luc joewest wrote: Hi I am doing lme models and they are coming out using the REML method, can anyone please tell me how i use the ML method and exactly what i put in to R to do this? Just wanted to say thanks for everyone who helped with my last question. Thanks Joe __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Random Forests Variable Importance Question
Paul, To build on what Andy said: The measures of importance RF provides are just alternative ways of getting at the same thing: Variable Importance. For example, MeanDecreaseAccuracy is one of those alternatives. As Andy said, it does not make sense to look at the absolute importance value. In a hypothetical case where all importance values seem high but are equal - that means that all variables have the same importance. In another case, where all importance values seem low but are equal - that means exactly the same thing, that all variables have the same importance. The point is: the absolute value of importance is not very helpful. One needs to build relative importance values. I learned to use it like this (similar to what Andy said): 1. Take RF output for each variable (MeanDecreaseAccuracy - for example, if the RF object is called rftest then I take the vector as.data.frame(rftest$importance)[1] 2. I divide each variable's (raw) importance by its respective SD (as.data.frame(rftest$importanceSD)[1]) 3. The resulting values that are less than zero are made equal to zero, as Andy mentioned. 4. I take each value, multiply it by 100 and divide it by the sum of all the values from step 3. This way I get relative importance of each predictor and all importances sum up to 100. -- Dimitri Liakhovitski MarketTools, Inc. dimitri.liakhovit...@markettools.com Date: Mon, 13 Apr 2009 09:09:35 -0400 From: Liaw, Andy andy_l...@merck.com Subject: Re: [R] Random Forests Variable Importance Question To: Paul Fisch fis...@gmail.com, r-help@r-project.org Message-ID: 39b6ddb9048d0f4dad42cb26aaff0afa071ba...@usctmx1106.merck.com Content-Type: text/plain; charset=iso-8859-1 I'll take a shot. Let me try to explain the 3rd measure first. A RF model tries to predict an outcome variable (the classes) from a group of potential predictor variables (the x). If a predictor variable is important in making the prediction accurate, then by messing with it (e.g., giving it random values) should have a larger impact on how well the prediction can be made, compared to a variable that contributes little. The variable importance measure tries to capture this. (If you throw a wrench into the trunk of a car, it probably doesn't affect how the car drives. However, if you throw the wrench into the engine compartment, that _may_ be a different story.) I don't know about others, but I only look at the relative importance of the variables, rather than trying to interpret the numbers (raw or scaled). Any number below 0 should be treated as the same as 0 (if I recall, Breiman Cutler's code truncate the values at 0). Any variable with importance value smaller than the absolute value of the minimum is probably not worth much looking. The first two measures (you must be predicting an outcome variable with two classes) are the analogous measures that address each of the two classes specifically, rather than over all of the data. Andy From: Paul Fisch I am trying to use the random forests package for classification in R. The Variable Importance Measures listed are: -mean raw importance score of variable x for class 0 -mean raw importance score of variable x for class 1 -MeanDecreaseAccuracy -MeanDecreaseGini Now I know what these mean as in I know their definitions. What I want to know is how to use them. What I am trying to figure out is what these values mean in only the context of how accurate they are, what is a good value, what is a bad value, what are the maximums and minimums, etc. If a variable has a high MeanDecreaseAccuracy or MeanDecreaseGini does that mean it is important or unimportant? Also any information on the raw scores would be really helpful too. I want to know everything there is to know about these numbers that is relevant to the application of them. I don't really want a technical explanation that uses words like 'error', 'summation', or 'permutated', but rather a simpler explanation that didn't involve any discussion of how random forests works(I have read all about that and didn't find it very helpful.) Like if I wanted someone to explain to me how to use a radio, I wouldn't expect the explanation to involve how a radio converts radio waves into sound. If anyone can help me out at all it would be really great.? I have read many many lectures on random forests and other data mining lectures but I have never found simple answers about how to read the variable importance measures. Thanks, Paul Fisch __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] matrix merge problem
Hi again, Your second problem can be solved with the merge function. Look at the help file with ?merge. Best of luck, Luc Juan Pablo Fededa wrote: Merci a lot!! On Tue, Apr 14, 2009 at 10:32 PM, Luc Villandre villa...@dms.umontreal.ca mailto:villa...@dms.umontreal.ca wrote: Hi Juan, Your first question can be answered easily. bin.matrix = matrix(A %in% B,nrow(A),ncol(A)) ; bin.vector = rowSums(bin.matrix) 0 ; C = A[bin.vector,] ; This should do the trick. Cheers, Luc Juan Pablo Fededa wrote: Dear r-help contributors, I have two questions: first: I have a matrix A and a vector B. I want to make a new matrix C, which is made of the rows of A having a value included in B. Second: I have two matrixes A and B, of different dimensions. B has unique values in column 2 and A has not unique values on column 2. I want to merge this two matrixes by the values in the columns 2 of B and 2 of A in such a way that the resulting matrix will be C: A: 1 2 2 2 3 3 4 3 5 4 6 4 7 5 8 5 B: 1 2 x c d 2 3 y f g C: 1 2 x c d 2 2 x c d 3 3 y f g 4 3 y f g 5 4 NA NA 6 4 NA NA 7 5 NA NA 8 5 NA NA Can you help me? Many thanks in advance. [[alternative HTML version deleted]] __ R-help@r-project.org mailto:R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question on zero-inflated Poisson count data with repeatedmeasures design - glmm.ADMB
Dear Thierry, Thanks for your answer and for letting me know about the R-Sig-mixed models mailing list! Furthermore you assume that the first visit in year 1 has the same effect as the first visit in year 2 and 3. And the same goes for the other visits. Is that a valid assumption for your data? Hmm, these are rather sparse data from small birds in Ecuadorian forests so it will be best to use a model syntax that makes the least assumptions possible. As suggested, I renamed 'counts' to visits' and numbered them from 1 to 15. If I understand the nlme syntax, I need something like this: nlme(abundance~X1+X2+visit, fixed=X1+X2~1, random=visit~1 | site/point) However, this seems to results in the following error: Error in nlme.formula(abundance ~ X1 + X2 + visit, fixed = X1 + X2 ~ 1, : element 1 is empty; the part of the args list of 'is.numeric' being evaluated was: (start) Moreover, nlme seens to use either REML or ML and I have not found any hints on how to specify a zero-inflated Poisson distribution for nmle... Any suggestions? Many thanks and best wishes! Diederik Diederik Strubbe Evolutionary Ecology Group Department of Biology, University of Antwerp Universiteitsplein 1 B-2610 Antwerp, Belgium http://webhost.ua.ac.be/deco tel : 32 3 820 23 85 -Original Message- From: ONKELINX, Thierry [mailto:thierry.onkel...@inbo.be] Sent: Tue 14-4-2009 15:46 To: Strubbe Diederik; r-help@r-project.org Subject: RE: [R] Question on zero-inflated Poisson count data with repeatedmeasures design - glmm.ADMB Dear Diederik, If you revisited the same points then it makes sense to use the data at the point level. But then I would mke that explicit by using a nested random effect. In the nlme/lme4 syntax: 1|Site/Point. Make shure that each point has a unique ID. Naming a variable count is not a very good idea unless it is something you counted. I would suggest to rename it to visit. That would cause less confugion. It looks to me like you have in your model a crossed random effect: Visit and Site. Was that intended? Furthermore you assume that the first visit in year 1 has the same effect as the first visit in year 2 and 3. And the same goes for the other visits. Is that a valid assumption for your data? Including year as a random effect is not a good idea since is has only three levels. Douglas Bates recommends at least six levels for a random effect. Otherwise you don't get a good estimate of its variance. You could number the visits from 1 to 15 instead of restarting from 1 each year. Then you make less assumitions about your model. As this random effect would incorporate the effects of year, visit and their interaction. HTH, Thierry PS R-Sig-mixed models is a mailing list dedicated to mixed models. That is more appropriate for this kind of questions. ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest Cel biometrie, methodologie en kwaliteitszorg / Section biometrics, methodology and quality assurance Gaverstraat 4 9500 Geraardsbergen Belgium tel. + 32 54/436 185 thierry.onkel...@inbo.be www.inbo.be To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey -Oorspronkelijk bericht- Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Strubbe Diederik Verzonden: maandag 13 april 2009 22:35 Aan: r-help@r-project.org Onderwerp: [R] Question on zero-inflated Poisson count data with repeatedmeasures design - glmm.ADMB Dear R community, I have some questions regarding the analysis of a zero-inflated count dataset and repeated measures design. The dataset is arranged as follows : Unit of analysis: point - these are points were bird were counted during a certain amount of time. In total we have about 175 points. Each point is located within a certain habitat fragment (here: site= A-B-C-D-..., in reality we have 25 sites,i.e. forest fragments). All points were counted five times during three years ( thus in total, each point was counted 15 times). We want to relate the bird abundance to a number of habitat variables (here: X1-X2-X3) collected at the site level. Abundance: this is the number of birds counted at a point. In most cases ( 90%), no birds were detected and the abundance dataset is thus zero-inflated. I have been looking for a code to analyze this zero-inflated poisson distributed dataset with a repeated measures design, and I have arrived at the glmmADMB package. library(glmmADMB) data -
Re: [R] matrix merge problem
Hi Juan, Your first question can be answered easily. bin.matrix = matrix(A %in% B,nrow(A),ncol(A)) ; bin.vector = rowSums(bin.matrix) 0 ; C = A[bin.vector,] ; This should do the trick. Cheers, Luc Juan Pablo Fededa wrote: Dear r-help contributors, I have two questions: first: I have a matrix A and a vector B. I want to make a new matrix C, which is made of the rows of A having a value included in B. Second: I have two matrixes A and B, of different dimensions. B has unique values in column 2 and A has not unique values on column 2. I want to merge this two matrixes by the values in the columns 2 of B and 2 of A in such a way that the resulting matrix will be C: A: 1 2 2 2 3 3 4 3 5 4 6 4 7 5 8 5 B: 1 2 x c d 2 3 y f g C: 1 2 x c d 2 2 x c d 3 3 y f g 4 3 y f g 5 4 NA NA 6 4 NA NA 7 5 NA NA 8 5 NA NA Can you help me? Many thanks in advance. [[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] Building GUI for custom R application
On Tue, Apr 14, 2009 at 9:46 PM, mah harwood...@gmail.com wrote: If the desired end-state is a regression model and the appropriate diagnostics, the Rcmdr package contains the necessary tools. Rcmdr is available for many Linux distribuitons as well as for Windows, and it is able to do much more than import-and-regress. I think the package was built from Tcl/Tk. If the goals, however, are learning to build a Rcmdr provides a handy plug-in system, and it's fairly easy to write your own plug-in in tcl/tk. There was also a recent discussion [1] on the subject of creating GUIs for R. Liviu [1] http://www.nabble.com/Creating-GUIs-for-R-td19862627.html __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Help with nested loops
Hello- I need to loop through a directory of files to extract data corresponding to dates in a dataframe. Within a function, I've written nested loops to index the dataframe dates, and the directory files. My function successfully extracts the data corresponding to my first data frame date, but stops there and doesn't continue through my entire list of data frame dates and directory files (I need it to go through ~2600 lines in my data frame, and ~50 data files in my directory). Currently, I'm using an 'if' statement to see if my data frame dates and directory file names meet the criteria for data extraction, which is I think why it stops after the first successful iteration. However, I'm stumped on what to do now. I have tried using 'while' statements which seem to hang up in an endless loop. Some advice on getting the function to finish looping through all of my data frame lines and directory files would be much appreciated. I've also read that apply, tapply, etc. can be more efficient at looping tasks, but my experimenting with them has not been much help and I'm not sure my task is best suited to those functions. Below is an example. I'm using R 2.7.2 in Vista. Example extract.asc.data.for.tracks-function(id, d.frame.date, centroid.x, centroid.y, ci.x, ci.y, asc.dir, asc.date.start, asc.date.end, asc.duration, env.variable) { id-id d.frame.date-as.POSIXct(d.frame.date, GMT, format=%Y-%m-%d) require(RSAGA) # set environment for RSAGA env-rsaga.env(path=C:\\programs\\saga_vc, cmd=saga_cmd.exe) # format directory file names for input into data extraction function below called 'pick.from.ascii.grid' asc.files-substr(basename(dir(asc.dir, pattern='.asc$')), 1, nchar(basename(dir(asc.dir, pattern='.asc$'))) - 4) # index and loop through dates dataframe for (j in 1 : length(asc.files)){ # index and loop through datafiles in directory for (i in 1 : length(d.frame.date)){ # find dates within the named directory of files that are within 7 days of any given dataframe date if ((as.POSIXct(substr(asc.files[j], start = nchar(asc.files[j]) - asc.date.start, stop = nchar(asc.files[j]) - asc.date.end), 'GMT') - d.frame.date[i]) %in% 1:asc.duration) # when date criteria are met, extract data using coordinates(x and y) plus a buffer (ci.x and ci.y) dat-pick.from.ascii.grid(data=as.data.frame(cbind(x=centroid.x[i] + ci.x, y=centroid.y[i] + ci.y)), env=env, cbind=T, path=asc.dir, file=paste(asc.files[j],'asc', sep=.), at.once=F, method=nearest.neighbour, nodata.values=-999) # calculate weighted mean of extracted data w.mean-weighted.mean(x=dat[,3], w=den.xt$y*den.yt$y, na.rm=T) # return new data frame containing original id, date, x/y coords, and newly calculated weighted mean out.df-data.frame(id[i], d.frame.date[i], centroid.x[i], centroid.y[i], w.mean[i]) # give names to columns in new data frame names(out.df)-c('id', 'date', 'x', 'y', paste(env.variable, 'w.mean', sep=_)) return(out.df) }}} # subset of my data frame stm.data iddatex y 10 STM05_2 2005-03-01 12:00:00 178.2606 -34.82035 11 STM05_2 2005-03-02 00:00:00 178.2281 -34.38141 12 STM05_2 2005-03-02 12:00:00 178.2145 -33.95625 13 STM05_2 2005-03-03 00:00:00 178.2123 -33.55642 14 STM05_2 2005-03-03 12:00:00 178.2056 -33.18816 15 STM05_2 2005-03-04 00:00:00 178.1920 -32.85041 16 STM05_2 2005-03-04 12:00:00 178.1722 -32.54057 17 STM05_2 2005-03-05 00:00:00 178.1465 -32.25634 18 STM05_2 2005-03-05 12:00:00 178.1150 -31.99568 19 STM05_2 2005-03-06 00:00:00 178.0777 -31.75682 # some of the data files in directory which I need to extract data from asc.dir [1] tmp1_290E0N2005-03-02 tmp1_290E0N2006-01-05 tmp1_290E0N2006-07-08 tmp1_290E0N2007-02-22 tmp10_290E0N2005-05-13 tmp10_290E0N2006-03-18 Arguements to run the function extract.asc.data.for.tracks(id=stm.data$id, d.frame.date=stm.data$date, centroid.x=stm.data$x, centroid.y=stm.data$y, ci.x=seq(-1,1,0.1), ci.y=seq(-1,1,0.1), asc.date.start=9, asc.date.end=0, asc.duration=7, env.variable=SST, asc.dir=C:\\...\\data.files) # the result of the function successfully extracting data from a single row in my data frame, but I need to do this for ~ 2600 dataframe lines id datex y SST_w.mean 1 STM05_2 2005-03-01 178.2606 -34.82035 21.97327 Many thanks, Tim -- View this message in context: http://www.nabble.com/Help-with-nested-loops-tp23049250p23049250.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] Two functions plotted in wireframe
On 14/04/2009 11:18 AM, Alrik Thiem wrote: Hi together, I have some graphical problems. I would like to add a semi-transparent surface at z=1 to an existing lattice wireframe plotting a general function z=f(x,y). Any suggestions on how this can be done? Transparency is hard, and I don't think lattice will be able to render this well. rgl may be a better choice. (It generally does a good job with one transparent surface, and sometimes is acceptable with more than one.) 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.
[R] Controlling widths in write.fwf()
Is there a way to handle the widths of values being written to a file using wrtite.fwf() ? For example, I used read.fwf(file, width.vector) to read a file. After making the necessary data manipulation, I want to write the data to a new file in the same width.vector format. Is there a way to specify this? Thanks in Advance Aparna [[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] Controlling widths in write.fwf()
On 14/04/2009 7:28 PM, Vemuri, Aparna wrote: Is there a way to handle the widths of values being written to a file using wrtite.fwf() ? For example, I used read.fwf(file, width.vector) to read a file. After making the necessary data manipulation, I want to write the data to a new file in the same width.vector format. Is there a way to specify this? There is no write.fwf function, but you can use sprintf() to convert things to strings and writeLines to write those strings. There's a lot of flexibility in the formats allowed; see the man page. 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.
[R] Lattice xyplot: Line and Rectangle in legend.
Hello fellow R users, I have a problem. I have created a barchart overlayed by an xyplot line, both of which read off the same Y axis. The problem comes when I try to generate a key. It seems that I can only create either two lines, or two rectangles. I would much prefer to have the barchat series depicted by a rectangle, and the xyplot series by a line. Is there a way to do this? Your help is much appreciated. James -- View this message in context: http://www.nabble.com/Lattice-xyplot%3A-Line-and-Rectangle-in-legend.-tp23050031p23050031.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] Darker markers for symbols in lattice
On Mon, Apr 13, 2009 at 9:37 AM, Naomi B. Robbins nbrgra...@optonline.net wrote: Now that I have the markers the weight I want using lex, I'm having trouble making the key match the markers. Any suggestions? BTW, I'm using R2.8.1 with Windows Vista. There's no real solution, but for some reason, the following seems to work: xyplot(1:10 ~ 1:10, groups = gl(3, 1), auto.key = TRUE, lex = 3, par.settings = list(grid.pars = list(lwd = 3))) -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Lattice xyplot: Line and Rectangle in legend.
On Tue, Apr 14, 2009 at 4:39 PM, jimdare jamesdar...@gmail.com wrote: Hello fellow R users, I have a problem. I have created a barchart overlayed by an xyplot line, both of which read off the same Y axis. The problem comes when I try to generate a key. It seems that I can only create either two lines, or two rectangles. I would much prefer to have the barchat series depicted by a rectangle, and the xyplot series by a line. Is there a way to do this? Something like xyplot(1 ~ 1, key = list(text = list(line), lines = list(col = 2), text = list(rect), rect = list(col = yellow))) ? -Deepayan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] large version of the R symbol
hi, I would like to implement the R-symbol in a presentation. Is there a large-scaled version of it on the web? thanks for 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.
Re: [R] Controlling widths in write.fwf()
Hi Aparna, you could always use the write.table function and set sep=. This will put all of your data into a sort of fixed-width column depending on what you specify to separate the values. See basic example below: x-matrix(nrow=2, ncol=2, c(1,2,3,4)) write.table(x, /Users/morse07/Desktop/x.txt, sep=, col.names=FALSE, row.names=FALSE) Note that any spaces you insert between the after the sep command will insert 1 fixed-width column per space in your file. Hope that helps, Brendan On Apr 14, 2009, at 7:28 PM, Vemuri, Aparna wrote: Is there a way to handle the widths of values being written to a file using wrtite.fwf() ? For example, I used read.fwf(file, width.vector) to read a file. After making the necessary data manipulation, I want to write the data to a new file in the same width.vector format. Is there a way to specify this? Thanks in Advance Aparna [[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] large version of the R symbol
On 14/04/2009 8:22 PM, Martin Batholdy wrote: hi, I would like to implement the R-symbol in a presentation. Is there a large-scaled version of it on the web? The developer.r-project.org web page has several versions of it. (The link is near the bottom of the main page.) 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] Problem with bargraph.CI in Sciplot package
On Sat, 2009-04-11 at 08:10 -0400, Manuel Morales wrote: On Fri, 2009-04-10 at 15:07 -0700, Metconnection wrote: Hi there, I wonder if anyone can help me. I'm trying to use bargraph.CI in the Sciplot package when there is a missing combination of the factor levels. Unfortunately the standard errors on the plot do not appear to be correct. Consider an analysis consisting of two factors A and B. When all factor level combinations are present all appears fine: library(sciplot) #all data response-c(32,54,32,65,34,65,65,45,54,23,43,23,76,87,65,45) factorA-c(A,A,A,A,A,A,A,A,B,B,B,B,B,B,B,B) factorB-c(a,a,a,a,b,b,b,b,a,a,a,a,b,b,b,b) data-data.frame(response,factorA,factorB) bargraph.CI(x.factor = data$factorB,data$response, group=data$factorA, legend=TRUE) but when I remove a combination of the two factors the error whiskers appear to be on the wrong bars: #excluding one combination response-c(34,65,65,45,54,23,43,23,76,87,65,45) factorA-c(A,A,A,A,B,B,B,B,B,B,B,B) factorB-c(b,b,b,b,a,a,a,a,b,b,b,b) data-data.frame(response,factorA,factorB) bargraph.CI(x.factor = data$factorB,data$response, group=data$factorA, legend=TRUE) I had a look at the ci.fun options but with no success. Thanks in advance for any ideas Simon Hi Simon, bargraph.CI was intended for factorial designs and it doesn't work well with missing factor combinations. I'll take a look at changing this, but for now, a quick fix is to add the missing combination with an NA value for the response. Eg., change the data in your second example to: response-c(34,65,65,45,54,23,43,23,76,87,65,45,NA) factorA-c(A,A,A,A,B,B,B,B,B,B,B,B,A) factorB-c(b,b,b,b,a,a,a,a,b,b,b,b,a) This issue has been fixed in version 1.0-5 which I just uploaded to CRAN. It should be available to download soon. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Controlling widths in write.fwf()
Thanks Brendan. write.table() doesn't seem to do it for me. The problem is that my data is not formatted as well as you show in the example. There are numbers and strings of varying sizes and write.table() misses the format. Aparna -Original Message- From: Brendan Morse [mailto:morse.bren...@gmail.com] Sent: Tuesday, April 14, 2009 5:35 PM To: Vemuri, Aparna Cc: r-help@r-project.org Subject: Re: [R] Controlling widths in write.fwf() Hi Aparna, you could always use the write.table function and set sep=. This will put all of your data into a sort of fixed-width column depending on what you specify to separate the values. See basic example below: x-matrix(nrow=2, ncol=2, c(1,2,3,4)) write.table(x, /Users/morse07/Desktop/x.txt, sep=, col.names=FALSE, row.names=FALSE) Note that any spaces you insert between the after the sep command will insert 1 fixed-width column per space in your file. Hope that helps, Brendan On Apr 14, 2009, at 7:28 PM, Vemuri, Aparna wrote: Is there a way to handle the widths of values being written to a file using wrtite.fwf() ? For example, I used read.fwf(file, width.vector) to read a file. After making the necessary data manipulation, I want to write the data to a new file in the same width.vector format. Is there a way to specify this? Thanks in Advance Aparna [[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] import from stata
You need a full name in quotes: auto - read.dta(C:/Stata10/ado/base/a/auto.dta) works just fine on my computer. On 4/14/09, Dwayne Blind dwaynebl...@gmail.com wrote: Dear R users, I am trying to import a table from STATA, a dta file. With a table called table, this is what I do : library(foreign) read.dta(table) It does not work. What am I doing wrong ? Best Regards, Dwayne [[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. -- Stas Kolenikov, also found at http://stas.kolenikov.name Small print: I use this email account for mailing lists only. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] confusion over names of lm.influence()$hat
I am performing a locally weighted regression model using housing data, where I only include observations within a certain distance of the house in question. For cross-validation of the bandwidth I am collecting elements of the hat matrix (where y hat=hat matrix *y). I was convinced I could grab the diagonal elements for the hat matrix using lm.influence()$hat. In particular, I am interested in grabbing the one element of the hat matrix that corresponds with the observation I am running my locally weighted regression at. When I looked more closely at the lm.influence()$hat output, I realized that the observations used in my regression do not appear to be the same observations for which the hat matrix returns values. I had assumed the names associated with lm.influence()$hat were the observation numbers for the regression data, am I wrong? I've included a code snippet and its output. I am confused as to why the observations for which I give positive weights in the regression do not appear to be the same as the names in the hat matrix output. Do you know what mistake I am making? obs - 451 # this is the location/observation in the data for which we are currently running the regression, for example require(fields) # calculate the distance all other observations are from this observation Di=t(rdist.earth(cbind(housedata$longitude[obs],housedata $latitude[obs]), + cbind(housedata$longitude,housedata $latitude))) ## b=.3 # this is the relevant distance threshold housedata$w - 0 # generate a weights variable housedata$w[Dib] - 1 # give all observations closer than b a weight of 1 print(which(housedata$w0)) # this tells me which observations are included in this regression [1] 333 336 340 345 346 376 378 406 414 418 419 425 426 427 428 429 430 431 [19] 436 438 441 444 450 451 456 457 458 461 462 463 464 465 467 468 469 470 [37] 471 474 475 476 479 481 483 488 494 496 508 512 514 518 525 526 528 530 [55] 531 533 538 539 544 548 563 572 576 584 585 587 591 594 595 600 601 607 [73] 613 615 616 617 618 624 631 637 638 641 645 647 652 653 654 655 656 659 [91] 663 678 681 685 688 689 691 693 694 711 712 # run the linear regression only including the observations within the distance threshold result.b - lm(adjprice~lotsize+squareft+garagesqft +numbath+numbed+time, + data=housedata, + weights=w ) # collect the hat matrix print(lm.influence(result.b)$hat) # 345348352357358 389391 0.06332126 0.06332126 0.05592105 0.09368046 0.10605304 0.05592105 0.09757274 419427431432438 439440 0.03762151 0.10091480 0.04979739 0.05659565 0.05160888 0.03915642 0.10149422 441442443444449 451722 0.05572360 0.03086186 0.05624229 0.04658039 0.09087753 0.06436925 0.09952022 725731732737738 739742 0.08183102 0.06732644 0.05362610 0.04742278 0.05196055 0.02725287 0.03086186 743744745746748 749750 0.03848066 0.06161776 0.03352387 0.09729289 0.04968367 0.04588662 0.04620045 751752755756757 760762 0.08194437 0.07748418 0.20282956 0.05679513 0.05283027 0.08194437 0.05737857 764769775777789 793795 0.14753830 0.04742278 0.04409041 0.04675800 0.05739381 0.05739381 0.04125143 799806807809811 812814 0.11049178 0.05286319 0.04125143 0.13971558 0.03192842 0.04254609 0.06587966 819820825829844 853857 0.23414783 0.02942560 0.04627927 0.04968367 0.04968367 0.04627927 0.02689040 865866868872875 876881 0.10691998 0.09988275 0.06171944 0.08152409 0.11049178 0.04627927 0.05572857 882888894896897 898899 0.10646147 0.04149530 0.12769051 0.04092457 0.06117365 0.04092457 0.04316847 905912918919922 926928 0.17072235 0.04125143 0.06117365 0.14435872 0.04309004 0.06117365 0.05196055 933934935936937 940944 0.06065717 0.03094961 0.18271286 0.10755273 0.05196055 0.06117365 0.06117365 959962966969971 973975 0.13231524 0.06752826 0.06752826 0.06752826 0.06752826 0.06117365 0.06752826 976994995 0.04149530 0.04125143 0.06158475 I only noticed this problem
[R] Compiling Fortran Subroutines as R Shared Objects on Mac OS-X
Hello, I am trying to compile some F77 subroutines as shared objects for R on my Mac. -- Mac OS-X Version 10.4.11 (Tiger Intel Mac) I have done this (successfully) before on Sun Solaris and Linux Fedora systems using the following command. R CMD SHLIB myfile.f I have g77 installed from this page. http://hpc.sourceforge.net/ I am using R 2.8.1, and I have installed all 4 additional packages including gfortran. When I try to compile my subroutines (which worked on two other systems), I get the following error. (I have also tried a very simple subroutine and produced the same error message.) chad-r-bhattis-computer:~/MyR/Examples/Fortran/Test1 chadrbhatti$ R CMD SHLIB two.f gfortran -arch i386 -fPIC -g -O2 -c two.f -o two.o gcc -arch i386 -std=gnu99 -dynamiclib -Wl,-headerpad_max_install_names -mmacosx-version-min=10.4 -undefined dynamic_lookup -single_module -multiply_defined suppress -L/usr/local/lib -o two.so two.o -lgfortran -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation /usr/bin/libtool: for architecture cputype (16777223) cpusubtype (3) object: /usr/local/lib/libgfortran.dylib malformed object (unknown load command 4) /usr/bin/libtool: for architecture cputype (16777223) cpusubtype (3) object: /usr/local/lib/libgcc_s.10.4.dylib malformed object (unknown load command 4) make: *** [two.so] Error 1 chad-r-bhattis-computer:~/MyR/Examples/Fortran/Test1 chadrbhatti$ which g77 /usr/local/bin/g77 chad-r-bhattis-computer:~/MyR/Examples/Fortran/Test1 chadrbhatti$ which gfortran/usr/local/bin/gfortran Would anyone happen to understand this error? The words malformed object and cpusubtype concern me. Note: I am much more of a Unix user than administrator. I have very limited administrator knowledge and vocabulary. I appreciate any help. Many Thanks, Chad R. Bhatti __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rpad vs. Rapache
Dear R-experts- I'm attempting to evaluate Rpad and Rapache with the former already installed. When I run the latter using VMware, it tries to run on the default IP address assigned to Rpad. Not being facile in Apache, I am considering running both in parallel for a time and my question is do any users have experience running either (or both) of these applications using virtual IP names strictly for intranet access? Any pitfalls? TIA -- Vince Fulco, CFA, CAIA 612.424.5477 (universal) vful...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to use cubic spline coefficients from termstrc package?
Hi, I'm using the cubic splines from termstrc package. I invoked the splines_estim function with a group of 43 bonds. It computes 6 knot points and returns values for alpha1 to alpha7. My question is how to use these alpha1 to alpha7 in the equation of yield? For example, if I'm trying to find the yield at, say, 12.25 years, which falls between 3rd 4th knot points what should the formula (expectedly a cubic polynomial with coefficients from the alpha set) for the computation be? Any help is appreciated. Thanks, Chirantan Visit us at http://www.2pirad.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] savePlot error when type = eps or wmf
Hello, When I use savePlot(filename=xy,type=eps) or savePlot(filename=xy,type=wmf) , I get the following error: Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : Polygon edge not found (zero-width or zero-height?) This doesn't occur when I change the type to jpeg or bmp. Can anyone explain what is going on and how I can fix it? Your help is much appreciated, James -- View this message in context: http://www.nabble.com/savePlot-error-when-type-%3D-%22eps%22-or-%22wmf%22-tp23052307p23052307.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] Creating a graphics window (in Windows, with RGui) that is not constrained to the RGui Window
Hi, all, Using RGui, is it possible to create a graphics window that can be moved outside of the RGui window? (This can be done--in fact must be done--using Rterm, but I wish to use RGui.) My interest for this is to use two monitors: in my private monitor I wish to execute R code in the Rgui window; in the public monitor I want the audience to see the results in the graphic window. Thanks, Joe Voelkel Rochester Institute of Technology __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Group by in R
On Mon, Apr 13, 2009 at 8:56 AM, Nick Angelou nikola...@yahoo.com wrote: data X1 X2 X3 X4 1 1 2 2 1 2 1 1 2 2 3 1 1 2 2 4 2 2 1 2 5 1 1 2 2 6 2 2 1 2 7 1 1 2 1 8 2 2 1 2 9 1 2 1 1 10 1 1 2 2 sqldf(select X1, X2, X3, X4, count(*) CNT from data group by X1, X2, X3, X4 ORDER BY X4, X1, X2, X3) X1 X2 X3 X4 CNT 1 1 1 2 1 1 2 1 2 1 1 1 3 1 2 2 1 1 4 1 1 2 2 4 5 2 2 1 2 3 The counts are fine, though it's not exactly what I need. I need a kind of contingency table: | levels of X4 | --- unique triplets of X1:X3 | 1 | 2 | - 1 1 1 | 0 0 1 1 2 | 1 4 1 2 1 | 1 0 1 2 2 | 1 0 2 1 1 | 0 0 2 1 2 | 0 0 2 2 1 | 0 3 2 2 2 | 0 0 So the final result should be a table structure like: 0 0 1 4 1 0 1 0 0 0 0 0 0 3 0 0 I propose this way to get the numbers you want. I create a new variable to represent the values of the three then make a table: md - matrix(c(1,2,2,1,1,1,2,2,1,1,2,2,2,2,1,2,1,1,2,2,2,2,1,2,1,1,2,1,2,2,1,2,1,2,1,1,1,1,2,2),ncol=4) dat - as.data.frame(md) names(dat)- c(x1,x2,x3,x4) newvar - factor(paste(dat$x1,dat$x2,dat$x3,sep=-)) table(newvar, dat$x4) Behold: table(newvar, dat$x4) newvar 1 2 1-1-1 1 0 1-2-1 1 0 1-2-2 1 3 2-1-1 1 0 2-1-2 1 0 2-2-1 1 0 2-2-2 0 1 -- Paul E. Johnson Professor, Political Science 1541 Lilac Lane, Room 504 University of Kansas __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] excluding a column from a data frame
Dear R People: Suppose I have the following data frame: x1 x2 x3 1 -0.1582116 0.06635783 1.765448 2 -1.1407422 0.47235664 0.615931 3 0.8702362 2.32301341 2.653805 str(xx) 'data.frame': 3 obs. of 3 variables: $ x1: num -0.158 -1.141 0.87 $ x2: num 0.0664 0.4724 2.323 $ x3: num 1.765 0.616 2.654 I can exclude the second column nicely via: xx[,-2] x1 x3 1 -0.1582116 1.765448 2 -1.1407422 0.615931 3 0.8702362 2.653805 Now suppose I wanted to exclude the column called x2. If I try: xx[,-x2] Error in -x2 : invalid argument to unary operator things don't work. Is there a simple way to do this by name rather than number, please? Thanks, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] excluding a column from a data frame
Tena koe Erin xx[, names(xx)!='x2'] HTH Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erin Hodgess Sent: Wednesday, 15 April 2009 5:39 p.m. To: R help Subject: [R] excluding a column from a data frame Dear R People: Suppose I have the following data frame: x1 x2 x3 1 -0.1582116 0.06635783 1.765448 2 -1.1407422 0.47235664 0.615931 3 0.8702362 2.32301341 2.653805 str(xx) 'data.frame': 3 obs. of 3 variables: $ x1: num -0.158 -1.141 0.87 $ x2: num 0.0664 0.4724 2.323 $ x3: num 1.765 0.616 2.654 I can exclude the second column nicely via: xx[,-2] x1 x3 1 -0.1582116 1.765448 2 -1.1407422 0.615931 3 0.8702362 2.653805 Now suppose I wanted to exclude the column called x2. If I try: xx[,-x2] Error in -x2 : invalid argument to unary operator things don't work. Is there a simple way to do this by name rather than number, please? Thanks, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] excluding a column from a data frame
Alternatively you could also drop the column like this: xx$x2-NULL On Wed, Apr 15, 2009 at 15:51, Peter Alspach palsp...@hortresearch.co.nz wrote: Tena koe Erin xx[, names(xx)!='x2'] HTH Peter Alspach -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Erin Hodgess Sent: Wednesday, 15 April 2009 5:39 p.m. To: R help Subject: [R] excluding a column from a data frame Dear R People: Suppose I have the following data frame: x1 x2 x3 1 -0.1582116 0.06635783 1.765448 2 -1.1407422 0.47235664 0.615931 3 0.8702362 2.32301341 2.653805 str(xx) 'data.frame': 3 obs. of 3 variables: $ x1: num -0.158 -1.141 0.87 $ x2: num 0.0664 0.4724 2.323 $ x3: num 1.765 0.616 2.654 I can exclude the second column nicely via: xx[,-2] x1 x3 1 -0.1582116 1.765448 2 -1.1407422 0.615931 3 0.8702362 2.653805 Now suppose I wanted to exclude the column called x2. If I try: xx[,-x2] Error in -x2 : invalid argument to unary operator things don't work. Is there a simple way to do this by name rather than number, please? Thanks, Erin -- Erin Hodgess Associate Professor Department of Computer and Mathematical Sciences University of Houston - Downtown mailto: erinm.hodg...@gmail.com __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. The contents of this e-mail are confidential and may be subject to legal privilege. If you are not the intended recipient you must not use, disseminate, distribute or reproduce all or any part of this e-mail or attachments. If you have received this e-mail in error, please notify the sender and delete all material pertaining to this e-mail. Any opinion or views expressed in this e-mail are those of the individual sender and may not represent those of The New Zealand Institute for Plant and Food Research Limited. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.