[R] uneven list to matrix

hadley wickham h.wickham at gmail.com
Fri Aug 24 18:12:43 CEST 2007


On 8/23/07, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> Here are two solutions.  The first repeatedly uses merge and the
> second creates a zoo object from each alph component whose time
> index consists of the row labels and uses zoo's multiway merge to
> merge them.
>
> # test data
> m <- matrix(1:5, 5, dimnames = list(LETTERS[1:5], NULL))
> alph <- list(m[1:4,,drop=F], m[c(1,3,4),,drop=F], m[c(1,4,5),,drop=F])
> alph

Or using reshape:

cast(melt(alph), X1 ~ L1)

Hadley



More information about the R-help mailing list