GotelliLab / EcoSimR

Repository for EcoSimR, by Gotelli, N.J. , Hart E. M. and A.M. Ellison. 2014. EcoSimR 0.1.0
http://ecosimr.org
Other
27 stars 10 forks source link

`summary` methods should not do any printing` #68

Open gavinsimpson opened 9 years ago

gavinsimpson commented 9 years ago

summary methods should not, by themselves do any printing. What they should do is create (and return) an R object that has all the information you wish to include in the summary. This object should have the class "summary.foo" if the summary method is summary.foo(). Then you add a print method for class summary.foo, print.summary.foo(), and it is that print method that should write messages to the screen and/or print all or parts of that summary.

Here is one instance in EcoSimR where you don't follow the proper conventions:

https://github.com/GotelliLab/EcoSimR/blob/master/R/coccurrence_null.R#L78

The reason for this convention is that if the summary information is that useful/interesting to the user, they might want that information in an R object, hence the summary creates & returns that object and it's own print method then handles showing the printed representation to the user.

emhart commented 9 years ago

Thanks @gavinsimpson I'll make that fix in the next version.