[R] points(x,y), mean and standard deviation
Joshua Wiley
jwiley.psych at gmail.com
Tue Oct 19 16:50:51 CEST 2010
Hi,
Here is an example using ggplot2. For future reference, it would be
convenient if you provided sample data. This is actually pretty easy
to do: dput(yourdata) or if your data is very large:
dput(head(yourdata)). At any rate, here is an example with the means
plotted as points and connected with a line and error bars around
them. The line is controlled by geom_line() so you can easily add or
remove it.
# Load ggplot2
library(ggplot2)
# Create some sample data
dat <- data.frame(X = as.Date(Sys.time()) - 0:10,
Y1 = sample(20:30, 11, replace = TRUE),
Y2 = sample(2:6, 11, replace = TRUE))
# Actual plot
ggplot(data = dat, aes(x = X, y = Y1, ymin = Y1 - Y2, ymax = Y1 + Y2)) +
geom_point() + # points at the means
geom_line() + # if you want lines between pints
geom_errorbar() # error bars, Y1 - Y2 and Y1 + Y2
HTH,
Josh
On Tue, Oct 19, 2010 at 1:41 AM, ashz <ashz at walla.co.il> wrote:
>
> Hi,
>
> I have a data set with 3 rows (X=date, Y1=arithmetic mean and Y2=standard
> deviation). How can I create a graph(e.g., points) which will show the
> +-stdev as well (similar to excel).
>
> Thanks
>
> --
> View this message in context: http://r.789695.n4.nabble.com/points-x-y-mean-and-standard-deviation-tp3001683p3001683.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
More information about the R-help
mailing list