[R] Selected matrices of an array and put into a list

arun smartpink111 at yahoo.com
Mon Nov 12 14:46:23 CET 2012


Hi,
You can also use ?alply() 

library(plyr)
BB<-array(sample(1:500,3*5*27,replace=TRUE),dim=c(3,5,27))
res<-alply(BB,3,function(x) x)[2:27]
str(res)
List of 26
#$ 2 : int [1:3, 1:5] 337 476 331 481 168 111 439 151 399 430 ...
# $ 3 : int [1:3, 1:5] 77 171 225 498 277 37 429 472 215 351 ...
# $ 4 : int [1:3, 1:5] 243 393 274 113 266 175 210 404 450 4 ...
---------------------------------------------------------------------------
--------------------------------------------------------------------------
#$ 25: int [1:3, 1:5] 319 398 351 235 280 476 81 393 30 304 ...
# $ 26: int [1:3, 1:5] 153 187 63 252 17 150 22 439 320 382 ...
# $ 27: int [1:3, 1:5] 282 356 75 190 364 402 499 167 481 307 ...


A.K.




----- Original Message -----
From: Haris Rhrlp <haris_r_help at yahoo.com>
To: "R-help at r-project.org" <R-help at r-project.org>
Cc: 
Sent: Monday, November 12, 2012 2:56 AM
Subject: [R] Selected matrices of an array and put into a list

Dear R users,

I have an array that has matrices that i want BB[16,5,2:27]
i want to put each of the 26 matrices into a List 

thanks in advance
    [[alternative HTML version deleted]]


______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.





More information about the R-help mailing list