[R] how convert an array to a matrix?

Sven Garbade garbade at psy.uni-muenchen.de
Fri Apr 14 11:57:17 CEST 2000

Hi Peter,

thanks for your code, it works fine. I´ve calculated the dimnames from
the inidces by simple arithemic.

Bye, Sven 

Peter Dalgaard BSA wrote:

> cbind(as.vector(slice(x,1)),
>         as.vector(slice(x,2)),
>         as.vector(slice(x,3)),
>         as.vector(x))
> where slice is the generalised row()/col()/... function which we
> haven't got in R (yet):
> slice<-function(x,i) sweep(x, i, 1:dim(x)[i], function(x,y) y )
> Hmm...that's not quite right. You want the dimnames in there instead
> of 1:dim(x)[i], but you get the general idea.
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list