R: How to merge logical elements in a list

user3969377

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?

Kara Woo

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to merge overlapping integer vector elements of a list in R

From Dev

How to merge elements of dataframes of different sizes containded in a list [R]?

From Dev

How to merge overlapping integer vector elements of a list in R

From Dev

R: merge elements of a list according to a vector of factors

From Dev

Merge a large list of logical vectors

From Dev

How to merge names with common elements in list?

From Dev

How to merge two elements in a list in Python

From Dev

How to merge elements within the same list?

From Dev

How to merge all elements in a list in R considering different names for merged variables

From Dev

Merge elements in list by property

From Dev

Merge elements in list by property

From Dev

How to reference .. .. elements in list in R?

From Dev

How to merge two lists? Preserving identical list elements for set manipulation

From Dev

String list to logical list optimization in R

From Dev

Group and Merge elements in same list

From Dev

how to merge duplicate elements?

From Dev

How to save the elements of a list individually in R?

From Dev

R: How to subset multiple elements from a list

From Dev

How to append all the elements of a list efficiently in R

From Dev

How to order all list elements by a vector in R?

From Java

How to add elements to a list in R (loop)

From Dev

How to find the largest N elements in a list in R?

From Dev

How to combine all the elements of list to a dataframe in R

From Dev

How to combine elements in a complicated list in R?

From Dev

How to unpack particular list elements into dataframes in R?

From Dev

How to combine elements from a data list in R?

From Dev

How to access elements of sorted list in R

From Dev

How to append all the elements of a list efficiently in R

From Dev

how to average groups of elements in a list in R?

Related Related

  1. 1

    How to merge overlapping integer vector elements of a list in R

  2. 2

    How to merge elements of dataframes of different sizes containded in a list [R]?

  3. 3

    How to merge overlapping integer vector elements of a list in R

  4. 4

    R: merge elements of a list according to a vector of factors

  5. 5

    Merge a large list of logical vectors

  6. 6

    How to merge names with common elements in list?

  7. 7

    How to merge two elements in a list in Python

  8. 8

    How to merge elements within the same list?

  9. 9

    How to merge all elements in a list in R considering different names for merged variables

  10. 10

    Merge elements in list by property

  11. 11

    Merge elements in list by property

  12. 12

    How to reference .. .. elements in list in R?

  13. 13

    How to merge two lists? Preserving identical list elements for set manipulation

  14. 14

    String list to logical list optimization in R

  15. 15

    Group and Merge elements in same list

  16. 16

    how to merge duplicate elements?

  17. 17

    How to save the elements of a list individually in R?

  18. 18

    R: How to subset multiple elements from a list

  19. 19

    How to append all the elements of a list efficiently in R

  20. 20

    How to order all list elements by a vector in R?

  21. 21

    How to add elements to a list in R (loop)

  22. 22

    How to find the largest N elements in a list in R?

  23. 23

    How to combine all the elements of list to a dataframe in R

  24. 24

    How to combine elements in a complicated list in R?

  25. 25

    How to unpack particular list elements into dataframes in R?

  26. 26

    How to combine elements from a data list in R?

  27. 27

    How to access elements of sorted list in R

  28. 28

    How to append all the elements of a list efficiently in R

  29. 29

    how to average groups of elements in a list in R?

HotTag

Archive