On 17/02/11 09:44, Sam Steingold wrote:
summary() in functions seems to print nothing.
str() does print something.
why?
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.

--
Simon Blomberg, BSc (Hons), PhD, MAppStat, AStat
Lecturer and Consultant Statistician
School of Biological Sciences
The University of Queensland
St. Lucia Queensland 4072
Australia
T: +61 7 3365 2506
email: S.Blomberg1_at_uq.edu.au
http://www.uq.edu.au/~uqsblomb/

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem

Statistics is the grammar of science - Karl Pearson.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to