Closed njtierney closed 4 years ago
All values of the vector needs names if multiple values will be returned. There shouldn't be this many warnings (one per column is appropriate), but this is how I would use range()
:
library(brolgar)
# range
wages %>%
features(ln_wages,
list(range = ~ setNames(range(.), c("min", "max"))))
#> # A tibble: 888 x 3
#> id range_min range_max
#> <int> <dbl> <dbl>
#> 1 31 1.43 2.13
#> 2 36 1.80 2.93
#> 3 53 1.54 3.24
#> 4 122 0.763 2.92
#> 5 134 2.00 2.93
#> 6 145 1.48 2.04
#> 7 155 1.54 2.64
#> 8 173 1.56 2.34
#> 9 206 2.03 2.48
#> 10 207 1.58 2.66
#> # … with 878 more rows
Created on 2020-08-20 by the reprex package (v0.3.0)
Neat! Thanks for that! So there isn't currently a way to specify names within features
?
Also if it is helpful I'd be happy to document this behaviour in fabletools, since I'll be doing it for brolgar as well
More documentation is always welcomed.
How do you mean by 'specify names within features
'? Do you have a proposed interface improvement?
I've noticed that when passing
features
a function that outputs something of lenght > 1, you get a long warning of renaming - I just wanted to check if this was expected behavhouiur? It's quite cool that this just works! I can get as many columns as there are outputs from the function. But just wanted to raise it as I hasn't seen it documented.Created on 2020-08-19 by the reprex package (v0.3.0)