How can I change what is printed when I type an object name?
The function ezANOVA in the ez package calcula开发者_StackOverflow中文版tes an ANOVA. Often I want to look at the means inside of these cells. Normally I just retype the formula and use the summaryBy function. This morning I modified the ezANOVA function so that it included in its resulting object the data required to do a summaryBy command. How can I change the object resulting from ezANOVA to by default hide this extra data when printed?
Your question is a little obscure. If you are returning an object with a class you can modify the print or show method for the corresponding class. You will have to know if you are dealing with an S3 or S4 class. loos at ?methods
of ?Methods
for details. as a quick example if you return an s3 class 'ezANOVA' you define a function.
print.ezANOVA<-function(x){
#code for formatting the ezANOVA object nice.
}
Update In light of your comment, and that you have already modified the exANOVA function. add this to the end of ezANOVA.
class(return.value)<-"ezANOVA"
return(return.value)
then add the print.ezANOVA
function and that should handle it.
精彩评论