Apply a function to columns in a data.frame
that inherit one of the specified types.
typly(
data,
f,
types,
negated = FALSE,
...
)
A list
A data.frame
.
A function
.
A character
vector of classes to test against.
Should the function be applied to columns that don't match any types
? Defaults to FALSE
.
Additional arguments to be passed to f
.
Alex Zajichek
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