Re: [R] ggplot / reshape: basic usage

From: John Kane <jrkrideau_at_yahoo.ca>
Date: Wed, 23 Jan 2008 14:08:57 -0500 (EST)


I don't understant what you're doing with the means calculation.

Howvever if you want the standard errors ( your se function) then will this do what you want?

df <- data.frame(x=c(1:10),y=sin(1:10),z=cos(1:10)); df
 dfm<-melt(df, id=c("x"), measured=c("y","z")); dfm   se <- function(x) sd(x)/sqrt(length(x))  sse <- cast(dfm, variable~., se)

I haven't used ggplot enough to be able to help there. --- baptiste Augui� <ba208_at_exeter.ac.uk> wrote:

> Hi,
>
> I've been trying to do the following simple thing:
> given a data.frame,
>
> > library(reshape)
> > library(ggplot2)
> >
> > df <-
> data.frame(x=c(1:10),y=sin(1:10),z=cos(1:10))
> > dfm<-melt(df, id=c("x"), measured=c("y","z"))
>
>
> i want to plot y and z against x, and add vertical
> errorbars to the
> points corresponding to the standard deviation of y
> and z respectively.
>
> I tried the following, inspired by some previous
> post in the list,
>
> > se <- function(x) sd(x)/sqrt(length(x))
> > means <- cast(dfm, variable~., function(x) c(se =
> se(x)))
> >
> > qplot(value,x, data=means, colour=variable, min =
> value - se, max =
> > value + se, geom=c("point","errorbar"))
>
>
> but this fails, as I obviously don't get the
> philosophy behind the
> "cast" function.
>
> Any advice welcome!
>
> Thanks,
>
> baptiste
>
> _____________________________
>
> Baptiste Augui�
>
> Physics Department
> University of Exeter
> Stocker Road,
> Exeter, Devon,
> EX4 4QL, UK
>
> Phone: +44 1392 264187
>
> http://newton.ex.ac.uk/research/emag
> http://projects.ex.ac.uk/atto
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 23 Jan 2008 - 19:14:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 23 Jan 2008 - 19:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive