Filter a List by Class
cfilter.Rd
Filters a list, keeping or excluding elements based on their class.
Examples
lst <- list(1L, "text", 3.14, list(a = 1))
cfilter(lst, "numeric") # returns elements that are numeric
#> [[1]]
#> [1] 3.14
#>
cfilter(lst, "character") # returns character elements
#> [[1]]
#> [1] "text"
#>
cfilter(lst, "numeric", not = TRUE) # returns elements that are NOT numeric
#> [[1]]
#> [1] 1
#>
#> [[2]]
#> [1] "text"
#>
#> [[3]]
#> [[3]]$a
#> [1] 1
#>
#>