[R] Help understanding behavior of apply vs sapply
Seth Falcon
sfalcon at fhcrc.org
Tue Mar 28 03:40:50 CEST 2006
Hi,
I was surprised that apply and sapply don't return the same results in
the example below. Can someone tell me what I'm missing?
> zls <- function(x) character(0)
> m <- matrix(0, nrow=2, ncol=2)
> apply(m, 1, zls)
character(0)
> sapply(m, zls)
[[1]]
character(0)
[[2]]
character(0)
[[3]]
character(0)
[[4]]
character(0)
> R.version
_
platform powerpc-apple-darwin8.5.0
arch powerpc
os darwin8.5.0
system powerpc, darwin8.5.0
status alpha
major 2
minor 3.0
year 2006
month 03
day 27
svn rev 37590
language R
version.string Version 2.3.0 alpha (2006-03-27 r37590)
More information about the R-help
mailing list