[R] generic arrays in R

Tamas K Papp tpapp at Princeton.EDU
Fri Nov 3 17:05:55 CET 2006


On Fri, Nov 03, 2006 at 07:20:34AM +0000, Prof Brian Ripley wrote:

> but
> 
> a <- array(list(f),c(2,2))
> a[[2,1]]

Thank you very much.  Can you please tell me how to make apply
generate arrays like this?  Eg if

a <- array(1:16,rep(2,4))

then a

apply(a,c(1,2,4), polynomial)

will just give me a regular array of numbers, and

apply(a,c(1,2,4),function(x) list(polynomial(x)))

give me a generic array, but the polynomials I want are inside lists:
I need constructs like [[1,1,1]][[1]] to access them.  I would like to
get a 3-way array with polynomials in it.  It seems to work with
function(x) splinefun(c(0,1),x) instead of polynomial, but array just
converts polynomials into vectors...  How can I protect them?

Thank you,

Tamas



More information about the R-help mailing list