50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

cheese (version 0.1.2)

typly: 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,
    ...
)

Value

A list

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.

Author

Alex Zajichek

Examples

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

Run the code above in your browser using DataLab