Skip to content

issues making splines with single row data frames #1191

@topepo

Description

@topepo

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.

Metadata

Metadata

Assignees

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