[R] Make barplot with error bars, anova out of a table

David Winsemius dwinsemius at comcast.net
Fri Apr 12 00:15:15 CEST 2013


On Apr 11, 2013, at 4:43 AM, Simza wrote:

> Helo everybody,
> I'm new to R and have some issues with my data in R. 
> 
> My raw data look like that:
> 
> ID Day size 1 1 7 1 1 7.2 1 1 7.1 2 1 7.3 2 1 7.4 2 1 7.2 3 1 7 3 1 7.1 3 1
> 7.5 4 1 7.3 4 1 7.2 4 1 7.6 1 2 7 1 2 7.2 1 2 7.1 2 2 7.1 2 2 7.4 2 2 7.2 3
> 2 7.5 3 2 7.1 3 2 7.5 4 2 7.2 4 2 7.2 4 2 7.3 1 3 7.4 1 3 7.2 1 3 7.1 2 3
> 7.2 2 3 7.4 2 3 7.2 3 3 7.4 3 3 7.2 3 3 7.5 4 3 7.4 4 3 7.2 4 3 7.7
> 
> What I want to do is:
> 1) calculate the significant difference of the size for the 4 groups but
> each day separately!)? E.g. difference in size between ID 1:2, 1:3, 1:4,
> 2:3, 2:4, 3:4 for each day.
> 
> I already tried lm() and anova() but just get the difference between day, ID
> and size. I also tried to separate the data per hand but I think there
> should be a way in "R" to do that automatically!? Moreover, I was searching
> the web for similar examples but couln't find anything useful so far.

I'm guessing this appeared as a three column data layout but using HTML format has sabotaged your intent.

> 
> 2) to make a barplot with error bars of the standart error (from the mean).
> So far I used: 
> barplot(matrix(c(Rtest.dat$pH.mean),nr=3), beside=T,
> col=c("black","grey","white"), main="pH", names.arg=c("Green", "Yellow",
> "Blue", "Red"), ylab="pH") legend("topright", c("Day 1","Day 2","Day 3"),
> cex=0.6, bty="n", fill=c("black","grey","white"))
> But I have problems to add the error bars. Also here I already searched the
> web but couldn't manage to get a code working for my data.
> 
> 3) and the last thing I would need is to add * or letters (a,b,...) to the
> graph, indicating the significant difference between them.
> 
> Hope someone can help me!

You might want to consider:

http://biostat.mc.vanderbilt.edu/wiki/Main/DynamitePlots

-- 

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list