From djsamperi at gmail.com  Sat Apr 12 06:39:10 2014
From: djsamperi at gmail.com (Dominick Samperi)
Date: Sat, 12 Apr 2014 00:39:10 -0400
Subject: [Rd] vapply confusion
Message-ID: <CADUbQ5gKwR+gMpjALkizH77zNj6ds4NbxX_-Kq5OjO+gqJo4=g@mail.gmail.com>

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.



[Rd] vapply confusion
Dominick Samperi