features {fabletools} | R Documentation |
Extract features from a dataset
Description
Create scalar valued summary features for a dataset from feature functions.
Usage
features(.tbl, .var, features, ...)
features_at(.tbl, .vars, features, ...)
features_all(.tbl, features, ...)
features_if(.tbl, .predicate, features, ...)
Arguments
.tbl |
A dataset |
.var |
An expression that produces a vector from which the features are computed. |
features |
A list of functions (or lambda expressions) for the features to compute. |
... |
Additional arguments to be passed to each feature. These arguments will only be passed to features which use it in their formal arguments ( |
.vars |
A tidyselect compatible selection of the column(s) to compute features on. |
.predicate |
A predicate function (or lambda expression) to be applied to the columns or a logical vector. The variables for which .predicate is or returns TRUE are selected. |
Details
Lists of available features can be found in the following pages:
See Also
Examples
# Provide a set of functions as a named list to features.
library(tsibble)
tourism %>%
features(Trips, features = list(mean = mean, sd = sd))
# Search and use useful features with `feature_set()`.
library(feasts)
tourism %>%
features(Trips, features = feature_set(tags = "autocorrelation"))
# Best practice is to use anonymous functions for additional arguments
tourism %>%
features(Trips, list(~ quantile(., probs=seq(0,1,by=0.2))))