Skip to content

step_harmonic() should create predictors #822

Description

@juliasilge

The new step_harmonic() should not have NA here because it creates new columns:

role = NA,

Even if I do manually set it to "predictor" something is going wrong with the printing:

library(recipes)
#> Loading required package: dplyr
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
#> 
#> Attaching package: 'recipes'
#> The following object is masked from 'package:stats':
#> 
#>     step
data(sunspot.year)
sunspots <-
  tibble(year = 1700:1988,
         n_sunspot = sunspot.year)

rec <- 
  recipe(n_sunspot ~ year, data = sunspots) %>%
  step_harmonic(year, frequency = 1 / 11, cycle_size = 1, 
                role = "predictor") 

prep(rec)
#> Recipe
#> 
#> Inputs:
#> 
#>       role #variables
#>    outcome          1
#>  predictor          1
#> 
#> Training data contained 289 data points and no missing data.
#> 
#> Operations:
#> 
#> Harmonic numeric variables for
#> Error in if (nchar(txt) == 0) txt <- "<none>": argument is of length zero

Created on 2021-09-27 by the reprex package (v2.0.1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions