Skip to content

Add locale argument to step_date() #1000

@juliasilge

Description

@juliasilge

Thanks to @cderv for highlighting this problem:

library(recipes)
#> Le chargement a nécessité le package : dplyr
#> 
#> Attachement du package : 'dplyr'
#> Les objets suivants sont masqués depuis 'package:stats':
#> 
#>     filter, lag
#> Les objets suivants sont masqués depuis 'package:base':
#> 
#>     intersect, setdiff, setequal, union
#> 
#> Attachement du package : 'recipes'
#> L'objet suivant est masqué depuis 'package:stats':
#> 
#>     step

examples <- tibble(someday = lubridate::ymd("2000-12-20") + lubridate::days(0:40))
recipe(~ someday, examples) %>%
  step_date(all_predictors()) %>%
  prep() %>%
  bake(new_data = examples)
#> # A tibble: 41 × 4
#>    someday    someday_dow someday_month someday_year
#>    <date>     <fct>       <fct>                <dbl>
#>  1 2000-12-20 "mer\\."    déc                   2000
#>  2 2000-12-21 "jeu\\."    déc                   2000
#>  3 2000-12-22 "ven\\."    déc                   2000
#>  4 2000-12-23 "sam\\."    déc                   2000
#>  5 2000-12-24 "dim\\."    déc                   2000
#>  6 2000-12-25 "lun\\."    déc                   2000
#>  7 2000-12-26 "mar\\."    déc                   2000
#>  8 2000-12-27 "mer\\."    déc                   2000
#>  9 2000-12-28 "jeu\\."    déc                   2000
#> 10 2000-12-29 "ven\\."    déc                   2000
#> # … with 31 more rows

Created on 2022-06-07 by the reprex package (v2.0.1)

I had deployed a workflow that used step_date(), and he could not predict from it locally because of the language difference.

We could:

  • at the least document this possible problem
  • save at prep() time the transformations used so they can be applied at bake() time

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions