| cols_class | R Documentation |
Create function(s) to identify column by class
cols_class(...)
... |
vector of (quoted) column classes to identify |
For >1 class, ... accepts either a vector of target classes or multiple
vectors of length 1, or a combination. See examples.
Note that as long as one of the classes in ... is found in x, the closure
output will return a value. If no clases in ... are found in x, the closure
output will throw an error.
A function that identifies columns in x according to ...
df <- data.frame(int_col = 1L, num_col = 1,
chr_col = "1", logi_col = TRUE,
fctr_col = factor("1"),
chr_col2 = "2",
stringsAsFactors = FALSE)
find_chr <- cols_class("character")
find_fct <- cols_class("factor")
find_chr.fct <- cols_class(c("character", "factor"))
find_chr.fct_alt <- cols_class("character", "factor") #same
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.