On Sun, 6 Nov 2005, Kjetil Brinchmann halvorsen wrote:
examples snipped
Why doesn't paste behave in apply as sum?
Because sum maps a vector of inputs to a single output, but paste does
not, unless you use collapse=
-thomas
__
I was surprised by:
test - matrix( as.character(1:4), 2)
test
[,1] [,2]
[1,] 1 3
[2,] 2 4
apply(test, 1, paste, sep=+)
[,1] [,2]
[1,] 1 2
[2,] 3 4
apply(test, 1, paste, sep=*)
[,1] [,2]
[1,] 1 2
[2,] 3 4
te - matrix(1:4, 2)
te
[,1] [,2]
[1,]13
halvorsen
Sent: Sunday, November 06, 2005 5:34 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Use of paste with apply()
I was surprised by:
test - matrix( as.character(1:4), 2)
test
[,1] [,2]
[1,] 1 3
[2,] 2 4
apply(test, 1, paste, sep=+)
[,1] [,2]
[1,] 1 2
[2,] 3 4