[R] do.call, missing arguments and [

hadley wickham h.wickham at gmail.com
Wed Jan 18 23:29:49 CET 2006


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)) == 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?

Thanks,

Hadley




More information about the R-help mailing list