1

Is there a way to plot summary statistics in ggplot2 without the raw data? Say I have three data points: the first has mean 34.2 and standard error 3.4, the second has mean 28.6 and standard error 0.5, and the third has mean 44.0 and standard error 2.2. How would I plot this?

gmallow
  • 11
  • 2

1 Answers1

3

There may be more efficient ways, but you could try putting those numbers into a data frame and plotting from that. So you'd have observations 1 - 3, and their corresponding means and standard errors in three columns as follows:

    obs <- c(1,2,3)
    mean <- c(34.2, 28.6, 44.0)
    se <- c(3.4, 0.5, 2.2)
    df = data.frame(obs, mean, se)

    ggplot(df, aes(y=mean, x=obs)) + 
       geom_bar(position="dodge", stat="identity") + 
       geom_errorbar(aes(ymax = mean+se, ymin = mean-se))
pyne
  • 507
  • 1
  • 5
  • 16