How to change what is printed when entering the name of an object?

The ezANOVA function in the ez package computes ANOVA. Often I want to look at the funds inside these cells. Usually I just retype the formula and use the summaryBy function. This morning I changed the ezANOVA function so that it included in my result object the data needed to execute the summaryBy command. How can I change the object resulting from ezANOVA by default to hide this additional data when printing?

+3
source share
1 answer

Your question is a bit unclear. If you return an object with a class, you can change the print or display method for the corresponding class. You will need to know if you are dealing with a class S3 or S4. loos in ?methodsof ?methodsfor details. as a quick example, if you return the 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 changed the exANOVA function. add this to the end of ezANOVA.

class(return.value)<-"ezANOVA"
return(return.value)

then add a function print.ezANOVAthat should handle it.

+4
source

Source: https://habr.com/ru/post/1785314/


All Articles