[R] How to set default plotting colors by treatment?
Dear R-helpers, I have a number of dataframes that looks something like this: mydfr - data.frame(treatment=c(rep(A,3),rep(B,3)), Xmeas=1:6, Ymeas=c(2,4,3,3,5,6)) # except with many more variables, which I plot all the time colored by treatment to quickly check things: with(mydfr, plot(Xmeas, Ymeas, pch=19, col=c(blue,red)[treatment])) # I find it annoying to keep typing in all the bits after Ymeas (yes I use a text editor but that's not the point...) # I tried defining a function like this myplot - function(...)plot(..., pch=19, col=c(blue,red)[treatment]) # So i can call it like this: with(mydfr, myplot(Xmeas, Ymeas)) # but: Error in plot.xy(xy, type, ...) : object 'treatment' not found I don't understand why the 'with' statement does not allow the 'myplot' function to find the 'treatment' variable (after all, it finds the other variables just fine). Can someone explain why this is, and how to fix this? thanks for your help Remko - Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.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] How to get last day of a month?
jim holtman wrote: just use timeDate from Rmetrics, there you will find several functions like ... # timeLastDayInMonthComputes the last day in a given month and year # timeFirstDayInMonth Computes the first day in a given month and year # timeLastDayInQuarter Computes the last day in a given quarter and year # timeFirstDayInQuarter Computes the first day in a given quarter and year # timeNthNdayInMonthComputes n-th ocurrance of a n-day in year/month # timeLastNdayInMonth Computes the last n-day in year/month and many more ... Diethelm Wuertz Does this help. Shows how to use the basic functions to get at the answer: # add first day of month to make it valid x - as.POSIXct(paste('1', 'sep2009', sep=''), format=%d%b%Y) # now advance one month and then go back one day for the end of the month next.mon - seq(x, length=2, by='1 month')[2] last.day - seq(next.mon, length=2, by='-1 day')[2] last.day [1] 2009-09-30 GMT On Sun, Sep 13, 2009 at 2:18 PM, megh megh700...@yahoo.com wrote: Is there any R function to calculate automatically the last day of a particular month? For example sep2009 should be converted to last day of September of 2009? Thanks -- View this message in context: http://www.nabble.com/How-to-get-last-day-of-a-month--tp25425645p25425645.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [R-pkgs] New package: tikzDevice
This is to announce the first release of the tikzDevice package on CRAN. The package should be migrating to your mirror soon. The tikzDevice package provides a new graphics device for R which enables direct output of graphics in a LaTeX-friendly way. Please see the original posting on R-Forge for all the release details: http://r-forge.r-project.org/forum/forum.php?forum_id=1596 Enjoy! - The tikzDevice Team [[alternative HTML version deleted]] ___ R-packages mailing list r-packa...@r-project.org https://stat.ethz.ch/mailman/listinfo/r-packages __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Exporting Numerous Graphs
Hi all, I have got 27 graphs to export (not a lot...I know!). How can I fit all of them into a single file like PNG without adjusting the size of the graphs? What's in my mind is like pasting graphs into Word, in which I can just scroll down to view the graphs. Thanks for your attention. Much appreciated. Chris -- View this message in context: http://www.nabble.com/Exporting-Numerous-Graphs-tp25430649p25430649.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] Re current neural network (RNN) package?
Still need assistance with this topic, so if anybody knows, please reply! J_Laberga wrote: Hello, I'm trying to tackle a problem that would require the implementation of a recurrent NN. However, even though the CRAN is very big, I can’t seem to find a package for this. Does anybody here know if one exits? BR, John -- View this message in context: http://www.nabble.com/Recurrent-neural-network-%28RNN%29-package--tp25116968p25431089.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] setting plotting device
Hi All, I have recently *re*-installed R-2.9.1 in my Linux machine. Since then, I am unable to plot using the usual interactive device. plot(1:10) This plots in a pdf file Rplots.pdf in my working directory. sessionInfo() R version 2.9.1 (2009-06-26) i686-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base dev.cur() null device 1 capabilities(what = NULL) jpeg png tifftcltk X11 aqua http/ftp sockets FALSEFALSEFALSEFALSEFALSEFALSE TRUE TRUE libxml fifo clediticonv NLS profmemcairo TRUE TRUE TRUE TRUE TRUEFALSEFALSE dev.interactive() [1] FALSE Before re-installation, everything was working perfectly. Please suggest, how do I set the interactive device as default? Thank in advance, Regards, Utkarsh [[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] RPostgreSQL package and libpq.dll file
It still doesn't work. Now, R is asking me for the SSLEAY32.dll. If I download it from the internet, and then put it in the file \R-2.8.1\library\RPostgreSQL\libs, now they ask me for the VSINIT.dll file ! it's like an infinite loop... I've tried to intall again the RPostgreSQL library but nothing's changed. I don't understand because Postgres is fine, it works. Should I install it again ? :s Thanks everyone. Date: Fri, 11 Sep 2009 08:21:59 -0700 From: m...@joeconway.com To: tchiba...@hotmail.com CC: r-help@r-project.org Subject: Re: [R] RPostgreSQL package and libpq.dll file Lore M wrote: Dear all, I'd like to use the package RPostgreSQL. I'm using R version 2.8.1 and I've download the last version RPostgreSQL. When I load the package, I get something like the file LIBPQ.DLL is missing. Do you have any idea about what I'm suppose to do ? Thanks everyone. libpq.dll is the PostgreSQL client library. You should be able to get it here: http://www.postgresql.org/download/windows HTH Joe _ [[elided Hotmail spam]] [[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] How to set default plotting colors by treatment?
# I tried defining a function like this myplot - function(...)plot(..., pch=19, col=c(blue,red)[treatment]) # So i can call it like this: with(mydfr, myplot(Xmeas, Ymeas)) # but: Error in plot.xy(xy, type, ...) : object 'treatment' not found basically that is something like calling: myplot( mydfr$Xmeas, mydfr$Ymeas ) So plot doesn't know that treatment is within mydfr... changing your function to: myplot - function(...) { plot(..., pch=19, col=c(blue,red)mydfr$[treatment] ) } should work? This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Exporting Numerous Graphs
I have got 27 graphs to export (not a lot...I know!). How can I fit all of them into a single file like PNG without adjusting the size of the graphs? What's in my mind is like pasting graphs into Word, in which I can just scroll down to view the graphs. Pretty sure PNG can only cope with single 'page' images - the page can be as big as it wants but then when it comes to things like printing its gonna cause problems as I doubt many graphics packages can split it over the page? So they'll either crop it or scale it. 27 on 1 page is gonna be very small? TIFF can handle multiple pages and of course so can PDF. I don't know of an export to TIFF function. So I'd suggest exporting to PDF - and exporting to 27 different file names (1 to 27.pdf) Then using a tool like pdfshuffler (linux GUI based) or using command line ghostscript (windows or linux) gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf 1.pdf 2.pdf 3.pdf ...etc... 27.pdf (This is a linux command not a R command. The widnwos version will be very simillar I suspect) That'd give you a 27 page pdf file with each graph on a new page? Much easier to scroll through than using a scroll bar on a graphics package - you can go back to Page 5 and on to page 9 to compare quickly rather than having to manually scroll to find the right info. Plus PDF is vector based which means future importing into decent desktop publishing packages should avoid and issues with loss / scaling. I believe its also possible with psmerge using postscript and so possible EPS files. This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] merging two rpart objects
Hi All, I am using rpart function to model my data: library(rpart) set.seed(1) x1 = sample(c(a,b),100,T) x2 = runif(100) y = ifelse((x1==a x2=0.5)|(x1==b x20.5), 0, 1) data = data.frame(x1,x2,y) fit = rpart(y~x1+x2) plot(fit); text(fit, use.n=TRUE) Now I want to use variable x1 for the first split. I thought of the following three ways of doing so, but none is complete: 1) Is there any way I can fix the variable used for the first split? (Or it will be great if I can fix the variable used for any particular split.) 2) If I have the data and I also have some classification rule, is there any way I can convert my rule into an rpart object? (so that I can use it for plotting the tree and to predict on some new data) For example: If I want my rule for prediction to be: y = if (x1==a and x2=0.5) or (x1==b and x20.5) then 0, otherwise 1 How do I get the corresponding rpart object? 3) If I split my data according to the desired variable and fit different cart models on both the datas: spl = split(data,data$x1) fit1 = rpart(y~x1,data=data, control=list(cp=0.1,maxdepth=1)) fit2 = rpart(y~x2, data=spl[[1]]) fit3 = rpart(y~x2, data=spl[[2]]) Is there any way I can merge fit1, fit2 and fit3 in a single rpart object? (so that I can use it for plotting the tree and to predict on some new data) Answer to any of the three above will solve my purpose. Any hints can be helpful. Thanks in advance, Regards, Utkarsh __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Exporting Numerous Graphs
Hi, It's probably easiest with the pdf (or postscript) device, pdf(all.pdf) for(ii in 1:27) plot(rnorm(10), main=paste(plot, ii)) dev.off() Bitmap-based devices can generate sequential filenames (Rplot1.png, Rplot2.png, ...) that you could combine in a single document using external tools (e.g. a pdf file with latex, or an html template that you can view in a browser, etc.). For example, create the following file template.brew, !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd; html lang=en head meta http-equiv=content-type content=text/html; charset=utf-8 titletitle/title link rel=stylesheet type=text/css href=style.css script type=text/javascript src=script.js/script /head body % for (ii in 1:27) { filename - paste(plot,ii, .png, sep=) png(filename) plot(rnorm(10), main=paste(plot, ii)) dev.off() % pimg src=% cat(filename) % p/ % } % /body /html and process it in R using, library(brew) brew(template.brew, template.html) HTH, baptiste 2009/9/14 Polwart Calum (County Durham and Darlington NHS Foundation Trust) calum.polw...@nhs.net I have got 27 graphs to export (not a lot...I know!). How can I fit all of them into a single file like PNG without adjusting the size of the graphs? What's in my mind is like pasting graphs into Word, in which I can just scroll down to view the graphs. Pretty sure PNG can only cope with single 'page' images - the page can be as big as it wants but then when it comes to things like printing its gonna cause problems as I doubt many graphics packages can split it over the page? So they'll either crop it or scale it. 27 on 1 page is gonna be very small? TIFF can handle multiple pages and of course so can PDF. I don't know of an export to TIFF function. So I'd suggest exporting to PDF - and exporting to 27 different file names (1 to 27.pdf) Then using a tool like pdfshuffler (linux GUI based) or using command line ghostscript (windows or linux) gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=merged.pdf 1.pdf 2.pdf 3.pdf ...etc... 27.pdf (This is a linux command not a R command. The widnwos version will be very simillar I suspect) That'd give you a 27 page pdf file with each graph on a new page? Much easier to scroll through than using a scroll bar on a graphics package - you can go back to Page 5 and on to page 9 to compare quickly rather than having to manually scroll to find the right info. Plus PDF is vector based which means future importing into decent desktop publishing packages should avoid and issues with loss / scaling. I believe its also possible with psmerge using postscript and so possible EPS files. This message may contain confidential information. If ...{{dropped:29}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to set default plotting colors by treatment?
Hi, Using ggplot2, you could do something like this, library(ggplot2) myplot - function(x, y, data, geom=point){ ggplot(data=data, map=aes_string(x=x, y=y, colour = treatment) ) + layer(geom=geom) + scale_colour_manual(values=c(red, blue)) } d = data.frame(Xmeas=rnorm(10), Ymeas=rnorm(10), treatment=factor(sample(letters[1:2], 10, TRUE))) myplot(x=Xmeas, y=Ymeas, data=d) + # adding custom specifications aes_string(size=treatment) + ylab(this is my label) + theme_bw() HTH, baptiste 2009/9/14 Polwart Calum (County Durham and Darlington NHS Foundation Trust) calum.polw...@nhs.net # I tried defining a function like this myplot - function(...)plot(..., pch=19, col=c(blue,red)[treatment]) # So i can call it like this: with(mydfr, myplot(Xmeas, Ymeas)) # but: Error in plot.xy(xy, type, ...) : object 'treatment' not found basically that is something like calling: myplot( mydfr$Xmeas, mydfr$Ymeas ) So plot doesn't know that treatment is within mydfr... changing your function to: myplot - function(...) { plot(..., pch=19, col=c(blue,red)mydfr$[treatment] ) } should work? This message may contain confidential information. If ...{{dropped:29}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Derivative of nonparametric curve
Thank you - Original Message From: spencerg spencer.gra...@prodsyse.com To: Liaw, Andy andy_l...@merck.com Cc: Rolf Turner r.tur...@auckland.ac.nz; FMH kagba2...@yahoo.com; r-help@r-project.org Sent: Wednesday, September 9, 2009 3:08:43 PM Subject: Re: [R] Derivative of nonparametric curve This may be overkill for your application, but you might be interested in the fda package, for which a new book appeared a couple of months ago: Functional Data Analysis with R and Matlab (Springer Use R! series, by Ramsay, Hooker and Graves; I'm the third author). The package includes a scripts subdirectory with R code to recreate all but one of the 76 figures in the book. [To find this scripts directory, use system.file('scripts', package='fda').] Functional data analysis generalizes spline smoothing in two important ways: (1) It supports the use of an arbitrary finite basis set to approximate elements of a function space; spline smoothing uses splines only, usually cubic splines. The first derivative of a cubic spline is piecewise quadratic, and the second derivative is piecewise linear. If you want something smoother than linear, you need at least a quartic spline, and Ramsay has recommended quintics -- degree 5 polynomials = order 6 spline. (2) It allows the curve to be smoothed using an arbitrary linear differential operator, not just the second derivative. This can be important if you have theory saying that the truth should follow a particular differential equation. Otherwise, if you want to estimate the second derivative, Ramsay has recommended smoothing with the fourth derivative rather than the second. (In any event, smoothing is achieved by penalized least squares with the penalty being proportional to the integral of the square of the chosen linear differential operator.) To reinforce this second point, chapter 11 of Functional Data Analysis with R and Matlab describes functional differential analysis, which will estimate non-constant coefficients in a differential equation model. Hope this helps. Spencer Graves Liaw, Andy wrote: From: Rolf Turner On 8/09/2009, at 9:07 PM, FMH wrote: Dear All, I'm looking for a way on computing the derivative of first and second order of a smoothing curve produced by a nonprametric regression. For instance, if we run the R script below, a smooth nonparametric regression curve is produced. provide.data(trawl) Zone92 - (Year == 0 Zone == 1) Position - cbind(Longitude - 143, Latitude) dimnames(Position)[[2]][1] - Longitude - 143 sm.regression(Longitude, Score1, method = aicc, col = red, model = linear) Could someone please give some hints on the way to find the derivative on the curve at some points ? See ?smooth.spline and ?predict.smooth.spline Since sm.regression() (from the sm package, I presume) uses kernel methods, a kernel-based estimator of derivatives is available in the KernSmooth package. Andy cheers, Rolf Turner ## Attention:\ This e-mail message is privileged and confid...{{dropped:9}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Notice: This e-mail message, together with any attachme...{{dropped:12}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Spencer Graves, PE, PhD President and Chief Operating Officer Structure Inspection and Monitoring, Inc. 751 Emerson Ct. San José, CA 95126 ph: 408-655-4567 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Color index in image function
Thank you From: Henrique Dallazuanna www...@gmail.com Cc: r-help@r-project.org Sent: Sunday, September 6, 2009 4:30:14 PM Subject: Re: [R] Color index in image function Try this to see which colors the codes are: Color - function(color){ z - matrix(1:length(color), ncol = length(color)) image(y = seq(1, length(color)), z, col = color, axes = FALSE) text(0, y = z, labels = color, pos = 1, offset = 0, cex = 0.7) } Color(topo.colors(5)) Color(terrain.colors(10)) You can use levelplot from lattice package too. Hi, Thank you for your response. I'm looking for the names of the colors denoted by these codes and what do these colors represent for. For instance, if we use topo.colors(5) in the image function, five different colors will be used in which its codes are denoted as: [1] #4C00 #004C #00E5 #00FF4DFF #00FF So, my first question is what type of color do these codes represent for? Are they white, red,...? My second question is, if we use this topo.colors(5) in image function to denote the temperature values for intance, what are these colors represent for? Does the first color, #4C00 represent the lower/medium/higher temperature? I do hope you could advice me on this matter? Thank you Fir - Original Message To: Steve Lianoglou mailinglist.honey...@gmail.com Sent: Sunday, September 6, 2009 3:41:02 PM Subject: Re: [R] Color index in image function Hi, Thank you for your response. I'm looking for the name of the colors denoted by this code and what are these colors representing for. For instance, if we use topo.colors(5) in the image function, five different colors will be used in which its codes are denoted as: [1] #4C00 #004C #00E5 #00FF4DFF #00FF So, my first question is what type of color does these codes represent for? Are they white, red,...? My second question is, if we use this topo.colors(5) in image function to denote the temperature values for intance, what are these colors represent for? Does the first color, #4C00 represent the lower/medium/higher temperature? I do hope you could advice me on this matter? Thank you Fir - Original Message From: Steve Lianoglou mailinglist.honey...@gmail.com Cc: r-help@r-project.org Sent: Sunday, September 6, 2009 3:20:25 PM Subject: Re: [R] Color index in image function Hi, Dear All, I was looking for the color index in image function, such as from topo.colors(n) and etc. but still never found it. For instance, from the help menu. The answer is in the code: ### # Volcano data visualized as matrix. Need to transpose and flip # matrix horizontally. image(t(volcano)[ncol(volcano):1,]) # A prettier display of the volcano x - 10*(1:nrow(volcano)) y - 10*(1:ncol(volcano)) image(x, y, volcano, col = terrain.colors(100), axes = FALSE) Right here: R terrrain.colors(100) [1] #00A600FF #03A700FF #07A800FF #0AAA00FF #0EAB00FF ... Is that what you mean? -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/%7Elianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Data in Array
Thank you - Original Message From: jim holtman jholt...@gmail.com To: FMH kagba2...@yahoo.com Cc: Schalk Heunis schalk.heu...@enerweb.co.za; r-help@r-project.org Sent: Tuesday, September 8, 2009 3:45:09 PM Subject: Re: [R] Data in Array Not sure what you mean by 'store', but you can use a list: a - matrix(1, nrow = 5, ncol = 1) b - matrix(2, nrow = 10, ncol = 1) c - matrix(3, nrow = 15, ncol = 1) myList - list(a, b, c) str(myList) List of 3 $ : num [1:5, 1] 1 1 1 1 1 $ : num [1:10, 1] 2 2 2 2 2 2 2 2 2 2 $ : num [1:15, 1] 3 3 3 3 3 3 3 3 3 3 ... myList[[2]] [,1] [1,] 2 [2,] 2 [3,] 2 [4,] 2 [5,] 2 [6,] 2 [7,] 2 [8,] 2 [9,] 2 [10,] 2 On Tue, Sep 8, 2009 at 8:14 AM, FMHkagba2...@yahoo.com wrote: Yes, but what actually i want to have is an array that might store these different matrices. - Original Message From: Schalk Heunis schalk.heu...@enerweb.co.za To: FMH kagba2...@yahoo.com Cc: r-help@r-project.org Sent: Tuesday, September 8, 2009 11:16:29 AM Subject: Re: [R] Data in Array have you tried rbind? On Tue, Sep 8, 2009 at 11:16 AM, FMHkagba2...@yahoo.com wrote: Dear All, I have some data which were stored in few matrices with different orders. Let have three different matrices a, b and c, which have the same number of column but different number of row. a - matrix(1, nrow = 5, ncol = 1) b - matrix(2, nrow = 10, ncol = 1) c - matrix(3, nrow = 15, ncol = 1) How could i put all these matrices in an array? Thank you Kagba __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- 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] acf gives correlations 1
Hi list, I've been producing autocorrelation functions of time series using the acf function, and have found a series or two for which correlations of 1 are given, which I think shouldn't happen. Attached is the time series I'm using, and below is the R code (version 2.9.1) that I'm entering: series - read.csv(series.csv) corr - acf(series, lag.max=90, na.action=na.pass, plot=T) The first few values of corr are below: 0 1.000 1 1.258 2 1.192 3 1.266 4 0.864 5 0.637 The entries of concern are 1-3 - surely these results are invalid? I'd be grateful if you could shed any light on this for me. Thanks in advance, Steve. signature.asc Description: OpenPGP digital signature __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to set default plotting colors by treatment?
col=c(blue,red)mydfr$[treatment] Yes, but I would like to use the function for lots of other dataframes as well, so embedding 'mydfr' in the function is not the ideal solution... remko - Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.com On Mon, Sep 14, 2009 at 6:08 PM, Polwart Calum (County Durham and Darlington NHS Foundation Trust) calum.polw...@nhs.net wrote: # I tried defining a function like this myplot - function(...)plot(..., pch=19, col=c(blue,red)[treatment]) # So i can call it like this: with(mydfr, myplot(Xmeas, Ymeas)) # but: Error in plot.xy(xy, type, ...) : object 'treatment' not found basically that is something like calling: myplot( mydfr$Xmeas, mydfr$Ymeas ) So plot doesn't know that treatment is within mydfr... changing your function to: myplot - function(...) { plot(..., pch=19, col=c(blue,red)mydfr$[treatment] ) } should work? This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Exporting Numerous Graphs
You can wite them out as single files (png('file-%02d.png',...)) and then import them to Word. On Mon, Sep 14, 2009 at 1:55 AM, Chris Li chri...@austwaterenv.com.au wrote: Hi all, I have got 27 graphs to export (not a lot...I know!). How can I fit all of them into a single file like PNG without adjusting the size of the graphs? What's in my mind is like pasting graphs into Word, in which I can just scroll down to view the graphs. Thanks for your attention. Much appreciated. Chris -- View this message in context: http://www.nabble.com/Exporting-Numerous-Graphs-tp25430649p25430649.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.
Re: [R] acf gives correlations 1
On 14/09/2009 6:40 AM, Steve Jones wrote: Hi list, I've been producing autocorrelation functions of time series using the acf function, and have found a series or two for which correlations of 1 are given, which I think shouldn't happen. Attached is the time series I'm using, and below is the R code (version 2.9.1) that I'm entering: series - read.csv(series.csv) corr - acf(series, lag.max=90, na.action=na.pass, plot=T) The first few values of corr are below: 0 1.000 1 1.258 2 1.192 3 1.266 4 0.864 5 0.637 The entries of concern are 1-3 - surely these results are invalid? I'd be grateful if you could shed any light on this for me. Your data file didn't show up. (Some attachments are stripped; it's better to include data inline.) 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] setting plotting device
utkarshsinghal wrote: Hi All, I have recently *re*-installed R-2.9.1 in my Linux machine. Hi, Did you use the package manager of you linux distro, or did you compile from source. cheers, Paul Since then, I am unable to plot using the usual interactive device. plot(1:10) This plots in a pdf file Rplots.pdf in my working directory. sessionInfo() R version 2.9.1 (2009-06-26) i686-pc-linux-gnu locale: LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=C;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C attached base packages: [1] stats graphics grDevices utils datasets methods base dev.cur() null device 1 capabilities(what = NULL) jpeg png tifftcltk X11 aqua http/ftp sockets FALSEFALSEFALSEFALSEFALSEFALSE TRUE TRUE libxml fifo clediticonv NLS profmemcairo TRUE TRUE TRUE TRUE TRUEFALSEFALSE dev.interactive() [1] FALSE Before re-installation, everything was working perfectly. Please suggest, how do I set the interactive device as default? Thank in advance, Regards, Utkarsh [[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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to set default plotting colors by treatment?
Remko Duursma wrote: col=c(blue,red)mydfr$[treatment] Yes, but I would like to use the function for lots of other dataframes as well, so embedding 'mydfr' in the function is not the ideal solution... The problem is that the info in 'treatment' is non-constant, and you need to either pass on the info into the scope of the function, or you need to calculate the values in 'treatment' inside the function. Could you provide us with a reproducible example (as suggested in the posting guide), that would make it much easier for us to answer you question veel succes! Paul remko - Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.com On Mon, Sep 14, 2009 at 6:08 PM, Polwart Calum (County Durham and Darlington NHS Foundation Trust) calum.polw...@nhs.net wrote: # I tried defining a function like this myplot - function(...)plot(..., pch=19, col=c(blue,red)[treatment]) # So i can call it like this: with(mydfr, myplot(Xmeas, Ymeas)) # but: Error in plot.xy(xy, type, ...) : object 'treatment' not found basically that is something like calling: myplot( mydfr$Xmeas, mydfr$Ymeas ) So plot doesn't know that treatment is within mydfr... changing your function to: myplot - function(...) { plot(..., pch=19, col=c(blue,red)mydfr$[treatment] ) } should work? This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to set default plotting colors by treatment?
The example is reproducible! Did you see the first post? remko - Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.com On Mon, Sep 14, 2009 at 9:19 PM, Paul Hiemstra p.hiems...@geo.uu.nl wrote: Remko Duursma wrote: col=c(blue,red)mydfr$[treatment] Yes, but I would like to use the function for lots of other dataframes as well, so embedding 'mydfr' in the function is not the ideal solution... The problem is that the info in 'treatment' is non-constant, and you need to either pass on the info into the scope of the function, or you need to calculate the values in 'treatment' inside the function. Could you provide us with a reproducible example (as suggested in the posting guide), that would make it much easier for us to answer you question veel succes! Paul remko - Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.com On Mon, Sep 14, 2009 at 6:08 PM, Polwart Calum (County Durham and Darlington NHS Foundation Trust) calum.polw...@nhs.net wrote: # I tried defining a function like this myplot - function(...)plot(..., pch=19, col=c(blue,red)[treatment]) # So i can call it like this: with(mydfr, myplot(Xmeas, Ymeas)) # but: Error in plot.xy(xy, type, ...) : object 'treatment' not found basically that is something like calling: myplot( mydfr$Xmeas, mydfr$Ymeas ) So plot doesn't know that treatment is within mydfr... changing your function to: myplot - function(...) { plot(..., pch=19, col=c(blue,red)mydfr$[treatment] ) } should work? This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] acf gives correlations 1
Apologies for the missing data. It can be downloaded from here (22Kb): http://www.squaregoldfish.co.uk/sekrett/series.csv Steve. Duncan Murdoch wrote: On 14/09/2009 6:40 AM, Steve Jones wrote: Hi list, I've been producing autocorrelation functions of time series using the acf function, and have found a series or two for which correlations of 1 are given, which I think shouldn't happen. Attached is the time series I'm using, and below is the R code (version 2.9.1) that I'm entering: series - read.csv(series.csv) corr - acf(series, lag.max=90, na.action=na.pass, plot=T) The first few values of corr are below: 0 1.000 1 1.258 2 1.192 3 1.266 4 0.864 5 0.637 The entries of concern are 1-3 - surely these results are invalid? I'd be grateful if you could shed any light on this for me. Your data file didn't show up. (Some attachments are stripped; it's better to include data inline.) Duncan Murdoch signature.asc Description: OpenPGP digital signature __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to set default plotting colors by treatment?
col=c(blue,red)mydfr$[treatment] Yes, but I would like to use the function for lots of other dataframes as well, so embedding 'mydfr' in the function is not the ideal solution... In that case I'd try something like: myplot - function(..., tmnt) { plot(..., pch=19, col=c(blue,red)[tmnt] ) } with(mydfr, myplot(Xmeas, Ymeas, tmnt=treatment)) That seems to work... - basically you just need to pass treatment in the function call... This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Sorting
On Sun, 2009-09-13 at 14:46 +0200, Erich Neuwirth wrote: months-c(jan,feb,mar,apr,may,jun, jul,aug,sep,oct,nov,dec) sortorder-order(as.numeric(date2[,2]),match(date2[,1],months)) To save some key strokes, the above can be done via: sortorder - order(as.numeric(date2[,2]), match(date2[,1], tolower(month.abb)) making use of the constant 'month.abb'. G date2[sortorder,] is probably what you want. megh wrote: I have following object : date2 [,1] [,2] [1,] apr 1992 [2,] aug 1992 [3,] dec 1992 [4,] feb 1992 [5,] jan 1992 [6,] jul 1992 [7,] jun 1992 [8,] mar 1992 [9,] may 1992 [10,] nov 1992 [11,] oct 1992 [12,] sep 1992 [13,] apr 1993 [14,] aug 1993 [15,] dec 1993 [16,] feb 1993 [17,] jan 1993 [18,] jul 1993 [19,] jun 1993 [20,] mar 1993 [21,] may 1993 [22,] nov 1993 [23,] oct 1993 [24,] sep 1993 [25,] apr 1994 [26,] aug 1994 [27,] dec 1994 [28,] feb 1994 [29,] jan 1994 [30,] jul 1994 Now I want to sort the elements like below, and want to get the index numbers of date2 under following sorting scheme. jan 1992 feb 1992 mar 1992 dec 1992 jan 1993 feb 1993 mar 1993 dec 1993 jan 1994 feb 1994 mar 1994 dec 1994 Can anyone help me please? -- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to set default plotting colors by treatment?
I offer my sincere apologies for not reading the e-mail carefully, your example is indeed reproducible. When you stop using the 'with' function, this is I think what you would like: myplot2 = function(formula, data, ...) { plot(formula, data = data, ..., pch = 19, col = c(blue,red)[data$treatment]) } myplot2(Ymeas~Xmeas, mydfr) A possible problem occurs when you want to redefine 'pch' or 'col', e.g.: myplot2(Ymeas~Xmeas, mydfr, pch = 20) Error in localWindow(xlim, ylim, log, asp, ...) : formal argument pch matched by multiple actual arguments cheers and hope this helps, Paul Remko Duursma wrote: The example is reproducible! Did you see the first post? remko - Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.com On Mon, Sep 14, 2009 at 9:19 PM, Paul Hiemstra p.hiems...@geo.uu.nl wrote: Remko Duursma wrote: col=c(blue,red)mydfr$[treatment] Yes, but I would like to use the function for lots of other dataframes as well, so embedding 'mydfr' in the function is not the ideal solution... The problem is that the info in 'treatment' is non-constant, and you need to either pass on the info into the scope of the function, or you need to calculate the values in 'treatment' inside the function. Could you provide us with a reproducible example (as suggested in the posting guide), that would make it much easier for us to answer you question veel succes! Paul remko - Remko Duursma Post-Doctoral Fellow Centre for Plants and the Environment University of Western Sydney Hawkesbury Campus Richmond NSW 2753 Dept of Biological Science Macquarie University North Ryde NSW 2109 Australia Mobile: +61 (0)422 096908 www.remkoduursma.com On Mon, Sep 14, 2009 at 6:08 PM, Polwart Calum (County Durham and Darlington NHS Foundation Trust) calum.polw...@nhs.net wrote: # I tried defining a function like this myplot - function(...)plot(..., pch=19, col=c(blue,red)[treatment]) # So i can call it like this: with(mydfr, myplot(Xmeas, Ymeas)) # but: Error in plot.xy(xy, type, ...) : object 'treatment' not found basically that is something like calling: myplot( mydfr$Xmeas, mydfr$Ymeas ) So plot doesn't know that treatment is within mydfr... changing your function to: myplot - function(...) { plot(..., pch=19, col=c(blue,red)mydfr$[treatment] ) } should work? This message may contain confidential information. If yo...{{dropped:21}} __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] acf gives correlations 1
G'day Steve, On Mon, 14 Sep 2009 13:44:56 +0200 Steve Jones st...@squaregoldfish.co.uk wrote: Apologies for the missing data. It can be downloaded from here (22Kb): http://www.squaregoldfish.co.uk/sekrett/series.csv Well, the Details section of acf's help page states: By default, no missing values are allowed. If the 'na.action' function passes through missing values (as 'na.pass' does), the covariances are computed from the complete cases. This means that the estimate computed may well not be a valid autocorrelation sequence, and may contain missing values. [...] And you have seem to have a massive amount of missing data: R dat - scan(url(http://www.squaregoldfish.co.uk/sekrett/series.csv;)) Read 6940 items R mean(!is.na(dat)) [1] 0.02881844 And, not surprisingly, an even smaller proportion of consecutive, non-missing observations. R mean(!is.na(dat[-1]) !is.na(dat[-length(dat)])) [1] 0.006340971 You can find out which formulae are used exactly by acf by studying the code, but this might give you an idea about what is going on: R ind - !is.na(dat) R (mu - mean(dat[ind])) ## too lazy for mean(dat, na.rm=TRUE) [1] 373.5165 R (sig2 - var(dat[ind])) ## ditto [1] 463.4041 R ind - which(!is.na(dat[-1]) !is.na(dat[-length(dat)])) R sum( (dat[ind]-mu) * (dat[ind+1] - mu)) / length(ind) [1] 593.3041 R sum( (dat[ind]-mu) * (dat[ind+1] - mu)) / length(ind) / sig2 [1] 1.280317 HTH Cheers, Berwin == Full address Berwin A Turlach Tel.: +61 (8) 6488 3338 (secr) School of Maths and Stats (M019)+61 (8) 6488 3383 (self) The University of Western Australia FAX : +61 (8) 6488 1028 35 Stirling Highway Crawley WA 6009e-mail: ber...@maths.uwa.edu.au Australiahttp://www.maths.uwa.edu.au/~berwin __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Exporting Numerous Graphs
Try this: library(RDCOMClient) w - COMCreate('Word.Application') w[[Visible]] - TRUE w[[DisplayAlerts]] - FALSE doc - w$Documents()$Add(Template=Normal, NewTemplate=FALSE, DocumentType=0) fooPasteGraphs - function(index, ...){ win.metafile() plot(rnorm(100)) dev.off() w$Selection()$Paste() } lapply(1:27, fooPasteGraphs) doc$SaveAs(FileName = graphs.doc, FileFormat = wdFormatDocument) doc$Close() w$Quit() doc - w - NULL rm(doc, w) On Mon, Sep 14, 2009 at 2:55 AM, Chris Li chri...@austwaterenv.com.auwrote: Hi all, I have got 27 graphs to export (not a lot...I know!). How can I fit all of them into a single file like PNG without adjusting the size of the graphs? What's in my mind is like pasting graphs into Word, in which I can just scroll down to view the graphs. Thanks for your attention. Much appreciated. Chris -- View this message in context: http://www.nabble.com/Exporting-Numerous-Graphs-tp25430649p25430649.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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Degrees of freedom etc- Fisher's
Hi When I run a Chi squared test in R I am automatically given the chi squared value and the degrees of freedom. How do I find these values when i've used Fisher's exact test? Cheers, Katie [[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] Analysis of a highly pseudoreplicate mixed-effects experiment
Hello everybody, I have been trying for some weeks to state the correct design of my experiment as a GLM formula, and have not been able to find something appropriate in Pinheiro Bates, so I am posting it here and hope somebody can help me. In each experimental condition, described by 1) gene (10 levels, fixed, because of high interest to me) 2) species (2 levels, fixed, because of high interest) 3) day (2 levels, random) 4) replicate (2 levels per day, random), I have several thousand data points consisting of two variables: 5) FITC (level of transfection of a cell) 6) APC (antibody binding to the cell) Because of intrinsic and uncontrollable cell-to-cell variation, FITC varies quite uniformly over a wide range, and APC correlates rather well with FITC. In some cases, I pasted day and replicate together as day_repl. My question is the following: Is there any gene (in my set of 10 genes) where the species makes a difference in the relation between FITC and APC ? If yes, in what gene does species have an effect ? And what is the effect of the species difference ? My attempts are the following: 1. Fit the data points of each experimental condition to a linear equation APC=Intercept+Slope*FITC and analyse the slopes : lm(Slope~species*gene*day_repl) This analysis shows clear differences between the genes, but no effect of species and no interaction gene:species. The linear fit to the cells is reasonably good, but of course does not represent the data set completely, so I wanted to incorporate the complete data set. 2a. lmer(APC~FITC*species*gene+(1|day)+(1|repl)) This gives extremely significant values for any interaction and variable because there are 200 000 df. Of course, it cannot be true, because the cells are not really independent. I have done many variations of the above, e.g. 2b. lmer(APC~FITC*species*gene+(1|day)+(1+FITC|day_repl)), but they all suffer from the excess of df. 3. lmer(APC~species*gene+(1|day/repl/FITC) gives several warning messages like this one: In repl:day : numerical expression has 275591 elements: only the first used 4. lmer(APC~gene*species+(1|day_repl) + (1+gene:species|FITC)) ran several days, but failed to converge... Can somebody give me any hint, or do you think the only possible analysis is a simplification as in my model 1 ? By the way, I am using R version 2.8.0 (2008-10-20) on Ubuntu 8.04 on a linux 2.6.24-24-generic kernel on different Intel systems. I am using the lme4 that came with R 2.8.0. Thank you very much for your time! -- Matthias Gralle, PhD Dept. Evolutionary Genetics Max Planck Institute for Evolutionary Anthropology Deutscher Platz 6 04103 Leipzig, Germany Tel +49 341 3550 519 Fax +49 341 3550 555 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] acf gives correlations 1
On 14/09/2009 7:44 AM, Steve Jones wrote: Apologies for the missing data. It can be downloaded from here (22Kb): http://www.squaregoldfish.co.uk/sekrett/series.csv The dataset is 97% missing values. I suspect what you're seeing is what the man page describes as follows: If the na.action function passes through missing values (as na.pass does), the covariances are computed from the complete cases. This means that the estimate computed may well not be a valid autocorrelation sequence, Duncan Murdoch Steve. Duncan Murdoch wrote: On 14/09/2009 6:40 AM, Steve Jones wrote: Hi list, I've been producing autocorrelation functions of time series using the acf function, and have found a series or two for which correlations of 1 are given, which I think shouldn't happen. Attached is the time series I'm using, and below is the R code (version 2.9.1) that I'm entering: series - read.csv(series.csv) corr - acf(series, lag.max=90, na.action=na.pass, plot=T) The first few values of corr are below: 0 1.000 1 1.258 2 1.192 3 1.266 4 0.864 5 0.637 The entries of concern are 1-3 - surely these results are invalid? I'd be grateful if you could shed any light on this for me. Your data file didn't show up. (Some attachments are stripped; it's better to include data inline.) 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-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Rstem package not available anymore?!?
Dear List, I tried installing the Rstem package from omegahat.org using my old command install.packages(Rstem, repos = http://www.omegahat.org/R;, type = source) but it seems omegahat.org is down. Any word on when it will be on again (if ever)? --- Sascha A. Wolfer, M.A. Centre for Cognitive Science Department for German Linguistics University of Freiburg http://portal.uni-freiburg.de/cognition/wolfer __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to set default plotting colors by treatment?
On Sep 14, 2009, at 8:00 AM, Paul Hiemstra wrote: I offer my sincere apologies for not reading the e-mail carefully, your example is indeed reproducible. When you stop using the 'with' function, this is I think what you would like: myplot2 = function(formula, data, ...) { plot(formula, data = data, ..., pch = 19, col = c(blue,red) [data$treatment]) } myplot2(Ymeas~Xmeas, mydfr) A possible problem occurs when you want to redefine 'pch' or 'col', e.g.: myplot2(Ymeas~Xmeas, mydfr, pch = 20) Error in localWindow(xlim, ylim, log, asp, ...) : formal argument pch matched by multiple actual arguments Generally one puts the defaults to arguments in the invocation section of the function myplot2 = function(formula, data, pch = 19,...) { plot(formula, data = data, ..., col = c(blue,red)) } myplot2(Ymeas~Xmeas, mydfr, pch = 20) # no error If you wanted to change the colors you could also use a construction like: ..., firstcol=red, seccol=blue, and then in the body of the function: ..., col=c(firstcol, seccol)[data$treatment] snip On Mon, Sep 14, 2009 at 6:08 PM, Polwart Calum (County Durham and Darlington NHS Foundation Trust) calum.polw...@nhs.net wrote: # I tried defining a function like this myplot - function(...)plot(..., pch=19, col=c(blue,red) [treatment]) # So i can call it like this: with(mydfr, myplot(Xmeas, Ymeas)) # but: Error in plot.xy(xy, type, ...) : object 'treatment' not found David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Degrees of freedom etc- Fisher's
On Sep 14, 2009, at 6:02 AM, Breach, Katherine wrote: Hi When I run a Chi squared test in R I am automatically given the chi squared value and the degrees of freedom. How do I find these values when i've used Fisher's exact test? The function fisher.test uses hypergeometric distribution functions, so it's not surprising that it does not report a chi-squared estimate. -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Announce: lme4 web application
inspired by useR! 2009, yeroon.net is a new project developing statistical web applications to make popular R packages easier available. A first version of the lme4 web interface is available at http://yeroon.net/lme4/ http://yeroon.net/lme4/ . It implements most lme4 features and some more. A short 2minute how-to demo video that illustrates how to use the application is available on youtube: http://www.youtube.com/watch?v=_OHps7z3Pqchd=1. More information and details are available on my website http://www.jeroenooms.com/lme4.html We hope you will give it a try, and that you like it. Any feedback/suggestions/bugreports are welcome of course. note: because this is a public demo server, R sessions are currently limited to 40seconds. If you experience timeouts, try again later (server can be busy). Thank you! Jeroen - Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University Visit http://www.jeroenooms.com www.jeroenooms.com to explore some of my current projects. -- View this message in context: http://www.nabble.com/Announce%3A-lme4-web-application-tp25435585p25435585.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] Teaching material for children...
Wondering if anyone is aware of resources appropriate for home schooled pre-teen/teen relatives? Before anyone suggests, a lengthy google search was unsuccessful. TIA, V. -- Vince Fulco, CFA, CAIA 612.424.5477 (universal) vful...@gmail.com A posse ad esse non valet consequentia “the possibility does not necessarily lead to materialization” __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Error: C stack usage is too close to the limit
R-help, I 'm trying to optimize a model to data using log-likelihoods but I encounter the following error message: l= c(49.4, 57.7,64.8,70.9,78.7,86.6,88.3,91.6,99,115) t=3:12 fn - function(params, l=l, t=t) { Linf - params[1] k - params[2] t0 - params[3] sigma - params[4] lhat - params[1]*(1-exp(-params[2]*(t-params[3]))) logL - -sum(dnorm(log(l),log(lhat),sqrt(sigma),TRUE)) return(logL) } resop - optim(c(120, .1, 0, 1), fn, method=L-BFGS-B,lower=c(0.0, 0.001, 0.001,0.01) + ,upper = rep(Inf, 4), hessian=TRUE, control=list(trace=1)) Error: C stack usage is too close to the limit Thanks in advance. Running R on a Windows XP machine version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 8.1 year 2008 month 12 day22 svn rev47281 language R version.string R version 2.8.1 (2008-12-22) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How do I ensure that the minimum value is always displayed on a y-axis in a plot?
Good day all, I'm trying to plot a figure and ensure that the minimum and maximum values are always displayed. However, the code below does not display the minimum value, no matter what I try. Could someone please help? Thanking you in advance, George. Code below for reproduction (apologies if the paste is too long) blah [1] 0.41955516 0.37330949 0.37934005 0.38013805 0.40092939 0.41809771 [7] 0.35506315 0.37619029 0.38832550 0.39542780 0.41286773 0.44871474 [13] 0.44615066 0.43361945 0.38145897 0.40604155 0.42088808 0.33563820 [19] 0.19898388 0.05405320 0.07195498 0.06063927 0.10984199 0.20232684 [25] 0.15127455 0.22510366 0.21140916 0.07260068 0.05777458 0.08828844 [31] 0.04021164 0.24469011 0.34492270 0.39574032 0.42518585 0.42548034 [37] 0.37197967 0.48975481 0.50734214 0.55670726 0.41196281 0.33531371 [43] 0.47829721 0.47731551 0.43365112 0.47014039 0.50725827 0.46507313 [49] 0.32546031 0.38638210 0.47445182 0.43344709 0.47184664 0.48753637 [55] 0.55147869 0.62923899 0.63642112 0.66178114 0.59527015 0.59549785 [61] 0.62225348 0.60587771 0.60169650 0.63869644 0.61497011 0.65405717 [67] 0.69497307 0.62576041 0.62001612 0.60824744 0.58845512 0.59354563 [73] 0.58475209 0.55517098 0.52625245 0.52072084 0.55999513 0.56649198 [79] 0.57620648 0.57745032 0.59226162 0.58934124 0.54486513 0.51508236 [85] 0.74226171 0.58931068 0.51018640 0.49098902 0.45596347 0.43259728 [91] 0.45967729 0.26489904 0.25191748 0.19439178 0.17408443 0.20808856 [97] 0.22975459 0.22893210 0.25564566 0.31440300 0.53385458 0.49516475 [103] 0.49393954 0.51413002 0.51550473 0.49094308 0.54652848 0.52330680 [109] 0.66077700 0.67473377 0.73252064 0.60095084 0.68951870 0.67420846 [115] 0.69349983 0.67653648 0.67111012 0.73809505 0.70304421 0.50431098 [121] 0.51570562 0.57064245 0.57074739 0.63965621 0.63229142 0.65723570 [127] 0.64391499 0.82621738 0.85068029 0.89709948 0.91123501 0.88550389 [133] 0.76118258 0.77473892 0.77503572 0.73966148 0.57395492 0.53487577 [139] 0.54431602 0.57154920 0.57202015 0.60106360 0.57827979 0.61068995 [145] 0.55431071 0.60882601 0.63072667 0.70043628 0.63970493 0.64275926 [151] 0.58062481 0.56941537 0.52262351 0.53100501 0.55272148 0.80326824 [157] 0.78036595 0.80721362 0.79298279 0.75516757 0.75579061 0.67656367 [163] 0.70496972 0.68608556 0.66523708 0.72524320 0.72008161 0.7194 [169] 0.66725266 0.75883243 0.74635191 0.54621226 0.65989640 0.77764740 [175] 0.65814792 1.00083188 1.02165546 0.94522872 0.90831836 0.88110308 [181] 0.89816588 0.89028173 0.94347223 0.98161240 0.98384939 0.94526478 [187] 0.97281886 0.98157746 0.96008129 0.96922374 0.97786087 0.99163911 [193] 0.99454825 0.97736352 0.99095124 0.92813285 0.93952818 0.98855307 [199] 0.98751104 1.00542472 1.00545473 1.02263743 1.01393869 1.03487649 [205] 1.04497946 1.02959214 0.98269728 1.01594502 1.02254283 1.00999491 [211] 1.03421722 0.82068414 0.78290122 0.82552434 0.77812239 0.73814563 [217] 0.73692711 0.71827498 0.66419647 0.57225762 0.52777201 0.59094474 [223] 0.63180748 0.60971980 0.61568132 0.59885033 0.58130928 0.54992662 [229] 0.53327994 0.52765513 0.53013986 0.60648203 0.62806366 0.56185943 [235] 0.57269468 0.54619305 0.53997574 0.49932167 0.52099655 0.57367695 [241] 0.55302045 0.55270828 0.59010362 0.59723936 0.58141465 0.57682344 [247] 0.58535031 0.58344239 0.59194913 0.59982716 0.66758340 0.72833184 [253] 0.72775151 0.79754621 0.81961383 0.89888747 0.86068598 0.84862423 [259] 0.84324231 0.86120500 0.3796 0.79363973 0.79360194 0.80167689 [265] 0.82430504 0.79068694 0.74700339 0.76740598 0.82838452 0.85449833 [271] 0.80523549 0.86915548 0.91917996 1.00838100 1.01711474 0.88572847 [277] 0.91220859 0.88790637 0.83414216 0.85770156 0.87551614 0.90779409 [283] 0.95448958 0.97048682 0.95669389 1.07568609 1.02615707 1.21670864 [289] 1.26424976 1.03758636 1.00911849 0.88467871 0.90480334 0.91616568 [295] 0.81912570 0.80111286 0.47223969 0.64554445 0.64264599 0.60489611 [301] 0.56542526 0.49117982 0.45614010 0.46773733 0.40172436 0.40196829 [307] 0.43754909 0.36359256 ylimits-range(c(blah,1.3)) plot(blah,type=l,yaxt=n,ann=FALSE,ylim=ylimits) b-ylimits[1] e-ylimits[2] tickMarks-round(tickMarks-seq(b,e,by=(e-b)/6),2) axis(2,las=2,at=tickMarks,labels=sprintf(%.2f,tickMarks)); __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] summary of rpart-Object in tktext window?
Hi, is it possible to put a summary of an rpart-Object into a tktext-window? Here is what I'm trying to do: fit - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis) tt - tktoplevel() tex - tktext(tt) tkpack(tex) tkinsert(tex, end, summary(fit)) But since the summary of an object is a list, I always get back the following error-message: cannot handle object of mode 'list' So, is there a different tk-window I should use for this kind of list or does anyone have an idea how to put the list into a tktext- window? Thanks for the help, -- Anne Skoeries [[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] linear regression, exclude a datum
Readers, I have been reading the r book (Crawley) and tried to use the influence measures function for linear regression, as described. I have one datum that I wish to show in the graph but exclude from the regression and ab line. x y 0 5 10 9 20 10 30 19 40 4 With the influence measures function I plot the graph but linear regression includes the datum (40,4), which I want to show on the graph but exclude from the linear regression ab line. Is there an alternative package to perform this task please? rhelp at conference.jabber.org r 251 mandriva 2008 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] summary of rpart-Object in tktext window?
Try this: tkinsert(tex, end, paste(capture.output(summary(fit)), collapse = \n)) On Mon, Sep 14, 2009 at 10:43 AM, Anne Skoeries h...@anne-skoeries.dewrote: Hi, is it possible to put a summary of an rpart-Object into a tktext-window? Here is what I'm trying to do: fit - rpart(Kyphosis ~ Age + Number + Start, data=kyphosis) tt - tktoplevel() tex - tktext(tt) tkpack(tex) tkinsert(tex, end, summary(fit)) But since the summary of an object is a list, I always get back the following error-message: cannot handle object of mode 'list' So, is there a different tk-window I should use for this kind of list or does anyone have an idea how to put the list into a tktext- window? Thanks for the help, -- Anne Skoeries [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] acf gives correlations 1
I misunderstood what the help page was saying - I thought that the missing values were what constituted the invalid function. Clearly I was mistaken. Looks like I'll have to compute the acf myself. Shame, but such is life. Thanks for the input, everyone! Steve. Berwin A Turlach wrote: G'day Steve, On Mon, 14 Sep 2009 13:44:56 +0200 Steve Jones st...@squaregoldfish.co.uk wrote: Apologies for the missing data. It can be downloaded from here (22Kb): http://www.squaregoldfish.co.uk/sekrett/series.csv Well, the Details section of acf's help page states: By default, no missing values are allowed. If the 'na.action' function passes through missing values (as 'na.pass' does), the covariances are computed from the complete cases. This means that the estimate computed may well not be a valid autocorrelation sequence, and may contain missing values. [...] And you have seem to have a massive amount of missing data: R dat - scan(url(http://www.squaregoldfish.co.uk/sekrett/series.csv;)) Read 6940 items R mean(!is.na(dat)) [1] 0.02881844 And, not surprisingly, an even smaller proportion of consecutive, non-missing observations. R mean(!is.na(dat[-1]) !is.na(dat[-length(dat)])) [1] 0.006340971 You can find out which formulae are used exactly by acf by studying the code, but this might give you an idea about what is going on: R ind - !is.na(dat) R (mu - mean(dat[ind])) ## too lazy for mean(dat, na.rm=TRUE) [1] 373.5165 R (sig2 - var(dat[ind])) ## ditto [1] 463.4041 R ind - which(!is.na(dat[-1]) !is.na(dat[-length(dat)])) R sum( (dat[ind]-mu) * (dat[ind+1] - mu)) / length(ind) [1] 593.3041 R sum( (dat[ind]-mu) * (dat[ind+1] - mu)) / length(ind) / sig2 [1] 1.280317 HTH Cheers, Berwin == Full address Berwin A Turlach Tel.: +61 (8) 6488 3338 (secr) School of Maths and Stats (M019)+61 (8) 6488 3383 (self) The University of Western Australia FAX : +61 (8) 6488 1028 35 Stirling Highway Crawley WA 6009e-mail: ber...@maths.uwa.edu.au Australiahttp://www.maths.uwa.edu.au/~berwin signature.asc Description: OpenPGP digital signature __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] mclustBIC version 3.3.1
Thanks! I just sent him an email. If anyone noticed any behavior change with this function version 3.3.1 please report any finding. Thanks in advance, Max Uwe Ligges-3 wrote: madmax1425 wrote: Hi there, I started getting a new error with the latest mclust package version 3.3.1. My only solution was to install the older package 3.2.1 or even 3.1-10. , (i think older ones will still work since i ve been using it for a while) the sentence giving trouble is: BIC - mclustBIC(as.vector(data), G = 1:3, modelNames=c(E)) Quite often i get missing groups suggesting the data is not appropriate for that clustering into 3 groups. I could not cast the results with NULL values in order to continue my process. Does anybody know anything about the new version of this function and how its effectiveness got reduced so drastically? Its functionalities seem to behave expanded handling noise etc etc as per changelog. Any ideas or workaround? Thanks a lot for the contribution in advance. Max If you think there is a bug please mail to the package maintainer and report your findings. Uwe Ligges __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- View this message in context: http://www.nabble.com/mclustBIC-version-3.3.1-tp25411550p25436098.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] linear regression, exclude a datum
Hi, On Sep 14, 2009, at 9:47 AM, e-letter wrote: Readers, I have been reading the r book (Crawley) and tried to use the influence measures function for linear regression, as described. I have one datum that I wish to show in the graph but exclude from the regression and ab line. x y 0 5 10 9 20 10 30 19 40 4 With the influence measures function I plot the graph but linear regression includes the datum (40,4), which I want to show on the graph but exclude from the linear regression ab line. Is there an alternative package to perform this task please? Please post the code you're using to try and do the regression. I think you simply want to remove the data point when you build the regression model, then plot it later after you plot the regression. Something like: model - lm(y ~ x, data=my.data[-5,]) ... plotting stuff ... If that doesn't make sense to you, please post some code we can comment on. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Luis Miguel Delgado Gomez/BBK está ausente d e la oficina.
Estaré ausente de la oficina desde el 14/09/2009 y no volveré hasta el 24/09/2009. Responderé a su mensaje cuando regrese. [[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] summary of rpart-Object in tktext window?
Thanks! That's it! Perfect! -- Anne Skoeries Olgastr. 54 74072 Heilbronn Phone: +49 (0)7131 - 390 33 33 Mobil: +49 (0)176 - 212 37 770 Mail: h...@anne-skoeries.de Am 14.09.2009 um 15:50 schrieb Henrique Dallazuanna: tkinsert(tex, end, paste(capture.output(summary(fit)), collapse = \n)) __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] SSVS
Hi, ALL, Is there any R/bioconductor package to do SSVS (stochastic search variable selection) for glm? Thanks, Cindy [[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] Location of Packages?
Hi, On Sep 14, 2009, at 12:03 PM, ivo welch wrote: Sorry, one more: on OSX, I deleted my old 2.9.2 R.app, and installed the 64 bit version of 2.9.0. I then did an install.packages(car) under my new 2.9.0. It seems to have worked, but alas, I still get an error that package 'car' was built under R version 2.9.2 . Where exactly does R under OSX install its packages? (is it a bug that another car is loaded?) /Library/Frameworks/R.framework/Resources/library/ You'll see that the Resources folder is actually a symlink to the current version's Resources folder: $ ls -l /Library/Frameworks/R.framework/Resources /Library/Frameworks/R.framework/Resources - Versions/Current/Resources And that the Current folder (in Versions/Current) is actually a symlink to the current version (answering your PPS question below). $ ls -l /Library/Frameworks/R.framework/Versions/Current /Library/Frameworks/R.framework/Versions/Current - 2.10 (2.10 because I'm running R-devel) PS: do I need to install the car packages under the 64-bit version, or will it be seen by the 64 bit version if I do a 32-bit install? If you are running R in 64 bit mode, you need a 64 bit install of the package (if it uses compiled code). Note that just because you downloaded a 64 bit version of R, you might not be running it in 64 bit mode by default. for safety, I did it under the command line version, which I presume is still 32-bit, and the 64 bit GUI. I don't understand what you're trying to say here. Assuming you have a 64 bit version of R, you can launch it in 64 bit mode from the terminal like so: $ R --arch x86_64 (That's on the http://r.research.att.com/ page, btw). PPS: how do I learn which version of R is running? Along with chasing down the symlinks to the Current version of (as stated above), when you start R, it will tell you in the preamble before the prompt is up. If you want to know if the version of R that's currently running is 64 vs. 32 bit, look at the size of the pointer: R .Machine$sizeof.pointer [1] 8 8 means 64 bit, 4 means 32 bit. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] problems with reshape
Hello * I would like to reshape wide the following dataset: rl - read.dta(intermedi/rapporti_lavoro.dta) [c(id_rl,prog,sil_pi,sil_cf,sil_dat_avv)] dim(rl) [1] 12964 5 object.size(rl) 1194728 bytes head(rl) id_rl prog sil_pi sil_cf sil_dat_avv 1 6381 04567XX NLMDRE64A5XX 2000-08-03 2 10331 54872XX FLGOIP66A3XX 2000-11-28 3 10432 56849XX QPWOER52E2XX 2000-07-07 4 15082 54982XX FJKLSD67P4XX 2000-12-12 5 15322 56849XX QWERTG50T0XX 2000-03-30 6 32831 12345XX POIQWE74H0XX 1999-12-31 Sil_cf and sil_pi are the idvar (sensible data too), prog is the timevar (now dataset is not sorted) sapply(rl, class) id_rlprog sil_pi sil_cf sil_dat_avv integer integer character character Date apply(rl, 2, function(x) sum(duplicated(x))) id_rlprog sil_pi sil_cf sil_dat_avv 0 1286369579886 10539 range(rl$prog) [1] 1 101 table(cut(rl$prog,5)) (0.9,20.9] (20.9,41](41,61] (61,81.1] (81.1,101] 12784 75 42 40 23 So i've scripted rl.wide - reshape(rl, idvar=c(sil_cf,sil_pi), timevar=prog, direction=wide) but after a biblic time I got something like Error: evaluation nested too deeply: infinite recursion. Any suggestion to perform that reshape? Many thanks Luca __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Teaching material for children...
http://jumpmath.org/program Looks good but no personal experience of it. --- On Mon, 9/14/09, Vince Fulco vful...@gmail.com wrote: From: Vince Fulco vful...@gmail.com Subject: [R] Teaching material for children... To: r-help@r-project.org Received: Monday, September 14, 2009, 9:17 AM Wondering if anyone is aware of resources appropriate for home schooled pre-teen/teen relatives? Before anyone suggests, a lengthy google search was unsuccessful. TIA, V. -- Vince Fulco, CFA, CAIA 612.424.5477 (universal) vful...@gmail.com A posse ad esse non valet consequentia “the possibility does not necessarily lead to materialization” __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 recode with an if-type statement
I'm sure this is easy, but I'm having a hard time figuring out how to recode some data in R. I have a variable numpeers which is valued 1, 2, or 3. I also have three other variables called w9zd9_1, w9zd9_2, and w9zd9_3. I want to use these variables to create a new item called distot. Specifically, here is what I want to do: -if numpeers=1, then distot=w9zd9_1 -if numpeers=2, then distot=(w9zd9_1 + w9zd9_2)/2 -if numpeers=3, then distot=(w9zd9_1 + w9zd9_2 + w9zd9_3)/3 Thanks, in advance, for the help! -- Casey A. Klofstad University of Miami Department of Political Science Coral Gables, FL klofs...@gmail.com http://www.as.miami.edu/personal/cklofstad/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Which apply function to use?
Dear All, I have a problem which *should* be pretty straightforward to resolve - but I can't work out how! I have a list of 3 coefficient estimates for 4 different datasets: Coefs-list(c(1,0.6,0.5),c(0.98,0.65,0.4),c(1.05,0.55,0.45),c(0.99,0.50,0.47)) All I want to do is take the sum (or mean) of each coefficient across the 4 datasets. I can do this using a for loop, but it gets very messy - as I need to do this several times I was hoping someone might have a better solution using one of the apply functions. Any ideas? Many thanks for any help you can provide. Cheers, Nick __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 graphing multiple lines of data
hey, On Mon, Sep 14, 2009 at 07:51:42AM -0700, John Kane wrote: p - ggplot(bmm, aes(x=age, y=bm, colour=pp, group=pp)) p - p + geom_line() remove the quotes and it will work: ggplot(bmm, aes(x=age, y=bm, colour=pp, group=pp))+geom_line() regards, Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] local sequence function
s == smu m...@z107.de on Mon, 14 Sep 2009 17:20:27 +0200 writes: s hey, I can not find a function for the following problem, s hopefully you can help me. s I have a vactor like this one s v = c(NA,NA,TRUE,TRUE,NA,TRUE,NA,TRUE,TRUE,TRUE) s and I would like to the TRUE values by the their local s sequence number. s This means, the result should look thike this: s c(NA,NA,1,2,NA,1,NA,1,2,3) s Of course I could solve the problems using a loop, but s this would be much to slow, because the real vector is s much larger. Can you point me in the right direction? direction? Ok, something along lapply(lapply(split(v, cumsum(is.na(v))), `[`, -1L), seq_along) $`1` integer(0) $`2` [1] 1 2 $`3` [1] 1 $`4` [1] 1 2 3 -- Martin Maechler, ETH Zurich __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] 64-bit OSX binary for 2.9.2
dear R wizards: I am looking for a binary package distribution of R 2.9.2 for OSX . Looking at http://r.research.att.com/ , there seems to be only a binary for 2.9.0 . is the 2.9.2 version binary package available somewhere? (at this point, would it make sense to elevate the 64-bit version to a standard recommended rather than just a boutique version?) sincerely, /iaw -- Ivo Welch (ivo.we...@brown.edu, ivo.we...@gmail.com) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] installation problem
wesley mathew wrote: Hello All I have some problem for installing XML_2.6-0.tar . I am working in widows and R version is R-2.9.1 *install.packages(XML)* After selecting a CRAN mirror ** *Error :-* Warning: unable to access index for repository http://cran.pt.r-project.org/bin/windows/contrib/2.9 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.9 Warning messages: 1: In open.connection(con, r) : unable to connect to 'cran.r-project.org' on port 80. 2: In getDependencies(pkgs, dependencies, available, lib) : package ‘XML’ is not available ** Looks like you have some network problem and cannot access the repositories. Ask you local administrator for help. *install.packages( c:/program files/R/XML_2.6-0.tar.gz, type=source, repos=NULL)* *Error :-* 'sh' is not recognized as an internal or external command, operable program or batch file. It is not straightforward nor very easy to install XML from sources. You'd need a) the tools for compiling packages from source and even then you'd need b) to have additional software such as the XML sources and need to adapt some files in the XML package. Uwe Ligges Thanks in advance for your help Kind Regards __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to refer to the last a few rows?
Try the tail() function -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peng Yu Sent: Monday, September 14, 2009 11:32 AM To: r-h...@stat.math.ethz.ch Subject: [R] How to refer to the last a few rows? Hi, x=matrix(1:60,nr=6) I can refer the last 2 rows by x[5:6,] If I don't know the total number of rows is 6, is there a way to refer the last 2 rows? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Location of Packages?
Sorry, one more: on OSX, I deleted my old 2.9.2 R.app, and installed the 64 bit version of 2.9.0. I then did an install.packages(car) under my new 2.9.0. It seems to have worked, but alas, I still get an error that package 'car' was built under R version 2.9.2 . Where exactly does R under OSX install its packages? (is it a bug that another car is loaded?) PS: do I need to install the car packages under the 64-bit version, or will it be seen by the 64 bit version if I do a 32-bit install? Or do I need to do a double install? for safety, I did it under the command line version, which I presume is still 32-bit, and the 64 bit GUI. PPS: how do I learn which version of R is running? regards, /iaw -- Ivo Welch (ivo.we...@brown.edu, ivo.we...@gmail.com) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Function Varcov in Design (Ver. 2.2-0) package
Hi, I'm running into an error message for the anova-function I never got before with the Design (Version 2.2-0) package. There seems to be a missing function Varcov, please check my function calls (it's in german but I think you get the error): library(Design)## attaching Design package and dependent packages Lade nötiges Paket: Hmisc ## loading dependent packages Lade nötiges Paket: survival Lade nötiges Paket: splines Attache Paket: 'Hmisc' The following object(s) are masked from package:survival : untangle.specials The following object(s) are masked from package:base : format.pval, round.POSIXt, trunc.POSIXt, units Design library by Frank E Harrell Jr Type library(help='Design'), ?Overview, or ?Design.Overview') to see overall documentation. Attache Paket: 'Design' The following object(s) are masked from package:Hmisc : strgraphwrap The following object(s) are masked from package:survival : Surv corr.lrm = lrm(CORRECTNESS ~ condition * type, data = data2) anova(corr.lrm) ## everything seemed to work fine, so run anova on the fitted model. Fehler in anova.Design(corr.lrm) : konnte Funktion Varcov nicht finden Error message translated: Error in anova.Design(model) : couldn't find function Varcov. Any ideas?! Thanks in advance! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Function Varcov in Design (Ver. 2.2-0) package
This is an error in the most recent Hmisc update. The authors promised to deliver another update that fixes this issue. Uwe Ligges Sascha Wolfer wrote: Hi, I'm running into an error message for the anova-function I never got before with the Design (Version 2.2-0) package. There seems to be a missing function Varcov, please check my function calls (it's in german but I think you get the error): library(Design)## attaching Design package and dependent packages Lade nötiges Paket: Hmisc## loading dependent packages Lade nötiges Paket: survival Lade nötiges Paket: splines Attache Paket: 'Hmisc' The following object(s) are masked from package:survival : untangle.specials The following object(s) are masked from package:base : format.pval, round.POSIXt, trunc.POSIXt, units Design library by Frank E Harrell Jr Type library(help='Design'), ?Overview, or ?Design.Overview') to see overall documentation. Attache Paket: 'Design' The following object(s) are masked from package:Hmisc : strgraphwrap The following object(s) are masked from package:survival : Surv corr.lrm = lrm(CORRECTNESS ~ condition * type, data = data2) anova(corr.lrm)## everything seemed to work fine, so run anova on the fitted model. Fehler in anova.Design(corr.lrm) : konnte Funktion Varcov nicht finden Error message translated: Error in anova.Design(model) : couldn't find function Varcov. Any ideas?! Thanks in advance! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] acf gives correlations 1
Hello On Mon, Sep 14, 2009 at 2:53 PM, Steve Jones st...@squaregoldfish.co.uk wrote: Looks like I'll have to compute the acf myself. Shame, but such is life. Wouldn't na.omit be an option? Liviu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Which apply function to use?
Hi, try this, rowMeans(as.data.frame(Coefs)) # or apply(as.data.frame(Coefs), 1, mean) HTH, baptiste 2009/9/14 Masca, N. nm...@leicester.ac.uk Dear All, I have a problem which *should* be pretty straightforward to resolve - but I can't work out how! I have a list of 3 coefficient estimates for 4 different datasets: Coefs-list(c(1,0.6,0.5),c(0.98,0.65,0.4),c(1.05,0.55,0.45),c(0.99,0.50,0.47)) All I want to do is take the sum (or mean) of each coefficient across the 4 datasets. I can do this using a for loop, but it gets very messy - as I need to do this several times I was hoping someone might have a better solution using one of the apply functions. Any ideas? Many thanks for any help you can provide. Cheers, Nick __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 http://newton.ex.ac.uk/research/emag __ [[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] call for input
Hi, On Sep 14, 2009, at 11:48 AM, Martin Batholdy wrote: Hi, is there a way to make a call for an input at some point of a process ..? I don't know how to describe it well ... like; please enter your first name: and then, what is typed in should be saved into a variable. See: ?readline -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to refer to the last a few rows?
Hi, tail(x,2) or x[seq(nrow(x)-1, nrow(x)), ] HTH, baptiste 2009/9/14 Peng Yu pengyu...@gmail.com Hi, x=matrix(1:60,nr=6) I can refer the last 2 rows by x[5:6,] If I don't know the total number of rows is 6, is there a way to refer the last 2 rows? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 http://newton.ex.ac.uk/research/emag __ [[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] Teaching material for children...
Hello On Mon, Sep 14, 2009 at 2:17 PM, Vince Fulco vful...@gmail.com wrote: Wondering if anyone is aware of resources appropriate for home schooled pre-teen/teen relatives? There is http://r-tutor.com/, but it is for college students/beginners in stats. It would make sense to repost the question on r-sig-teaching. Liviu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] call for input
Hi, is there a way to make a call for an input at some point of a process ..? I don't know how to describe it well ... like; please enter your first name: and then, what is typed in should be saved into a variable. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Function Varcov in Design (Ver. 2.2-0) package
Please read r-help messages from 2 days ago that contain a simple work-around. Frank Sascha Wolfer wrote: Hi, I'm running into an error message for the anova-function I never got before with the Design (Version 2.2-0) package. There seems to be a missing function Varcov, please check my function calls (it's in german but I think you get the error): library(Design)## attaching Design package and dependent packages Lade nötiges Paket: Hmisc## loading dependent packages Lade nötiges Paket: survival Lade nötiges Paket: splines Attache Paket: 'Hmisc' The following object(s) are masked from package:survival : untangle.specials The following object(s) are masked from package:base : format.pval, round.POSIXt, trunc.POSIXt, units Design library by Frank E Harrell Jr Type library(help='Design'), ?Overview, or ?Design.Overview') to see overall documentation. Attache Paket: 'Design' The following object(s) are masked from package:Hmisc : strgraphwrap The following object(s) are masked from package:survival : Surv corr.lrm = lrm(CORRECTNESS ~ condition * type, data = data2) anova(corr.lrm)## everything seemed to work fine, so run anova on the fitted model. Fehler in anova.Design(corr.lrm) : konnte Funktion Varcov nicht finden Error message translated: Error in anova.Design(model) : couldn't find function Varcov. Any ideas?! Thanks in advance! __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] local sequence function
Try this: v - c(NA,NA,TRUE,TRUE,NA,TRUE,NA,TRUE,TRUE,TRUE) ick -rle(v) foo - unlist(apply(matrix(ick$lengths),1,seq)) foo[is.na(v)] - NA foo [1] NA NA 1 2 NA 1 NA 1 2 3 -Don At 5:20 PM +0200 9/14/09, smu wrote: hey, I can not find a function for the following problem, hopefully you can help me. I have a vactor like this one v = c(NA,NA,TRUE,TRUE,NA,TRUE,NA,TRUE,TRUE,TRUE) and I would like to the TRUE values by the their local sequence number. This means, the result should look thike this: c(NA,NA,1,2,NA,1,NA,1,2,3) Of course I could solve the problems using a loop, but this would be much to slow, because the real vector is much larger. Can you point me in the right direction? thank you! regards, Stefan __ R-help@r-project.org mailing list https://*stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://*www.*R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 graphing multiple lines of data
Thanks to both of you. I knew it was something stupid. I just didn't realise it was that stupid. --- On Mon, 9/14/09, baptiste auguie baptiste.aug...@googlemail.com wrote: From: baptiste auguie baptiste.aug...@googlemail.com Subject: Re: [R] ggplot2 graphing multiple lines of data To: R R-help r-h...@stat.math.ethz.ch Received: Monday, September 14, 2009, 11:34 AM alternatively, use aes_string, p - ggplot(bmm, aes_string(x=age, y=bm, colour=pp, group=pp)) p - p + geom_line() p HTH, baptiste 2009/9/14 smu m...@z107.de hey, On Mon, Sep 14, 2009 at 07:51:42AM -0700, John Kane wrote: p - ggplot(bmm, aes(x=age, y=bm, colour=pp, group=pp)) p - p + geom_line() remove the quotes and it will work: ggplot(bmm, aes(x=age, y=bm, colour=pp, group=pp))+geom_line() regards, Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 http://newton.ex.ac.uk/research/emag __ [[alternative HTML version deleted]] -Inline Attachment Follows- __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] loading a package .Rda file at package load time
Hi, I have seen the answer to this sometime before but I just can't find it again - pointers appreciated. I have a package that contains some data.frames saved as .Rda files in the data/ directory. When the package is loaded I would like to have them be available in the workspace (without the user having to explicitly load them using data(...)). If my package does not use a NAMESPACE, I can place data(varName) in .First.lib. However if I use NAMESPACES then the above line will fail when placed in .onLoad. I was thinking of doing something such as load'filename.Rda') but that would require me to know the path to the package in a platform independent way. Can anybody suggest how I can acheive this? Thanks, -- Rajarshi Guha NIH Chemical Genomics Center [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Question about Factors
The suggestions from others to use lattice's xyplot, or ggplot2 are good. If you want an explicit loop you can do something like: for ( nm in unique(mydat$Name) ) { with( subset( mydf, Name==nm) , { plot(Time, Value, title=nm) readline('CR to continue ') } ) } At 5:19 PM -0700 9/13/09, Chris Li wrote: Hi all, I am new to R and I have got a question in regards to factors. Say I have a simple dataset like the following: Name Time Value a 1:00 1.25 a 2:00 1.26 b 1:00 1.29 b 2:00 1.28 c 1:00 1.21 c 1:30 1.20 c 2:00 1.23 I want to write a script that automatically plot value against time for a, b and c. Because I have got more than 1 datasets, therefore the name of the next dataset may consist d, e, h and g. So I will need a script that can detect the changes in Name automatically. Thank you very much for your time. Chris -- View this message in context: http://*www.*nabble.com/Question-about-Factors-tp25428665p25428665.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. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] installation problem
wesley mathew wrote: Hello All I have some problem for installing XML_2.6-0.tar . I am working in widows and R version is R-2.9.1 *install.packages(XML)* After selecting a CRAN mirror ** *Error :-* Warning: unable to access index for repository http://cran.pt.r-project.org/bin/windows/contrib/2.9 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.9 Warning messages: 1: In open.connection(con, r) : unable to connect to 'cran.r-project.org' on port 80. 2: In getDependencies(pkgs, dependencies, available, lib) : package ‘XML’ is not available ** Hi, Sounds like either: - The mirror is broken, try a few others - You are behind a proxy server, configure you machine to use the proxy server *install.packages( c:/program files/R/XML_2.6-0.tar.gz, type=source, repos=NULL)* *Error :-* 'sh' is not recognized as an internal or external command, operable program or batch file. This doesn't work in windows if you have not installed the Rtools (http://www.murdoch-sutherland.com/Rtools/). Try to install those first, or download and install the windows binary version. cheers, Paul Thanks in advance for your help Kind Regards __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 274 3113 Mon-Tue Phone: +3130 253 5773 Wed-Fri http://intamap.geo.uu.nl/~paul __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] local sequence function
Try this also: with(rle(v), unlist(sapply(lengths, FUN = seq)) * v) On Mon, Sep 14, 2009 at 12:20 PM, smu m...@z107.de wrote: hey, I can not find a function for the following problem, hopefully you can help me. I have a vactor like this one v = c(NA,NA,TRUE,TRUE,NA,TRUE,NA,TRUE,TRUE,TRUE) and I would like to the TRUE values by the their local sequence number. This means, the result should look thike this: c(NA,NA,1,2,NA,1,NA,1,2,3) Of course I could solve the problems using a loop, but this would be much to slow, because the real vector is much larger. Can you point me in the right direction? thank you! regards, Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Eliminate cases in a subset of a dataframe
Hi Holger, On Sep 14, 2009, at 10:57 AM, Hollix wrote: Hi folks, I created a subset of a dataframe (i.e., selected only men): subdata - subset(data,data$gender==1) After a residual diagnostic of a regression analysis, I detected three outliers: linmod - lm(y ~ x, data=subdata) plot(linmod) Say, the cases 11,22, and 33 were outliers. Here comes the problem: When I want to exclude these three cases in a further regression analysis, - for instance with linmod2 - lm(y[-c(11,22,33)] ~ x[-c(11,22,33)], data=subdata) - it does not work. I suspect that your x matrix is probably a 2d matrix, so you might need to do: R lm(y[-c(11,22,33)] ~ x[-c(11,22,33),] Note the trailing comma after the -c() vector when indexing into x! Perhaps you can just remove those rows from your data and keep your formula clean, like so? R linmod2 - lm(y ~ x, data=subdata[-c(11,22,33),]) I guess this has something to do with this strange row.names- vector which has been added to the dataframe when creating the subset. I find it very strange why R gives the case numbers in the diagnostics but then doesn't allow me to use these numbers for further exclusion. Hmm .. not sure what you mean, but this won't get in your way either way if you are using integers to index into your data.frame. Can anybody tell me: 1. what this row.names vector is 2. How I can refer to cases after creating a subset (e.g., in order to exclude them). Refer to them by their position in the data.frame as you would if you didn't create a subset. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Strange question/result about SVM
Hello, I have a very unusual situation with an SVM and wanted to get the group's opinion. We developed an experiment where we train the SVM with one set of data (train data) and then test with a completely independent set of data (test data). The results were VERY good. I found and error in how we generate one of or training variables. We discovered that it was indirectly influenced by future events. Clearly that needed to be fixed. Fixing the variable immediately changed our results from good to terrible. (Not a surprise since the erroneous variable had future influence.) A friend, who knows NOTHING of statistics or math, innocently asked, Why don't you just keep that variable since it seems to make your results so much better. The idea, while naive, led me to thinking. We can include future data in the training set, since it occurred in the past, but what to do with the test data from today? As a test, I tried simply setting the variable to the average of the value in the training data. The results were great! Now since the data is scaled, and we set the variable to the same value (constant from average of training data.) it scaled to 0. Still, great results. To summarize: Bad var in training + Bad var in testing = great results Good var in training + Good var in testing = bad results Bad var in training + Constant in testing = great results. I'm not an expert with the internals of the SVM, but clearly the bad variable is setting some kind of threshhold or intercept when defining the model. Can someone help me figure out why/how this is working? Thanks! -- N __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] 64-bit OSX binary for 2.9.2
On Sep 14, 2009, at 11:59 AM, Steve Lianoglou wrote: Hi, On Sep 14, 2009, at 11:44 AM, ivo welch wrote: dear R wizards: I am looking for a binary package distribution of R 2.9.2 for OSX . Looking at http://r.research.att.com/ , there seems to be only a binary for 2.9.0 . is the 2.9.2 version binary package available somewhere? (at this point, would it make sense to elevate the 64- bit version to a standard recommended rather than just a boutique version?) There isn't a *.pkg / *.dmg install for it, but it's there. In this section: Universal nightly builds for Mac OS X (10.4 Tiger and 10.5 Leopard) Third row in the table: http://r.research.att.com/R-2.9-branch-leopard-universal.tar.gz You have to inflate it at the root of your HD. The text right below the d/l table tells you how to do that: Alternatively you can use the tar-ball (*.tar.gz) which must be unpacked in the root (e.g. tar fvxz R*.tar.gz -C /), but doesn't contain the GUI (see below for a separate download). The problem may arise for *NIX-newbies ( a group in which I still claim membership) that they are unable to operationalize that message. For one thing they may not even know how to open a Terminal window. For another they may not know that the / at the end of that command will take care of unpacking at the root, so they will not need to navigate away from the place that they find themselves when Terminal opens up a bash session. The steps broken down would be something along these lines: First : Download the nightly build, and select Save to file rather than opening with Stuffit, and then it by default should end up in the user/Downloads/ folder. 1. a-c) Go to the Utilities folder of the Applications folder and double-click on Terminal.app 2. a) Go back to the browser and select the string: tar fvxz R*.tar.gz -C / (I would solicit some input here from more competent UNIXers regarding whether one would ever need to prefix this command with sudo.) 2. b) cmd-C to put it in the clipboard 2. c) click on the Terminal window and cmd-V to paste-in that command. 2 d) use the arrow and backspace keys (since mouse-clicking does not change the cursor position in Terminal sessions) to delete the R*.tar.gz on the command line. 3 a) Navigate with the Finder to the Downloads/ folder and locate the Rbuild. Click-drag that file to the Terminal window and unclick (or is it lift-click) when the pointer is at the place on the command line where the R*.tar.gz used to be. A full path version of the file name will get inserted (an no quotes are needed, unlike what one might expect after working in R regularly.) On my machine, one now sees this on the command line: tar fvxz /Users/davidwinsemius/Downloads/R-2.9-branch-leopard- universal.tar.gz -C / 4) Hit return Sit back and watch the show. You can the separately download the appropriate R-GUI and put in in the /Applications/ folder. You'll have to install the R.app GUI separately if you want to use the 2.9.2 install, otherwise I think the 2.9.0 *.pkg installer includes it, though I'm not sure. It does, In fact, it has both the 32 bit GUI and the 64 bit GUI. What I did was install that package _first_ which gave me 2.9.0 and then performed the steps above. You really would not want to do it in a reversed order, since you would be replacing R 2.9.2 with R 2.9.0. And of course this message _should_ have gone to r-sig-...@stat.math.ethz.ch and any follow up should trim the r-help address. -- David Winsemius, MD Heritage Laboratories West Hartford, CT __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] installation problem
wesley mathew wrote: Hello All I have some problem for installing XML_2.6-0.tar . I am working in widows and R version is R-2.9.1 Unfortunately, I think there are some problems with CRAN being able to build the XML package for Windows, at least the page: http://cran.r-project.org/web/packages/XML/index.html Lists it as unavailable. However, I know I have installed it on a Windows machine at the university using install.packages()-- R may be set up to pull from some additional repository there. I'll check the next time I'm in the lab. -Charlie - Charlie Sharpsteen Undergraduate Environmental Resources Engineering Humboldt State University -- View this message in context: http://www.nabble.com/installation-problem-tp25438411p25439211.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] How to refer to the last a few rows?
Hi, x=matrix(1:60,nr=6) I can refer the last 2 rows by x[5:6,] If I don't know the total number of rows is 6, is there a way to refer the last 2 rows? Regards, Peng __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How do I ensure that the minimum value is always displayed on a y-axis in a plot?
Try this: Assuming your vector is x: ylimits-c(min(x)- .05,max(x)+ .05) plot(x,type=l,yaxt=n,ann=FALSE,ylim=ylimits) By the way, if you are going to supply much data, it is better practice to use dput() . Try dput(x) to see what I mean. --- On Mon, 9/14/09, Jorgy Porgee jorgy.por...@gmail.com wrote: From: Jorgy Porgee jorgy.por...@gmail.com Subject: [R] How do I ensure that the minimum value is always displayed on a y-axis in a plot? To: r-help@r-project.org Received: Monday, September 14, 2009, 9:42 AM Good day all, I'm trying to plot a figure and ensure that the minimum and maximum values are always displayed. However, the code below does not display the minimum value, no matter what I try. Could someone please help? Thanking you in advance, George. Code below for reproduction (apologies if the paste is too long) blah [1] 0.41955516 0.37330949 0.37934005 0.38013805 0.40092939 0.41809771 [7] 0.35506315 0.37619029 0.38832550 0.39542780 0.41286773 0.44871474 [13] 0.44615066 0.43361945 0.38145897 0.40604155 0.42088808 0.33563820 [19] 0.19898388 0.05405320 0.07195498 0.06063927 0.10984199 0.20232684 [25] 0.15127455 0.22510366 0.21140916 0.07260068 0.05777458 0.08828844 [31] 0.04021164 0.24469011 0.34492270 0.39574032 0.42518585 0.42548034 [37] 0.37197967 0.48975481 0.50734214 0.55670726 0.41196281 0.33531371 [43] 0.47829721 0.47731551 0.43365112 0.47014039 0.50725827 0.46507313 [49] 0.32546031 0.38638210 0.47445182 0.43344709 0.47184664 0.48753637 [55] 0.55147869 0.62923899 0.63642112 0.66178114 0.59527015 0.59549785 [61] 0.62225348 0.60587771 0.60169650 0.63869644 0.61497011 0.65405717 [67] 0.69497307 0.62576041 0.62001612 0.60824744 0.58845512 0.59354563 [73] 0.58475209 0.55517098 0.52625245 0.52072084 0.55999513 0.56649198 [79] 0.57620648 0.57745032 0.59226162 0.58934124 0.54486513 0.51508236 [85] 0.74226171 0.58931068 0.51018640 0.49098902 0.45596347 0.43259728 [91] 0.45967729 0.26489904 0.25191748 0.19439178 0.17408443 0.20808856 [97] 0.22975459 0.22893210 0.25564566 0.31440300 0.53385458 0.49516475 [103] 0.49393954 0.51413002 0.51550473 0.49094308 0.54652848 0.52330680 [109] 0.66077700 0.67473377 0.73252064 0.60095084 0.68951870 0.67420846 [115] 0.69349983 0.67653648 0.67111012 0.73809505 0.70304421 0.50431098 [121] 0.51570562 0.57064245 0.57074739 0.63965621 0.63229142 0.65723570 [127] 0.64391499 0.82621738 0.85068029 0.89709948 0.91123501 0.88550389 [133] 0.76118258 0.77473892 0.77503572 0.73966148 0.57395492 0.53487577 [139] 0.54431602 0.57154920 0.57202015 0.60106360 0.57827979 0.61068995 [145] 0.55431071 0.60882601 0.63072667 0.70043628 0.63970493 0.64275926 [151] 0.58062481 0.56941537 0.52262351 0.53100501 0.55272148 0.80326824 [157] 0.78036595 0.80721362 0.79298279 0.75516757 0.75579061 0.67656367 [163] 0.70496972 0.68608556 0.66523708 0.72524320 0.72008161 0.7194 [169] 0.66725266 0.75883243 0.74635191 0.54621226 0.65989640 0.77764740 [175] 0.65814792 1.00083188 1.02165546 0.94522872 0.90831836 0.88110308 [181] 0.89816588 0.89028173 0.94347223 0.98161240 0.98384939 0.94526478 [187] 0.97281886 0.98157746 0.96008129 0.96922374 0.97786087 0.99163911 [193] 0.99454825 0.97736352 0.99095124 0.92813285 0.93952818 0.98855307 [199] 0.98751104 1.00542472 1.00545473 1.02263743 1.01393869 1.03487649 [205] 1.04497946 1.02959214 0.98269728 1.01594502 1.02254283 1.00999491 [211] 1.03421722 0.82068414 0.78290122 0.82552434 0.77812239 0.73814563 [217] 0.73692711 0.71827498 0.66419647 0.57225762 0.52777201 0.59094474 [223] 0.63180748 0.60971980 0.61568132 0.59885033 0.58130928 0.54992662 [229] 0.53327994 0.52765513 0.53013986 0.60648203 0.62806366 0.56185943 [235] 0.57269468 0.54619305 0.53997574 0.49932167 0.52099655 0.57367695 [241] 0.55302045 0.55270828 0.59010362 0.59723936 0.58141465 0.57682344 [247] 0.58535031 0.58344239 0.59194913 0.59982716 0.66758340 0.72833184 [253] 0.72775151 0.79754621 0.81961383 0.89888747 0.86068598 0.84862423 [259] 0.84324231 0.86120500 0.3796 0.79363973 0.79360194 0.80167689 [265] 0.82430504 0.79068694 0.74700339 0.76740598 0.82838452 0.85449833 [271] 0.80523549 0.86915548 0.91917996 1.00838100 1.01711474 0.88572847 [277] 0.91220859 0.88790637 0.83414216 0.85770156 0.87551614 0.90779409 [283] 0.95448958 0.97048682 0.95669389 1.07568609 1.02615707 1.21670864 [289] 1.26424976 1.03758636 1.00911849 0.88467871 0.90480334 0.91616568 [295] 0.81912570 0.80111286 0.47223969 0.64554445 0.64264599 0.60489611 [301] 0.56542526 0.49117982 0.45614010 0.46773733 0.40172436 0.40196829 [307] 0.43754909 0.36359256 ylimits-range(c(blah,1.3)) plot(blah,type=l,yaxt=n,ann=FALSE,ylim=ylimits) b-ylimits[1] e-ylimits[2] tickMarks-round(tickMarks-seq(b,e,by=(e-b)/6),2) axis(2,las=2,at=tickMarks,labels=sprintf(%.2f,tickMarks)); __ R-help@r-project.org mailing list
Re: [R] local sequence function
try the following: v - c(NA,NA,TRUE,TRUE,NA,TRUE,NA,TRUE,TRUE,TRUE) l - as.numeric(!is.na(v)) tmp - cumsum(l) tmp - cummax((!l) * tmp) I hope it helps. Best, Dimitris smu wrote: hey, I can not find a function for the following problem, hopefully you can help me. I have a vactor like this one v = c(NA,NA,TRUE,TRUE,NA,TRUE,NA,TRUE,TRUE,TRUE) and I would like to the TRUE values by the their local sequence number. This means, the result should look thike this: c(NA,NA,1,2,NA,1,NA,1,2,3) Of course I could solve the problems using a loop, but this would be much to slow, because the real vector is much larger. Can you point me in the right direction? thank you! regards, Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] Eliminate cases in a subset of a dataframe
linmod2 - update(linmod, data = subdata[-c(11,22,33),]) Hollix wrote: Hi folks, I created a subset of a dataframe (i.e., selected only men): subdata - subset(data,data$gender==1) After a residual diagnostic of a regression analysis, I detected three outliers: linmod - lm(y ~ x, data=subdata) plot(linmod) Say, the cases 11,22, and 33 were outliers. Here comes the problem: When I want to exclude these three cases in a further regression analysis, - for instance with linmod2 - lm(y[-c(11,22,33)] ~ x[-c(11,22,33)], data=subdata) - it does not work. I guess this has something to do with this strange row.names-vector which has been added to the dataframe when creating the subset. I find it very strange why R gives the case numbers in the diagnostics but then doesn't allow me to use these numbers for further exclusion. Can anybody tell me: 1. what this row.names vector is 2. How I can refer to cases after creating a subset (e.g., in order to exclude them). Many thanks in advance, Best, Holger -- James W. MacDonald, M.S. Biostatistician Douglas Lab University of Michigan Department of Human Genetics 5912 Buhl 1241 E. Catherine St. Ann Arbor MI 48109-5618 734-615-7826 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Eliminate cases in a subset of a dataframe
At a quick glance, your code seems to be deleting columns not rows try y[-c(11,22,33), ] --- On Mon, 9/14/09, Hollix holger.steinm...@web.de wrote: From: Hollix holger.steinm...@web.de Subject: [R] Eliminate cases in a subset of a dataframe To: r-help@r-project.org Received: Monday, September 14, 2009, 10:57 AM Hi folks, I created a subset of a dataframe (i.e., selected only men): subdata - subset(data,data$gender==1) After a residual diagnostic of a regression analysis, I detected three outliers: linmod - lm(y ~ x, data=subdata) plot(linmod) Say, the cases 11,22, and 33 were outliers. Here comes the problem: When I want to exclude these three cases in a further regression analysis, - for instance with linmod2 - lm(y[-c(11,22,33)] ~ x[-c(11,22,33)], data=subdata) - it does not work. I guess this has something to do with this strange row.names-vector which has been added to the dataframe when creating the subset. I find it very strange why R gives the case numbers in the diagnostics but then doesn't allow me to use these numbers for further exclusion. Can anybody tell me: 1. what this row.names vector is 2. How I can refer to cases after creating a subset (e.g., in order to exclude them). Many thanks in advance, Best, Holger -- View this message in context: http://www.nabble.com/Eliminate-cases-in-a-subset-of-a-dataframe-tp25437374p25437374.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. __ [[elided Yahoo spam]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Which apply function to use?
Masca, N. wrote: Dear All, I have a problem which *should* be pretty straightforward to resolve - but I can't work out how! I have a list of 3 coefficient estimates for 4 different datasets: Coefs-list(c(1,0.6,0.5),c(0.98,0.65,0.4),c(1.05,0.55,0.45),c(0.99,0.50,0.47)) All I want to do is take the sum (or mean) of each coefficient across the 4 datasets. I can do this using a for loop, but it gets very messy - as I need to do this several times I was hoping someone might have a better solution using one of the apply functions. Any ideas? Many thanks for any help you can provide. Cheers, Nick Since Coefs is a list object you could use the lapply list apply function to execute the mean() function on each component of the list: lapply( Coefs, mean ) You could also use it to execute your own function that contains additional operations: lapply( Coefs, function( listComponent ){ # Do whatever. mean( listComponent ) }) However, I don't know what you mean by these coefficients you want to apply to each of the four data sets. Perhaps you could elaborate? -Charlie - Charlie Sharpsteen Undergraduate Environmental Resources Engineering Humboldt State University -- View this message in context: http://www.nabble.com/Which-%22apply%22-function-to-use--tp25439192p25439276.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] Eliminate cases in a subset of a dataframe
Hi folks, I created a subset of a dataframe (i.e., selected only men): subdata - subset(data,data$gender==1) After a residual diagnostic of a regression analysis, I detected three outliers: linmod - lm(y ~ x, data=subdata) plot(linmod) Say, the cases 11,22, and 33 were outliers. Here comes the problem: When I want to exclude these three cases in a further regression analysis, - for instance with linmod2 - lm(y[-c(11,22,33)] ~ x[-c(11,22,33)], data=subdata) - it does not work. I guess this has something to do with this strange row.names-vector which has been added to the dataframe when creating the subset. I find it very strange why R gives the case numbers in the diagnostics but then doesn't allow me to use these numbers for further exclusion. Can anybody tell me: 1. what this row.names vector is 2. How I can refer to cases after creating a subset (e.g., in order to exclude them). Many thanks in advance, Best, Holger -- View this message in context: http://www.nabble.com/Eliminate-cases-in-a-subset-of-a-dataframe-tp25437374p25437374.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] installation problem
Hello All I have some problem for installing XML_2.6-0.tar . I am working in widows and R version is R-2.9.1 *install.packages(XML)* After selecting a CRAN mirror ** *Error :-* Warning: unable to access index for repository http://cran.pt.r-project.org/bin/windows/contrib/2.9 Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/bin/windows/contrib/2.9 Warning messages: 1: In open.connection(con, r) : unable to connect to 'cran.r-project.org' on port 80. 2: In getDependencies(pkgs, dependencies, available, lib) : package XML is not available ** *install.packages( c:/program files/R/XML_2.6-0.tar.gz, type=source, repos=NULL)* *Error :-* 'sh' is not recognized as an internal or external command, operable program or batch file. Thanks in advance for your help Kind Regards -- Wesley [[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] 64-bit OSX binary for 2.9.2
Hi, On Sep 14, 2009, at 11:44 AM, ivo welch wrote: dear R wizards: I am looking for a binary package distribution of R 2.9.2 for OSX . Looking at http://r.research.att.com/ , there seems to be only a binary for 2.9.0 . is the 2.9.2 version binary package available somewhere? (at this point, would it make sense to elevate the 64-bit version to a standard recommended rather than just a boutique version?) There isn't a *.pkg / *.dmg install for it, but it's there. In this section: Universal nightly builds for Mac OS X (10.4 Tiger and 10.5 Leopard) Third row in the table: http://r.research.att.com/R-2.9-branch-leopard-universal.tar.gz You have to inflate it at the root of your HD. The text right below the d/l table tells you how to do that: Alternatively you can use the tar-ball (*.tar.gz) which must be unpacked in the root (e.g. tar fvxz R*.tar.gz -C /), but doesn't contain the GUI (see below for a separate download). You'll have to install the R.app GUI separately if you want to use the 2.9.2 install, otherwise I think the 2.9.0 *.pkg installer includes it, though I'm not sure. -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Strange question/result about SVM
Noah, It may be just me - but how does any of your questions on prediction modeling relate to R? It seems to me that you have been getting a lot of free consulting from this forum that is supposed to be a forum for help on R-related issues. 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_personal_pages/Varadhan.h tml -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Noah Silverman Sent: Monday, September 14, 2009 1:00 PM To: r help Subject: [R] Strange question/result about SVM Hello, I have a very unusual situation with an SVM and wanted to get the group's opinion. We developed an experiment where we train the SVM with one set of data (train data) and then test with a completely independent set of data (test data). The results were VERY good. I found and error in how we generate one of or training variables. We discovered that it was indirectly influenced by future events. Clearly that needed to be fixed. Fixing the variable immediately changed our results from good to terrible. (Not a surprise since the erroneous variable had future influence.) A friend, who knows NOTHING of statistics or math, innocently asked, Why don't you just keep that variable since it seems to make your results so much better. The idea, while naive, led me to thinking. We can include future data in the training set, since it occurred in the past, but what to do with the test data from today? As a test, I tried simply setting the variable to the average of the value in the training data. The results were great! Now since the data is scaled, and we set the variable to the same value (constant from average of training data.) it scaled to 0. Still, great results. To summarize: Bad var in training + Bad var in testing = great results Good var in training + Good var in testing = bad results Bad var in training + Constant in testing = great results. I'm not an expert with the internals of the SVM, but clearly the bad variable is setting some kind of threshhold or intercept when defining the model. Can someone help me figure out why/how this is working? Thanks! -- N __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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] local sequence function
hey, I can not find a function for the following problem, hopefully you can help me. I have a vactor like this one v = c(NA,NA,TRUE,TRUE,NA,TRUE,NA,TRUE,TRUE,TRUE) and I would like to the TRUE values by the their local sequence number. This means, the result should look thike this: c(NA,NA,1,2,NA,1,NA,1,2,3) Of course I could solve the problems using a loop, but this would be much to slow, because the real vector is much larger. Can you point me in the right direction? thank you! regards, Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] ggplot2 graphing multiple lines of data
alternatively, use aes_string, p - ggplot(bmm, aes_string(x=age, y=bm, colour=pp, group=pp)) p - p + geom_line() p HTH, baptiste 2009/9/14 smu m...@z107.de hey, On Mon, Sep 14, 2009 at 07:51:42AM -0700, John Kane wrote: p - ggplot(bmm, aes(x=age, y=bm, colour=pp, group=pp)) p - p + geom_line() remove the quotes and it will work: ggplot(bmm, aes(x=age, y=bm, colour=pp, group=pp))+geom_line() regards, Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 http://newton.ex.ac.uk/research/emag __ [[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] how to recode with an if-type statement
Of course if w9zd9_1, w9zd9_2, w9zd9_3 were elements of a data.frame (or even a list), you could use indexing, w9zd9 = data.frame(w9zd9_1 = 1:10, w9zd9_2 = 1:10, w9zd9_3 = -2*1:10) average = function(numbers=1, w9zd9){ if(numbers == 1L) return(w9zd9[ ,1]) # vector case fails with rowMeans rowMeans(w9zd9[ ,seq(1, numbers)]) } average(1, w9zd9) average(2, w9zd9) average(3, w9zd9) HTH, baptiste 2009/9/14 Don MacQueen m...@llnl.gov I suppose there are a couple of ways... if (numbers==1) { distot - } else if (numbers ==2) { distot - } else if (numbers==3) { distot - } else distot - NA (letting you fill in the right hand side within each block) There's also distot - switch(numbers, w9zd9_1, (w9zd9_1 + w9zd9_2)/2, (w9zd9_1 + w9zd9_2 + w9zd9_3)/3, NA) In both cases I added an explicit result in case numbers is not one of the expected values. Generalizing this to an arbitrary value of numbers would be trickier. -Don At 11:05 AM -0400 9/14/09, Casey Klofstad wrote: I'm sure this is easy, but I'm having a hard time figuring out how to recode some data in R. I have a variable numpeers which is valued 1, 2, or 3. I also have three other variables called w9zd9_1, w9zd9_2, and w9zd9_3. I want to use these variables to create a new item called distot. Specifically, here is what I want to do: -if numpeers=1, then distot=w9zd9_1 -if numpeers=2, then distot=(w9zd9_1 + w9zd9_2)/2 -if numpeers=3, then distot=(w9zd9_1 + w9zd9_2 + w9zd9_3)/3 Thanks, in advance, for the help! -- Casey A. Klofstad University of Miami Department of Political Science Coral Gables, FL klofs...@gmail.com http://*www.*as.miami.edu/personal/cklofstad/ __ R-help@r-project.org mailing list https://*stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http:// *www.*R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/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 http://newton.ex.ac.uk/research/emag __ [[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] (no subject)
I want to comput prime component of a graph. please guide mi. thanks alot [[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] Teaching material for children...
Dear R colleagues-- Apologies for belabouring, but if it wasn't obvious already, I was speaking specifically to R-Project resources for young adults. As I was querying the R-help list, thought that was crystal clear but I've received an offer or two of assistance of a more generic nature. Best, V. On Mon, Sep 14, 2009 at 9:17 AM, Vince Fulco vful...@gmail.com wrote: Wondering if anyone is aware of resources appropriate for home schooled pre-teen/teen relatives? Before anyone suggests, a lengthy google search was unsuccessful. TIA, V. -- Vince Fulco, CFA, CAIA 612.424.5477 (universal) vful...@gmail.com A posse ad esse non valet consequentia “the possibility does not necessarily lead to materialization” -- Vince Fulco, CFA, CAIA 612.424.5477 (universal) vful...@gmail.com A posse ad esse non valet consequentia “the possibility does not necessarily lead to materialization” __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot2 legend text....a basic question
Hello fellow R's, I´ve been learning to use the ggplot2 library, and after a full day of work I still have a couple of basic questions. Here is an example: mydata=data.frame(x=runif(20),y=runif(20),n=runif(20)) mydata2=data.frame(x=c(0.4,0.6,0.5),y=c(0.4,0.4,0.6)) ggplot(mydata, aes(x, y)) + geom_point(aes(size = n)) + geom_polygon(data=mydata2,aes(x,y,alpha=0.5)) In this plot, the points are labeled as n (the name of the variable) and the polygon is labeled as 0.5 (the alpha value used). My questions are: a) How to change the text in the legend (for example, number instead of n). b) How to avoid having a legend for the polygon? Many thanks, Julian -- Julian Mariano Burgos Hafrannsóknastofnunin/Marine Research Institute Skúlagata 4, 121 Reykjavík, Iceland Sími/Telephone : +354-5752037 Bréfsími/Telefax: +354-5752001 Netfang/Email: jul...@hafro.is, jmbur...@u.washington.edu __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] how to recode with an if-type statement
I suppose there are a couple of ways... if (numbers==1) { distot - } else if (numbers ==2) { distot - } else if (numbers==3) { distot - } else distot - NA (letting you fill in the right hand side within each block) There's also distot - switch(numbers, w9zd9_1, (w9zd9_1 + w9zd9_2)/2, (w9zd9_1 + w9zd9_2 + w9zd9_3)/3, NA) In both cases I added an explicit result in case numbers is not one of the expected values. Generalizing this to an arbitrary value of numbers would be trickier. -Don At 11:05 AM -0400 9/14/09, Casey Klofstad wrote: I'm sure this is easy, but I'm having a hard time figuring out how to recode some data in R. I have a variable numpeers which is valued 1, 2, or 3. I also have three other variables called w9zd9_1, w9zd9_2, and w9zd9_3. I want to use these variables to create a new item called distot. Specifically, here is what I want to do: -if numpeers=1, then distot=w9zd9_1 -if numpeers=2, then distot=(w9zd9_1 + w9zd9_2)/2 -if numpeers=3, then distot=(w9zd9_1 + w9zd9_2 + w9zd9_3)/3 Thanks, in advance, for the help! -- Casey A. Klofstad University of Miami Department of Political Science Coral Gables, FL klofs...@gmail.com http://*www.*as.miami.edu/personal/cklofstad/ __ R-help@r-project.org mailing list https://*stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://*www.*R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- -- Don MacQueen Environmental Protection Department Lawrence Livermore National Laboratory Livermore, CA, USA 925-423-1062 __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Merge data frames but prefer values in on
On 2009-September-11 , at 13:55 , wrote: Maybe: do.call(rbind, lapply(with(xy - rbind(x, y), split(xy, list(a, b), drop = TRUE)), tail, 1)) On Fri, Sep 11, 2009 at 3:45 AM, jo jo.li...@gmail.com wrote: Thanks for the post-processing ideas. But is there any way to do that in one step? Thanks but by in one step I meant within the merge, not in one post- processing step ;) JiHO --- http://maururu.net __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] acf gives correlations 1
This is quite a nasty one! I've been having a look at it, and I think it would be useful to go back to first principles. Given a series u[1:N], the correlation coefficient between u[1:(N-k)] and u[(k+1):N] is c(k) = cov(u[1:(N-k)],u[(k+1):N])/sqrt(var(u[1:(N-k)])*var(u(k+1):N])) in which, in particular, the means of u[1:(N-k)] and u[(k+1):N] are subtracted from their respective series in caluclating the variances and the covariance. This definition can be adopted for the serial correlation of lag k. However, variants of this definition are often adopted for the sake of better estimation (in various senses). These include subtracting the mean M of the entire series from u[1:(N-k)] and u[(k+1):N], and then forming sum( (u[1:(N-k)]-M)*( u[(k+1):N-M) ) in calculating the covariance, and using var(u[1:N]) in the denominator instead of the above denominator. But only the above definition of c(k) is guaranteed to yield a result between -1 and 1; variants can theoretically give a result outside this range. This is unlikely to happen for a long series -- indeed, there is unlikely to be much difference between the various ways of doing it in a long series. But in your case you do not have long series. I have read your series into a vector called x, of length N=6940. For example, the set of values i such that neither x[i] nor x[i+1] is NA is: which((!is.na(x[1:(N-1)])(!is.na(x[2:N] [1] 3238 4604 4605 4606 4932 4933 4985 4991 4992 4993 4994 [12] 5331 5353 5429 5478 5479 5527 5554 5569 5583 5597 [23] 5625 5639 5653 5681 5682 5683 5905 5947 5977 5978 6043 [34] 6044 6045 6241 6283 6297 6301 6311 6395 6396 6397 6398 only 44 in length; and the lengths of sequences of succesive integers in the above are: 1 3 2 1 4 1 1 1 2 1 2 1 1 1 1 1 1 3 1 1 2 3 1 1 1 1 1 4 Now let ix.1 - which((!is.na(x[1:(N-1)])(!is.na(x[2:N] x1.0 - x[ix.1] x1.1 - x[ix.1+1] Now we can calculate a correlation of lag 1 as c(1) = cov(x1.0,x1.1)/sqrt(var(x1.0)*var(x1.1)) = 0.8511088 which is nicely between 0 and 1. This is calculated using the basic definition of c(k) above, not any variant. NOW: What variant would we like to play with? [1]: Subtract the mean of all the x's in x1.0 and x1.1 ix - union(ix.1,(ix.1+1)); n - length(ix) M - mean(x[ix]) v1.0 - x1.0 - M ; v1.1 - x1.1 - M sum(v1.0*v1.1)/sqrt(sum(v1.0^2)*sum(v1.1^2)) = 0.8523563 which is not very different. [2]: Subtract the mean of all non-NA x's in x M - mean(x,na.rm=TRUE) v1.0 - x1.0 - M ; v1.1 - x1.1 - M sum(v1.0*v1.1)/sqrt(sum(v1.0^2)*sum(v1.1^2)) = 0.8621987 which is a bit more different [3]: Use the covariance of x1.0,x1.1 as in c(k), but use the variance of all the non-NA x's V - var(x,na.rm=TRUE) cov(x1.0,x1.1)/V = 1.196581 **This is beginning to look like what R's acf() does! But not quite: acf at lag 1 gave 1.258, at lag 2 1.192 However, it makes the point ... I too would be unhappy with results, purporting to be correlations, which so much exceeded 1. I would normally think of using the above method for c(k), along the lines of Ck - function(x,k){ ix.1 - which((!is.na(x[1:(N-k)])(!is.na(x[(k+1):N] x1.0 - x[ix.1] x1.1 - x[ix.1+k] cov(x1.0,x1.1)/sqrt(var(x1.0)*var(x1.1)) } for(k in (1:10)){ acfs[k]-Ck(x,k) } cbind((1:10),acfs) # acfs # 1 0.8511088 # 2 0.5881168 # 3 0.6543933 # 4 0.9046573 # 5 0.9392939 # 6 0.8076299 # 7 0.8605418 # 8 0.9431999 # 9 0.9667194 # 10 0.9477807 (Note): I've also had a look at the code in acf(), but it's not clear to me exactly what it does in a case like yours! Hoping this is of some help, Ted. On 14-Sep-09 13:53:01, Steve Jones wrote: I misunderstood what the help page was saying - I thought that the missing values were what constituted the invalid function. Clearly I was mistaken. Looks like I'll have to compute the acf myself. Shame, but such is life. Thanks for the input, everyone! Steve. Berwin A Turlach wrote: G'day Steve, On Mon, 14 Sep 2009 13:44:56 +0200 Steve Jones st...@squaregoldfish.co.uk wrote: Apologies for the missing data. It can be downloaded from here (22Kb): http://www.squaregoldfish.co.uk/sekrett/series.csv Well, the Details section of acf's help page states: By default, no missing values are allowed. If the 'na.action' function passes through missing values (as 'na.pass' does), the covariances are computed from the complete cases. This means that the estimate computed may well not be a valid autocorrelation sequence, and may contain missing values. [...] And you have seem to have a massive amount of missing data: R dat - scan(url(http://www.squaregoldfish.co.uk/sekrett/series.csv;)) Read 6940 items R mean(!is.na(dat)) [1] 0.02881844 And, not surprisingly, an even smaller proportion of consecutive, non-missing observations. R mean(!is.na(dat[-1]) !is.na(dat[-length(dat)])) [1] 0.006340971 You can find out which formulae are used exactly by
Re: [R] local sequence function
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Henrique Dallazuanna Sent: Monday, September 14, 2009 9:59 AM To: smu Cc: r-help@r-project.org Subject: Re: [R] local sequence function Try this also: with(rle(v), unlist(sapply(lengths, FUN = seq)) * v) Note that the sequence() function is essentially the second argument to that call to with(). sequence function (nvec) unlist(lapply(nvec, seq_len)) environment: namespace:base It uses lapply because there is no need to waste the time sapply spends simplifying the answer and it uses seq_len since that is faster than seq (and gives more predictable results for odd inputs like 0). For long input vectors the following Sequence() function is faster and probably uses less memory Sequence - function(nvec) { seq_len(sum(nvec)) - rep(cumsum(c(0L,nvec[-length(nvec)])), nvec) } Hence the following can be considerably faster than the above f2 - function(v)v * Sequence(rle(is.na(v))$lengths) Note that I use rle(is.na(v)) instead of rle(v), since R's rle considers a run of n NA's to be n runs of singleton NA's, which would cause the lapply-based function to waste time computing seq_len(1) for each NA (which we intend to throw away). When using Sequence instead of sequence you may as well omit the is.na. For a vector of 10 million NA's and TRUE's with c. 5 million runs in it v1-sample(c(TRUE,NA), replace=T, size=1e7, prob=c(.7,.3)) f2 takes 2.7 seconds on my machine and the sequence() based approach takes 19.0. sequence() is a candidate for implementing in C as it is orthogonal to the rep() function which is a .Primitive noquote(rep(c(A,B,C,D), c(2,4,1,2))) [1] A A B B B B C D D sequence(c(2,4,1,2)) [1] 1 2 1 2 3 4 1 1 2 Bill Dunlap TIBCO Software Inc - Spotfire Division wdunlap tibco.com On Mon, Sep 14, 2009 at 12:20 PM, smu m...@z107.de wrote: hey, I can not find a function for the following problem, hopefully you can help me. I have a vactor like this one v = c(NA,NA,TRUE,TRUE,NA,TRUE,NA,TRUE,TRUE,TRUE) and I would like to the TRUE values by the their local sequence number. This means, the result should look thike this: c(NA,NA,1,2,NA,1,NA,1,2,3) Of course I could solve the problems using a loop, but this would be much to slow, because the real vector is much larger. Can you point me in the right direction? thank you! regards, Stefan __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40 S 49° 16' 22 O [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] ggplot2 graphing multiple lines of data
Some day I may figure out how ggplot2 works. I am trying to plot 5 columns of data on a graph (similar to a simple matplot) === library(ggplot2) bmi - structure(list(pct = 2:21, P10 = c(14.6, 14.5, 14.2, 13.9, 13.7, 13.7, 13.9, 14.2, 14.5, 14.8, 15.3, 15.9, 16.6, 17.2, 17.8, 18.1, 18.3, 18.4, 18.5, 18.6), P25 = c(15.2, 15, 14.8, 14.6, 14.4, 14.5, 14.8, 15.1, 15.5, 15.9, 16.4, 17.1, 17.8, 18.5, 19.1, 19.4, 19.6, 19.7, 19.8, 19.9), P50 = c(16, 15.8, 15.5, 15.4, 15.4, 15.6, 16, 16.4, 16.9, 17.4, 18, 18.7, 19.5, 20.2, 20.8, 21.1, 21.4, 21.5, 21.6, 21.7), P75 = c(16.8, 16.7, 16.5, 16.4, 16.5, 16.9, 17.5, 18.1, 18.7, 19.4, 20.1, 20.9, 21.6, 22.4, 23, 23.4, 23.6, 23.8, 24, 24.1), P90 = c(17.6, 17.5, 17.5, 17.5, 17.8, 18.4, 19.2, 20.1, 21, 21.8, 22.6, 23.4, 24.2, 24.9, 25.5, 25.9, 26.3, 26.6, 27, 27.3)), .Names = c(pct, P10, P25, P50, P75, P90), class = data.frame, row.names = c(NA, -20L)) # simple matplot example matplot(bmi[,2:6], type=l) === I thought that I should be able to do it following the example from pg.50 of Hadley's ggplot pdf book. ===Hadleys example=== library(nlme) # to get Oxboy dataset p - ggplot(Oxboys, aes(age, height, group = Subject)) + geom_line() p NON-WORKING CODE= bmm - melt(bmi, id=c(pct)) names(bmm) - c(age, pp, bm) bmm[,2] - as.ordered(bmm[,2]) p - ggplot(bmm, aes(x=age, y=bm, colour=pp, group=pp)) p - p + geom_line() p === [[elided Yahoo spam]] Would someone kindly point out what supidity I am commiting here? Thanks __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] (no subject)
Hi, On Sep 14, 2009, at 10:19 AM, asie soheili wrote: I want to comput prime component of a graph. please guide mi. If you're working with graphs, you'll want to check out the igraph package: http://cran.r-project.org/web/packages/igraph/ http://igraph.sourceforge.net/ -steve -- Steve Lianoglou Graduate Student: Computational Systems Biology | Memorial Sloan-Kettering Cancer Center | Weill Medical College of Cornell University Contact Info: http://cbio.mskcc.org/~lianos/contact __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Location of Packages?
iw == ivo welch ivo_we...@brown.edu on Mon, 14 Sep 2009 12:03:59 -0400 writes: iw Sorry, one more: on OSX, I deleted my old 2.9.2 R.app, and installed the 64 iw bit version of 2.9.0. I then did an install.packages(car) under my new iw 2.9.0. It seems to have worked, but alas, I still get an error that package iw 'car' was built under R version 2.9.2 . Where exactly does R under OSX iw install its packages? (is it a bug that another car is loaded?) Don't know. But in R, you can always see (and also change if you want) in which libraries R is looking for packages, either by ll - library() str(ll) ## or ll or -- more quickly but with less adjoint info -- by .libPaths() iw PS: do I need to install the car packages under the 64-bit version, or will iw it be seen by the 64 bit version if I do a 32-bit install? Or do I need to iw do a double install? for safety, I did it under the command line version, iw which I presume is still 32-bit, and the 64 bit GUI. iw PPS: how do I learn which version of R is running? sessionInfo() iw regards, /iaw Regards, Martin iw -- iw Ivo Welch (ivo.we...@brown.edu, ivo.we...@gmail.com) iw [[alternative HTML version deleted]] hmm __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.