[R] Learning ANOVA

Stephen Liu satimis at yahoo.com
Fri Aug 13 18:43:14 CEST 2010


Hi Erik,


I followed following video as example;

ANOVA in R 
http://www.youtube.com/watch?v=Dwd3ha0P8uw&feature=related


Now I got it done;

> boxplot(test01$count ~ test01$spray)


Continued:

> InsectSprays.aov <-(test01$count ~ test01$spray)
> summary(InsectSprays.aov)
 Length   Class    Mode 
      3 formula    call 

Seems having problem here.


> TukeyHSD(InsectSprays.aov)
Error in UseMethod("TukeyHSD") : 
  no applicable method for 'TukeyHSD' applied to an object of class "formula"

I'm still stuck here.


B.R.
Stephen L




----- Original Message ----
From: Erik Iverson <eriki at ccbr.umn.edu>
To: Stephen Liu <satimis at yahoo.com>
Cc: r-help at r-project.org
Sent: Sat, August 14, 2010 12:15:31 AM
Subject: Re: [R]  Learning ANOVA



> Performed following steps on R:-
> 
> ### to access to the object
>> data(InsectSprays)
> 
> ### create a .csv file
>> write.csv(InsectSprays, "InsectSpraysCopy.csv")
> 
> 
> On another terminal
> $ sudo updatedb
> $ locate InsectSpraysCopy.csv
> /home/userA/InsectSpraysCopy.csv
> 
> 
> ### Read in some data
>> test01 <- read.csv(file.choose(), header=TRUE)
> 
> Enter file name: /home/userA/InsectSpraysCopy.csv

I either don't understand what you're doing, or you seem
very confused.

R comes with many sample data sets for you to use.

You can see a list of them using the ?data function.

Calling data with an argument loads that dataset.

So, when you type:

> data(InsectSprays)

that data object is now available in R, see

> objects()

You can look at it simply by printing it:

> InsectSprays

If for some reason it makes sense to do it this way for your
use case, then that's fine, I just want to make sure you understand
that you don't have to if accessing built-in datasets is all you want.

> ### Look at the data
>> test01
>     X count spray
> 1   1    10     A
> 2   2     7     A
> 3   3    20     A

<snip>

> ### Create a side-by-side boxplot of the data
> boxplot(test01$DO ~ test01$Stream)
> Error in model.frame.default(formula = test01$DO ~ test01$Stream) :   invalid 
>type (NULL) for variable 'test01$DO'

Why do you think test01 has an element called "D0" or "Stream"?? The
column names when you print the data tell you otherwise!





More information about the R-help mailing list