[R] Subsetting array (NA:s)
Lauri Nikkinen
lauri.nikkinen at iki.fi
Thu Jan 10 16:29:16 CET 2008
Hi R-users,
I have an array similar to this:
tmp <- array(1:6, c(2,3,3))
n1 <- c("one", "two")
n2 <- c("three", "four", "five")
n3 <- c("six", "seven", "eight")
dimnames(tmp) <- list(n1, n2, n3)
tmp[1,,1] <- NA
tmp[1,3,2] <- NA
tmp[2,,3] <- NA
tmp
How to subset !is.na(x) rows resulting
, , six
three four five
two 2 4 6
, , seven
three four five
one 1 3 NA
two 2 4 6
, , eight
three four five
one 1 3 5
I have tried something like
tmp[!apply(is.na(tmp), 1, all),,]
with negative results.
Thanks
-Lauri
More information about the R-help
mailing list