Closed leonfernandes closed 4 months ago
features()
allows for calculation of features from arbitrary expressions, and so "Trips"
is handled as a length 1 character vector.
To select columns with tidyselect you can use features_at()
.
E.g.
library(fabletools)
library(tsibble)
#>
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, union
head(tourism, 160) |>
features(Trips, features = list(mean = mean, sd = sd))
#> # A tibble: 2 x 5
#> Region State Purpose mean sd
#> <chr> <chr> <chr> <dbl> <dbl>
#> 1 Adelaide South Australia Business 156. 35.6
#> 2 Adelaide South Australia Holiday 157. 27.1
head(tourism, 160) |>
features_at("Trips", features = list(mean = mean, sd = sd))
#> # A tibble: 2 x 5
#> Region State Purpose Trips_mean Trips_sd
#> <chr> <chr> <chr> <dbl> <dbl>
#> 1 Adelaide South Australia Business 156. 35.6
#> 2 Adelaide South Australia Holiday 157. 27.1
Created on 2024-03-02 with reprex v2.0.2
As demonstrated in the reprex below, the
features.tbl_ts()
fails when.var
is a character string. Wrapping this function with a variable column name is a problem.Created on 2023-07-21 with reprex v2.0.2