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

Allow list columns? #402

Closed
jonthegeek opened this issue Oct 25, 2019 · 4 comments
Closed

Allow list columns? #402

jonthegeek opened this issue Oct 25, 2019 · 4 comments
Labels
feature a feature request or enhancement long term

Comments

@jonthegeek
Copy link

Minimal, reproducible example:

test_data <- tibble::tibble(
  a = list(mtcars, mtcars),
  b = 1:2
)
recipes::recipe(test_data, b ~ .)
Error in model.frame.default(formula, data) : 
  invalid type (list) for variable 'a'

I understand this might be a weird case, but there are steps in textrecipes that expect a list column, and I've written a step of my own that expects a tibble. I was trying to do some of the setup (which involves a java engine and didn't play nice with parallel) outside of the recipe, and then use that data in a couple different recipes, but recipes won't let me start with a list. I can understand this error if it comes out of the prep as a list, but I'm not done with it yet.

@topepo topepo added the feature a feature request or enhancement label Jun 5, 2020
@topepo
Copy link
Member

topepo commented Jun 5, 2020

I think that we will eventually support this. I'll leave this open so that we can document thoughts/requirements here.

@kwiscion
Copy link

kwiscion commented Sep 4, 2020

It turns out that recipes can handle list columns, but only when using vars and roles arguments instead of a formula.

test_data <- tibble::tibble(
  a = list(mtcars, mtcars),
  b = 1:2
)
recipes::recipe(test_data, vars = c("a", "b"), roles = c("outcome", "predictor"))
Data Recipe

Inputs:

      role #variables
   outcome          1
 predictor          1

The issue with formula originates from function stats::model.frame() used to extract predictors names in function recipes:::get_rhs_vars().

@EmilHvitfeldt
Copy link
Member

An unexpected side-effect of #1283 means that recipes now support list-columns

library(recipes)

test_data <- tibble::tibble(
  a = list(mtcars, mtcars),
  b = 1:2
)

recipe(test_data, b ~ .)
#> 
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#> 
#> ── Inputs
#> Number of variables by role
#> outcome:   1
#> predictor: 1

Copy link

github-actions bot commented Jun 9, 2024

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 Jun 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature a feature request or enhancement long term
Projects
None yet
Development

No branches or pull requests

4 participants