[R] mean vs sum behavior

From: Emmanuel Castella <Emmanuel.Castella_at_leba.unige.ch>
Date: Mon, 31 Mar 2008 18:41:51 +0200


Dear all
Could someone explain me why
lapply(split(x,fac),mean)
returns means per levels of fac for each column of x whereas
lapply(split(x,fac),sum)
does not return sums per level of fac and columns of x, but adds all columns together?
Hence, how can I get sum to behave as mean in this instance? Thank you very much in advance
E. Castella



R-help_at_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. Received on Mon 31 Mar 2008 - 16:53:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 31 Mar 2008 - 17:30:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive