Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues making splines with single row data frames #1191

Closed
topepo opened this issue Aug 25, 2023 · 1 comment · Fixed by #1192
Closed

issues making splines with single row data frames #1191

topepo opened this issue Aug 25, 2023 · 1 comment · Fixed by #1192
Assignees
Labels
bug an unexpected problem or unintended behavior

Comments

@topepo
Copy link
Member

topepo commented Aug 25, 2023

First seen in tidymodels/TMwR#367

library(tidymodels)
tidymodels_prefer()
theme_set(theme_bw())
options(pillar.advice = FALSE, pillar.min_title_chars = Inf)
ns_rec <- 
  recipe(mpg ~ ., data = mtcars) %>% 
  step_ns(disp, deg_free = 3) %>% 
  prep()

bake(ns_rec, mtcars %>% slice(1))
#> Error in if (num < 1) {: argument is of length zero

ns2_rec <- 
  recipe(mpg ~ ., data = mtcars) %>% 
  step_spline_natural(disp, deg_free = 3) %>% 
  prep()

bake(ns2_rec, mtcars %>% slice(1))
#> Error in if (num < 1) {: argument is of length zero

Created on 2023-08-25 with reprex v2.0.2

For step_ns(), it is an issue with stripping off attributes (I assume the dim attribute).

For step_spline_natrual(), it is using I() rowwise that is dropping the dimension.

@topepo topepo added the bug an unexpected problem or unintended behavior label Aug 25, 2023
@github-actions
Copy link

github-actions bot commented Sep 9, 2023

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants