[R-sig-teaching] adding plus/minus 1 standard devaition into each bar in cluster bar chart

Ian Fellows ian.fellows at stat.ucla.edu
Tue Dec 14 17:37:17 CET 2010


Superior plots can be made pretty easily in ggplot2
library(ggplot2)
ggplot() +
	stat_boxplot(aes(y = mpg,x = factor(gear)),data=mtcars,width = 0.5) +
	geom_point(aes(x = factor(gear),y = mpg),data=mtcars,position = position_jitter(height = 0.0,width = 0.1))

There is also a convinience function in Deducer that does much the same thing:

library(Deducer)
data(mtcars)
oneway.plot(formula=mpg~gear,data=mtcars,alpha=1) #with one variable
oneway.plot(formula=d(mpg,disp,hp,drat)~gear,data=mtcars, alpha=1) #with multiple variables



On Dec 14, 2010, at 6:43 AM, Stuart Wagenius wrote:

> Hadley, Thanks for the recommended reading. Is there R code to make
> recommended plots?
> 
> Stuart
> 
> On Mon, Dec 13, 2010 at 5:22 PM, Hadley Wickham <hadley at rice.edu> wrote:
> 
>> Before doing that, I'd highly recommend reading
>> http://biostat.mc.vanderbilt.edu/twiki/pub/Main/TatsukiRcode/Poster3.pdf
>> 
>> Hadley
>> 
>> On Sat, Dec 11, 2010 at 8:43 AM, Ali Zanaty <zanaty2005 at yahoo.com> wrote:
>>> Dear All R users:
>>> 
>>> I hope that this message finds all of you well.
>>> 
>>> Currently, I am teaching an undergraduate course in statistics.
>>> 
>>> If possible, Could you please help me out how to add plus/minus 1
>> standard
>>> deviation added to each bar into R cluster bar chart.
>>> 
>>> You can use the following artificial data.
>>> 
>>> data cat 1 cat 2
>>> 23     1      1
>>> 45     1      1
>>> 34     1      1
>>> 5      1      1
>>> 32     1      1
>>> 44     1      1
>>> 3      2      1
>>> 1      2      1
>>> 2      2      1
>>> 3      2      1
>>> 4      2      1
>>> 5      1      2
>>> 6      1      2
>>> 7      1      2
>>> 8      1      2
>>> 544    2      2
>>> 78     2      2
>>> 543    2      2
>>> 34     2      2
>>> 89     2      2
>>> 9      1      3
>>> 43     1      3
>>> 23     1      3
>>> 45     1      3
>>> 7      1      3
>>> 5      1      3
>>> 7      1      3
>>> 6      2      3
>>> 867    2      3
>>> 3      2      3
>>> 4      2      3
>>> 5      2      3
>>> 6      2      3
>>> 7      2      3
>>> 8      2      3
>>> 9      2      3
>>> 
>>> I need to create a bar chart for the mean of data column for each
>> category. I
>>> know how to create the cluster bar chart. But I need your help with how
>> to add
>>> plus/minus 1 standard deviation into each bar.
>>> 
>>> Thank you so much for your helps and for your attention to this matter,
>> and I
>>> look forward to hearing from you.
>>> 
>>> 
>>> Regards,
>>> 
>>> zanaty
>>> 
>>> 
>>> 
>>>       [[alternative HTML version deleted]]
>>> 
>>> _______________________________________________
>>> R-sig-teaching at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
>>> 
>> 
>> 
>> 
>> --
>> Assistant Professor / Dobelman Family Junior Chair
>> Department of Statistics / Rice University
>> http://had.co.nz/
>> 
>> _______________________________________________
>> R-sig-teaching at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
>> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-teaching at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-teaching
> 




More information about the R-sig-teaching mailing list