Read documentation for TukeyHSD by typing the command:

?TukeyHSD

The input to that function should usually be, "a fitted model object,
usually an aov fit."

You have not created a "fitted model object."

This seems to work:
model <- aov(InsectSprays$count ~ InsectSprays$spray)
TukeyHSD(model)


The aov() makes the aov model object. Tacking .aov onto an object name
doesn't do that.

Which introductory R book(s) have you read? That would be a worthwhile
investment of your time.

--Chris Ryan

On Fri, Aug 13, 2010 at 12:43 PM, Stephen Liu <satimis@yahoo.com> wrote:

> 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@ccbr.umn.edu>
> To: Stephen Liu <satimis@yahoo.com>
> Cc: r-help@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!
>
>
>
> ______________________________________________
> 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<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]

