[R] Creating a ragged array
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Feb 11 17:16:41 CET 2011
On Fri, Feb 11, 2011 at 10:39 AM, Barth B. Riley <bbriley at chestnut.org> wrote:
> Dear list
>
> I am trying to figure out how to create a ragged array that consists of groups of array elements (indices from the original array) of similar values. I would like to create a ragged array that might look something like this:
>
> S[1]
> 11, 19, 14,7
>
> S[2]
> 29,4,1,13,44
>
> S[3]
> 56,9,2,35
>
> S[4]
> 3,5
>
Try stack and unstack:
S <- list(A = c(11,19,14,7), B = c(29,4,1,13,44), C = c(56,9,2,35), D
= c(3,5)); S
stk <- stack(S); stk
ustk <- unstack(stk); ustk
identical(ustk, S) # TRUE
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list