Hi, I'm trying to analyse some data I have imported into R from a .csv file but when I carry out the aov command the results show only one degree of freedom when there should be 14. Does anyone know why? I'd really appreciate some help, the data is pasted below. /The imported table looks ike this this:/ Order Transect Sample Abundance 1 Coleoptera 1 1 13 2 Coleoptera 1 2 12 3 Coleoptera 1 3 11 4 Coleoptera 1 4 13 5 Coleoptera 1 5 6 6 Coleoptera 2 1 18 7 Coleoptera 2 2 18 8 Coleoptera 2 3 16 9 Coleoptera 2 4 21 10 Coleoptera 2 5 11 11 Coleoptera 3 1 19 12 Coleoptera 3 2 16 13 Coleoptera 3 3 9 14 Coleoptera 3 4 32 15 Coleoptera 3 5 29 /The command I am using is this:/ anova2<-aov(Abundance~Transect,data=beetle) /The results come out like this:/ Df Sum Sq Mean Sq F value Pr(>F) Transect 1 250.00 250.000 7.2394 0.01852 * Residuals 13 448.93 34.533 --- Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 Cheers, Sam -- View this message in context: http://r.789695.n4.nabble.com/ANOVA-from-imported-data-has-only-1-degree-of-freedom-tp3887528p3887528.html Sent from the R help mailing list archive at Nabble.com.
David Winsemius
2011-Oct-09 17:25 UTC
[R] ANOVA from imported data has only 1 degree of freedom
On Oct 9, 2011, at 11:10 AM, shardman wrote:> Hi, > > I'm trying to analyse some data I have imported into R from a .csv > file but > when I carry out the aov command the results show only one degree of > freedom > when there should be 14. Does anyone know why? I'd really appreciate > some > help, the data is pasted below. >To me this appears likely to be homework. If so then please read your college's rules regarding academic honesty. In any case, please read the Posting Guide.> > /The imported table looks ike this this:/ > > Order Transect Sample Abundance > 1 Coleoptera 1 1 13 > 2 Coleoptera 1 2 12 > 3 Coleoptera 1 3 11 > 4 Coleoptera 1 4 13 > 5 Coleoptera 1 5 6 > 6 Coleoptera 2 1 18 > 7 Coleoptera 2 2 18 > 8 Coleoptera 2 3 16 > 9 Coleoptera 2 4 21 > 10 Coleoptera 2 5 11 > 11 Coleoptera 3 1 19 > 12 Coleoptera 3 2 16 > 13 Coleoptera 3 3 9 > 14 Coleoptera 3 4 32 > 15 Coleoptera 3 5 29 > > /The command I am using is this:/ > > anova2<-aov(Abundance~Transect,data=beetle) > > /The results come out like this:/ > > Df Sum Sq Mean Sq F value Pr(>F) > Transect 1 250.00 250.000 7.2394 0.01852 * > Residuals 13 448.93 34.533 > --- > Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > Cheers, > Sam > > > -- > View this message in context: http://r.789695.n4.nabble.com/ANOVA-from-imported-data-has-only-1-degree-of-freedom-tp3887528p3887528.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.David Winsemius, MD West Hartford, CT
Hi David, Thanks for your message. I can assure you this is not homework. I'm working on an ecology project and am trying to analyse the results from the fieldwork. I don't want other people to do the work for me I was just hoping someone might be able to spot where I have made a mistake, I'm still teaching myself to use R after having used SPSS for a long time. I did read the posting guidelines but couldn't see any reason not to ask for help, I'm sorry if I've got it wrong, Yours, Sam -- View this message in context: http://r.789695.n4.nabble.com/ANOVA-from-imported-data-has-only-1-degree-of-freedom-tp3887528p3887979.html Sent from the R help mailing list archive at Nabble.com.
Ben Bolker
2011-Oct-10 02:08 UTC
[R] ANOVA from imported data has only 1 degree of freedom
shardman <samuelhardman <at> hotmail.com> writes:> > Hi, > > I'm trying to analyse some data I have imported into R from a .csv file but > when I carry out the aov command the results show only one degree of freedom > when there should be 14. Does anyone know why? I'd really appreciate some > help, the data is pasted below. > > /The imported table looks ike this this:/ > > Order Transect Sample Abundance > 1 Coleoptera 1 1 13[snip]> 15 Coleoptera 3 5 29 > > /The command I am using is this:/ > > anova2<-aov(Abundance~Transect,data=beetle) >I was going to tell you to read up on the distinction between factors and numeric variables in statistical models, but I can't immediately find a reference on line (this is bound to be in Peter Dalgaard's book or any other basic-stats-with-R text). str() will tell you whether the columns are numeric or factors. Try beetle <- transform(beetle,Transect=factor(Transect)) [or ?read.csv and use colClasses explicitly to specify the classes of the columns] before running your anova.