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

2013-04-11 Thread Simza
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.

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!

Thanks for your help!!



--
View this message in context: 
http://r.789695.n4.nabble.com/Make-barplot-with-error-bars-anova-out-of-a-table-tp4663979.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2013-04-11 Thread Paul Johnson
Hi

On Thu, Apr 11, 2013 at 6:43 AM, Simza alex_steckba...@gmx.at 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.

 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.

R has a function called arrows that we use to draw intervals like
that. You have to calculate the intervals, of course, that's up to
you, and then draw them on the plot.

As luck would have it, I've been working a vaguely similar type of plot,

http://pj.freefaculty.org/scraps/plot-factor-proto.pdf

and I'm going to upload the R code that produces that plot. It shows
how to do arrows and such. I'm calling this a WorkingExample

http://pj.freefaculty.org/R/WorkingExamples/plot-regression-factors-1.R

 3) and the last thing I would need is to add * or letters (a,b,...) to the
 graph, indicating the significant difference between them.

Try text() to insert stuff on plots. * is writable by text.


 Hope someone can help me!

 Thanks for your help!!



 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Make-barplot-with-error-bars-anova-out-of-a-table-tp4663979.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



--
Paul E. Johnson
Professor, Political Science  Assoc. Director
1541 Lilac Lane, Room 504  Center for Research Methods
University of Kansas University of Kansas
http://pj.freefaculty.org   http://quant.ku.edu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


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

2013-04-11 Thread David Winsemius

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.