typly {cheese}R Documentation

Evaluate a function on columns conforming to one or more (or no) specified types

Description

Apply a function to columns in a data.frame that inherit one of the specified types.

Usage

typly(
    data,
    f,
    types,
    negated = FALSE,
    ...
)

Arguments

data

A data.frame.

f

A function.

types

A character vector of classes to test against.

negated

Should the function be applied to columns that don't match any types? Defaults to FALSE.

...

Additional arguments to be passed to f.

Value

A list

Author(s)

Alex Zajichek

Examples

heart_disease %>%
    
    #Compute means on numeric or logical data
    typly(
        f = mean,
        types = c("numeric", "logical"),
        na.rm = TRUE
    ) 

[Package cheese version 0.1.2 Index]