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 · 1 comment
Closed

roles and possible type to list columns #221

topepo opened this issue Oct 8, 2018 · 1 comment
Assignees

Comments

@topepo
Copy link
Collaborator

@topepo 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.

@topepo topepo added this to To do in Package: recipes Oct 8, 2018
@EmilHvitfeldt
Copy link
Contributor

@EmilHvitfeldt EmilHvitfeldt commented Oct 8, 2018

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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.