-
Notifications
You must be signed in to change notification settings - Fork 112
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
loopify step_profile() #1177
loopify step_profile() #1177
Conversation
|
||
for (i in names(object$columns)) { | ||
new_data[[i]] <- rep(object$columns[[i]], n) | ||
new_data <- list() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it easier to create a empty list, fill it, order it, tibblify it. Than to modify the existing tibble, order it making sure the lengths matched
new_data[[names(object$profile)]] <- object$profile[[1]] | ||
|
||
new_data <- vctrs::vec_recycle_common(!!!new_data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is so cool! We can avoid doing rep(value, n)
aaa <- list(1, 2, 4, 1:5)
vctrs::vec_recycle_common(!!!aaa)
#> [[1]]
#> [1] 1 1 1 1 1
#>
#> [[2]]
#> [1] 2 2 2 2 2
#>
#> [[3]]
#> [1] 4 4 4 4 4
#>
#> [[4]]
#> [1] 1 2 3 4 5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dig it! One note on a pattern we may be able to use elsewhere in these PRs. :)
Co-authored-by: Simon P. Couch <[email protected]>
This pull request 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. |
Related to #1156.
This PR does a small refactor to
step_profile()
to bring them up to the same standard as #1156.This step is quite different that most other steps as it doesn't use the
new_data
inbake()
, so many of the check functions we normally use shouldn't be done here.