[R] subsetting 3D array
arun
smartpink111 at yahoo.com
Fri Jan 10 04:23:49 CET 2014
Hi Alex,
Try:
set.seed(345)
results<- array(sample(-5:5,120,replace=TRUE),dim=c(10,3,4))
indx <- !!apply(results,1,sum)
library(plyr)
results2 <- laply(lapply(seq(dim(results)[1]),function(i) results[i,,])[indx],identity)
attr(results2,"dimnames") <- NULL
dim(results2)
#[1] 9 3 4
A.K.
I have a 3D array with 13,000 11x8 matrices.
dim(results
[1] 13000 11 8
Some matrices in the array add up to 0. For example
sum(results[1,,])==0
[1] TRUE
I would like to remove these. How can I do this?
More information about the R-help
mailing list