Dear list, I would like to produce a plot of variables where the size of the points will be indicative of their standard errors. How is that possible? Thank you! [[alternative HTML version deleted]]
Hi Irene, Assuming you have already calculated the standard errors, something like the following will work: library(ggplot2) qplot(x, y, data=mydataframe, size = se) Hadley On Fri, May 2, 2008 at 8:52 AM, Irene Mantzouni <ima at aqua.dtu.dk> wrote:> Dear list, > > > > I would like to produce a plot of variables where the size of the points > will be indicative of their standard errors. > > How is that possible? > > > > Thank you! > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- http://had.co.nz/
?symbols -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.snow at imail.org (801) 408-8111> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Irene Mantzouni > Sent: Friday, May 02, 2008 7:52 AM > To: r-help at stat.math.ethz.ch > Subject: [R] points size in plots > > Dear list, > > > > I would like to produce a plot of variables where the size of > the points will be indicative of their standard errors. > > How is that possible? > > > > Thank you! > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
>> -----Original Message----- >> From: r-help-bounces at r-project.org >> [mailto:r-help-bounces at r-project.org] On Behalf Of Irene Mantzouni >> Sent: Friday, May 02, 2008 7:52 AM >> To: r-help at stat.math.ethz.ch >> Subject: [R] points size in plots >> >> Dear list, >> >> >> >> I would like to produce a plot of variables where the size of >> the points will be indicative of their standard errors. >> >> How is that possible? >> >> >> >> Thank you!Do you mean (a) the larger the standard error, the bigger the point, or (b) the larger the standard error, the smaller the point? (b) makes more statistical sense. Anyways, you can use cex. An example with two variables, u and v, in the case of (a) u <- rnorm(10,2,3) v <- rnorm(10,5,4) se.u <- runif(10,1,4) se.v <- runif(10,4,7) x <- 2:11 plot(x,u,cex=se.u/max(se.u)) points(x,v,cex=se.v/max(se.v),pch=19) And in the case of (b) u <- rnorm(10,2,3) v <- rnorm(10,5,4) se.u <- runif(10,1,4) se.v <- runif(10,4,7) x <- 2:11 plot(x,u,cex=(1/se.u)/max(1/se.u)) points(x,v,cex=(1/se.v)/max(1/se.v),pch=19) If you have NAs in your variables, use the na.rm=TRUE argument of max(). If the standard errors are very different, you can multiply the quantity evaluated for cex with a positive constant, say u <- rnorm(10,2,3) v <- rnorm(10,5,4) se.u <- runif(10,1,4) se.v <- runif(10,4,7) x <- 2:11 w=2.5 plot(x,u,cex=w*(1/se.u)/max(1/se.u)) points(x,v,cex=w*(1/se.v)/max(1/se.v),pch=19) HTH Ruben