[R] question how to add Standard Deviation as "Whiskers" in a simple plot
David Winsemius
dwinsemius at comcast.net
Mon May 28 19:13:27 CEST 2012
On May 28, 2012, at 9:55 AM, gianni lavaredo wrote:
> Dear Researchers,
>
> sorry for this simple question. I have a point plot with mean
> values and i
> wish to plot line with Standard Deviation as "Whiskers". I calculate
> the
> mean+sd and mean-sd, but i can not figure out the way to add the line.
>
> mydata <-
> data
> .frame
> (mean
> =
> c
> (0.42,0.41,0.41,0.43,0.45,0.43,0.43,0.42,0.44,0.45,0.45,0.45,0.46,0.43,0.42,0.37,0.44,0.46,0.46,0.39,0.40
> ),
>
> sdUP
> =
> c
> (0.58,0.56,0.55,0.57,0.61,0.55,0.57,0.59,0.61,0.60,0.57,0.60,0.62,0.57,0.59,0.56,0.57,0.61,0.61,0.56,0.54
> ),
>
> sdDOWN
> =
> c
> (0.26,0.26,0.28,0.29,0.30,0.30,0.29,0.26,0.28,0.31,0.34,0.30,0.31,0.30,0.25,0.19,0.31,0.31,0.31,0.22,0.25
> ))
>
> plot(mydata$mean,
> type="o",
> ylab="mean",
> xlab="class")
>
> thanks in advance and sorry for any disturb
If you tried lines() usin either sdUP or sdDOWN you saw nothing
because the ylim was set by default using ony hte information in the
mean vector.
Try:
> plot(mydata$mean,
+ type="o",
+ ylab="mean",
+ xlab="class", ylim=range(c(mydata$sdUP, mydata$sdDOWN)))
> lines(mydata$sdDOWN, col="blue", lty=3)
> lines(mydata$sdUP, col="blue", lty=3)
--
David.
More information about the R-help
mailing list