-
Notifications
You must be signed in to change notification settings - Fork 57
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
Correctly handle NA
column names from pivot_wider()
#395
Conversation
FYI checks are passing now that #393 is merged (so we're definitely good for review). |
I don't follow the numeric substitution logic. I don't think I'd expect Do we even need to change
right after this: dtplyr/R/step-call-pivot_wider.R Lines 69 to 75 in 55e9298
Does that solve the issue? |
Hmm now that you mention it it is probably better to just ignore the numeric case in |
@eutwt ready for review again.
I think it's a good idea to fix this in |
In my mind it would be cleaner if the But, this is an extremely minor point, up to opinion, and the function is internal anyway. I think this is fine to merge as-is Behavior comparisonMain: new_name <- names(ToothGrowth)[6] # missing by mistaken index
step_setnames(
lazy_dt(ToothGrowth),
"dose",
new_name,
in_place = FALSE
)
#> Error: NA in 'new' at positions [1] old_name <- names(ToothGrowth)[6] # missing by mistaken index
step_setnames(
lazy_dt(ToothGrowth %>% mutate("NA" = 3)),
old_name,
"new",
in_place = FALSE
)
#> Error: NA in 'new' at positions [1] This PR: new_name <- names(ToothGrowth)[6] # missing by mistaken index
step_setnames(
lazy_dt(ToothGrowth),
"dose",
new_name,
in_place = FALSE
)
#> Source: local data table [60 x 3]
#> Call: setnames(`_DT1`, "dose", "NA")
#>
#> len supp `NA`
#> <dbl> <fct> <dbl>
#> 1 4.2 VC 0.5
#> 2 11.5 VC 0.5
#> 3 7.3 VC 0.5
#> 4 5.8 VC 0.5
#> 5 6.4 VC 0.5
#> 6 10 VC 0.5
#> # … with 54 more rows
#>
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results old_name <- names(ToothGrowth)[6] # missing by mistaken index
step_setnames(
lazy_dt(ToothGrowth %>% mutate("NA" = 3)),
old_name,
"new",
in_place = FALSE
)
#> Source: local data table [60 x 4]
#> Call: setnames(`_DT1`, "NA", "new")
#>
#> len supp dose new
#> <dbl> <fct> <dbl> <dbl>
#> 1 4.2 VC 0.5 3
#> 2 11.5 VC 0.5 3
#> 3 7.3 VC 0.5 3
#> 4 5.8 VC 0.5 3
#> 5 6.4 VC 0.5 3
#> 6 10 VC 0.5 3
#> # … with 54 more rows
#>
#> # Use as.data.table()/as.data.frame()/as_tibble() to access results |
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.
See minor comment, but don't necessarily need to address
Wouldn't any workaround we build run into this issue? (like the one mentioned in here) |
Basically I see this as being due to the
|
Ah yep, that makes sense. |
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.
👍
NA
column names in step_setnames()
NA
column names from pivot_wider()
Closes #394
Pretty sure this is failing checks due to things updated in #393. So we can wait to merge until that is ready to go.