Re: [R] do.call, missing arguments and [

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Thu 19 Jan 2006 - 10:31:40 EST

On 1/18/06, hadley wickham <h.wickham@gmail.com> wrote:
> x <- array(1:30, c(4,5,3))
> x[1,,]
>
> How can I do the same thing with do.call?

do.call("[", list(x, 1, TRUE, TRUE))

seems to work for me.

Deepayan

>
> do.call("[", list(x, 1)) == x[1]
> do.call("[", list(x, 1, NULL, NULL)) == x[1, NULL, NULL]
>
> I guess you can't, because of the special way that [ deals with arguments.
>
> How can I index an array programmatically for arrays and indices of
> varying dimensionality?



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jan 19 10:39:53 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:06 EST