This reminds me that I had been meaning to submit an enhancement of abind() that allows the first argument to be a list of arrays so that you could simply do abind(list.of.arrays, along=4), as I find this is a very common pattern.
-- Tony Plate
At Tuesday 04:48 PM 10/21/2003 +0100, Robin Hankin wrote:
Hi everyone
I've been playing with do.call() but I'm having problems understanding it.
I have a list of "n" elements, each one of which is "d" dimensional [actually an n-by-n-by ... by-n array]. Neither n nor d is known in advance. I want to bind the elements together in a higher-dimensional array.
Toy example follows with d=n=3.
f <- function(n){array(n,c(3,3,3))} x <- sapply(1:3,f,simplify=FALSE)
Then what I want is
ans <- abind(x[[1]] , x[[2]] , x[[3]] , along=4)
[abind() is defined in library(abind)].
Note that dim(ans) is c(3,3,3,3), as required.
PROBLEM: how do I do tell do.call() that I want to give abind() the extra argument along=4 (in general, I want along=length(dim(x[[1]]))+1)?
Oblig Attempt:
jj <- function(...){abind(... , along=4)} do.call("jj" , x)
This works, because I know that d=3 (and therefore use along=4), but it doesn't generalize easily to arbitrary d. I'm clearly missing something basic. Anyone?
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help