cols_class: Create function(s) to identify column by class

View source: R/cols_class.R

cols_classR Documentation

Create function(s) to identify column by class

Description

Create function(s) to identify column by class

Usage

cols_class(...)

Arguments

...

vector of (quoted) column classes to identify

Details

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.

Value

A function that identifies columns in x according to ...

Examples

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

slin30/wzMisc documentation built on Jan. 27, 2023, 1 a.m.