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

roles and possible type to list columns #221

Closed
topepo opened this issue Oct 8, 2018 · 2 comments · Fixed by #245
Closed

roles and possible type to list columns #221

topepo opened this issue Oct 8, 2018 · 2 comments · Fixed by #245

Comments

@topepo
Copy link
Member

topepo commented Oct 8, 2018

In the spirit of breaking changes for the next version... ☹️

For example:

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
recipe(Sepal.Length ~ ., data = iris) %>%
  summary()
#> # A tibble: 5 x 4
#>   variable     type    role      source  
#>   <chr>        <chr>   <chr>     <chr>   
#> 1 Sepal.Width  numeric predictor original
#> 2 Petal.Length numeric predictor original
#> 3 Petal.Width  numeric predictor original
#> 4 Species      nominal predictor original
#> 5 Sepal.Length numeric outcome   original

Created on 2018-10-08 by the reprex package (v0.2.1)

There are certainly occasions where a column can play more than one role.

We also might want to have more granular type attributes. For example, should a date field have types of "numeric" and "date"?

This would affect the functionality of add_role and we might need an additional change_role since the former should append and the latter should reset.

@EmilHvitfeldt
Copy link
Member

This change would also need changes to the various check functions that now expect a single type/role.

Would you ever need to have exclusive selections?
Selection all the numeric types that aren't date types.

Additionally, should change_role replace a single type with another or replace the entire list of types? Having the change_role reset the types might remove type information not considered in said step.

Maybe having add_role, change_role and reset_role might work.

roles <- c("numeric", "date")

add_role(roles, "fun")
#> [1] "numeric" "date" "fun"

change_role(roles, from = "numeric", to = "character")
#> [1] "character" "date"

reset_role(roles, "character")
#> [1] "character"

@github-actions
Copy link

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 Feb 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Development

Successfully merging a pull request may close this issue.

3 participants