View source: R/general_utils.R
cfilter | R Documentation |
Filters a list, keeping or excluding elements based on their class.
cfilter(x, class, not = FALSE)
x |
A list of R objects. |
class |
A character string specifying the class to filter by. |
not |
Logical; if 'TRUE', elements *not* inheriting from 'class' are kept. Default is 'FALSE'. |
A list containing the elements of 'x' that (do not) inherit from the specified class.
lst <- list(1L, "text", 3.14, list(a = 1))
cfilter(lst, "numeric") # returns elements that are numeric
cfilter(lst, "character") # returns character elements
cfilter(lst, "numeric", not = TRUE) # returns elements that are NOT numeric
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.