[Rd] vapply confusion
Dominick Samperi
djsamperi at gmail.com
Sat Apr 12 06:39:10 CEST 2014
The following code seems to contain an inconsistency in
the behavior of vapply(). Am I missing something here?
## This function assumes v is a 3d vector, beta a scalar.
f3d <- function(v,beta) { v+beta }
## This expression applies f3d to a vector of scalars, and
## specifies the template 'array(10,3)' for the return value.
dat <- vapply(seq(0,1,length=10), function(beta) {
f3d(c(0,0,0), beta) }, array(10,3))
dim(dat) # 3 10 (the dimensions are the reverse of the template?)
Of course, a transpose will patch the result to match the
specified template.
More information about the R-devel
mailing list