scatter plot, aov()
1
0
Entering edit mode
6 weeks ago
Rob ▴ 40

Hello friends, can anyone help me answering this question? I don't really know how to respond.

Question: Plot can be used to make regular old scatter plots. Why doesn't plot make a scatter plot when passed the object anovaOutput?

#runs an anova on my data and saves the out put
anovaOutput <- aov(Temp ~ Month, data = airquality)

#I plot the output of the anova
par(mfrow = c(2,2)) #this is just used to show the four graphs create by the next line.

plot(anovaOutput)
scatter plot aov() • 112 views
ADD COMMENT
2
Entering edit mode

plot() can detect certain classes of objects and then 'know' which components to use to generate the plot. In this case, plot() may not have a default behaviour for objects produced by aov()

ADD REPLY
1
Entering edit mode

If you want a scatter plot, would this not make better sense?

plot(airquality$Month, airquality$Temp)

...or, indeed, just:

plot(Temp ~ Month, data = airquality)
ADD REPLY
0
Entering edit mode

Thanks Kevin, You are right. This is just an assignment question for R course that I do not know how to explain in words.

ADD REPLY
0
Entering edit mode

This post does not seem to have anything to do with bioinformatics and might be closed as off-topic.

ADD REPLY
1
Entering edit mode
6 weeks ago

Actually, the default behavior of the plot() function applied to an object of the aov or lm class is to plot diagnostic plots to check the quality of the annova. This happen because different plot methods are applied depending on the class. To know the class of your object, use class(anovaOutput). Then methods(plot) will list all the different methods available for the plot function. It is also possible to define your own methods for your newly defined classes. Also, to see what a method does, you can use the function getAnywhere():

class(anovaOutput)
[1] "aov" "lm" 

methods(plot)[4:15]
 [4] plot.default        plot.dendrogram*    plot.density*      
 [7] plot.ecdf           plot.factor*        plot.formula*      
[10] plot.function       plot.hclust*        plot.histogram*    
[13] plot.HoltWinters*   plot.isoreg*        plot.lm*           

getAnywhere(plot.lm)
ADD COMMENT
1
Entering edit mode

Thanks Carlo So, what I understood from your answer is: according to the class of my object (here aov object) a different method (different from default) is applied for plotting with the plot ().

ADD REPLY

Login before adding your answer.

Traffic: 2367 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6