R-alpha: apply()

Kurt Hornik Kurt.Hornik@ci.tuwien.ac.at
Fri, 22 Aug 1997 12:37:36 +0200


The following is identical in R and S, but still strange ...

R> apply(matrix(1:20, nc = 4), 1, table)
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    1    1    1    1
[2,]    1    1    1    1    1
[3,]    1    1    1    1    1
[4,]    1    1    1    1    1
R> apply(matrix(rep(1, 20), nc = 4), 1, table)
[1] 4 4 4 4 4
R> apply(matrix(c(1:4, 1, 6 : 8), nc = 4), 1, table)
[[1]]
1 3 7 
2 1 1 

[[2]]
2 4 6 8 
1 1 1 1

-k
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-