[R] how to plot a distribution of mean and standard deviation

Ben Bolker bbolker at gmail.com
Sun Oct 23 18:38:34 CEST 2011


R. Michael Weylandt <michael.weylandt <at> gmail.com> writes:

> It seems like the relevant plot would depend on what you are trying to
> investigate, but usually a scatterplot would well work for bivariate
> data with no other assumptions needed. I usually find ecdf() plots
> rather hard to interpret without playing around with the data
> elsewhere first and I'm not sure they make an enormous amount of sense
> for bivariate data in your case since they reorder inputs.
> 
> Michael

 [snip]
> On Sun, Oct 23, 2011 at 6:51 AM, gj <gawesh <at> gmail.com> wrote:
> > Hi,
> > I have the following data about courses (504) in a university, two
> > attributes about the proportion of resources used (#resources_used /
> > #resources_available), namely the average and the standard deviation.
> > Thus I have:
> > [1] n=504 rows
> > [2] 1 id column and 2 attributes
> >
> > Here's a sample of the data:

 [snip]


  You could make a "caterpillar plot" as follows:

X <- read.csv("coursetmp.dat")
library(ggplot2)
X <- transform(X,courseid=reorder(courseid,average))
ggplot(X,aes(x=courseid,y=average,
   ymin=average-2*std,ymax=average+2*std))+geom_point()+
  geom_linerange()+coord_flip()

  (Here the x and y axes are flipped because it's easier to plot & read
the course ID labels that way)

  Of course, the answer to "how should I visualize these data?" always
depends on what you want to find out ...



More information about the R-help mailing list