Skip to content

summary in functions

2 messages · Sam Steingold, Simon Blomberg

#
On 17/02/11 09:44, Sam Steingold wrote:
summary() returns the summary information as its value. If you want to 
see this value from inside a function, use print(summary()). The reason 
you see the summary information at the top level is because R implicitly 
assumes that you want to print() the summary() output. This is the same 
for any object. Typing obj at the prompt is really the same as doing 
print(obj). In contrast, str() does not return a value, and you see the 
output printed because it is a side-effect of calling the function. 
(This behaviour irks me as it is not good functional programming style, 
although ?str says that it does not return a value for "efficiency 
reasons").

Cheers,

Simon.