Skip to content

Have steps return integers when appropriate #766

@EmilHvitfeldt

Description

@EmilHvitfeldt

Some steps that return what are essentially integers are returning them as doubles. It might be helpful to handle the conversion to help with object sizes.

library(recipes)
library(modeldata)

data("Chicago")

recipe(ridership ~ date, data = Chicago) %>%
  step_date(date, label = FALSE, keep_original_cols = FALSE) %>%
  prep() %>%
  bake(new_data = NULL)
#> # A tibble: 5,698 × 4
#>    ridership date_dow date_month date_year
#>        <dbl>    <dbl>      <dbl>     <dbl>
#>  1     15.7         2          1      2001
#>  2     15.8         3          1      2001
#>  3     15.9         4          1      2001
#>  4     15.9         5          1      2001
#>  5     15.4         6          1      2001
#>  6      2.42        7          1      2001
#>  7      1.47        1          1      2001
#>  8     15.5         2          1      2001
#>  9     15.9         3          1      2001
#> 10     15.9         4          1      2001
#> # … with 5,688 more rows

recipe(ridership ~ date, data = Chicago) %>%
  step_date(date, keep_original_cols = FALSE) %>%
  step_dummy(all_nominal_predictors()) %>%
  prep() %>%
  bake(new_data = NULL)
#> # A tibble: 5,698 × 19
#>    ridership date_year date_dow_Mon date_dow_Tue date_dow_Wed date_dow_Thu
#>        <dbl>     <dbl>        <dbl>        <dbl>        <dbl>        <dbl>
#>  1     15.7       2001            1            0            0            0
#>  2     15.8       2001            0            1            0            0
#>  3     15.9       2001            0            0            1            0
#>  4     15.9       2001            0            0            0            1
#>  5     15.4       2001            0            0            0            0
#>  6      2.42      2001            0            0            0            0
#>  7      1.47      2001            0            0            0            0
#>  8     15.5       2001            1            0            0            0
#>  9     15.9       2001            0            1            0            0
#> 10     15.9       2001            0            0            1            0
#> # … with 5,688 more rows, and 13 more variables: date_dow_Fri <dbl>,
#> #   date_dow_Sat <dbl>, date_month_Feb <dbl>, date_month_Mar <dbl>,
#> #   date_month_Apr <dbl>, date_month_May <dbl>, date_month_Jun <dbl>,
#> #   date_month_Jul <dbl>, date_month_Aug <dbl>, date_month_Sep <dbl>,
#> #   date_month_Oct <dbl>, date_month_Nov <dbl>, date_month_Dec <dbl>

Created on 2021-08-10 by the reprex package (v2.0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementlong term

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions