[R] Using apply
jho|tm@n @end|ng |rom gm@||@com
Wed Oct 31 03:47:22 CET 2018
> s2 <- apply(x*x, 2, sum)
 55 330
Data Munger Guru
What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.
On Tue, Oct 30, 2018 at 10:28 PM Steven Yen <styen using ntu.edu.tw> wrote:
> I need help with "apply". Below, I have no problem getting the column sums.
> 1. How do I get the sum of squares?
> 2. In general, where do I look up these functions?
> x<-matrix(1:10,nrow=5); x
> sum <- apply(x,2,sum); sum
> [[alternative HTML version deleted]]
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help