I have data like the following
set.seed(1)
glist <- lapply(1:5,function(i){sample(c(TRUE,FALSE),1)})
I would like the index locations of the FALSE values, c(3,4). I am trying to coerce the list array into an array with
tf_array <- Reduce(merge,glist)
the output is
[1] y x
<0 rows> (or 0-length row.names)
the output I was expecting is below, and then I was going to use the which function.
c(TRUE,TRUE,FALSE,FALSE,TRUE).
How do I locate the indices of the FALSE entries in a list of logical values?
unlist(glist)
gives the output you're expecting:
[1] TRUE TRUE FALSE FALSE TRUE
Then, using which()
:
which(!unlist(glist))
# [1] 3 4
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments