-
Notifications
You must be signed in to change notification settings - Fork 417
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
Feature Request: Allow across() for column selection in complete() #1523
Comments
Just for completeness and to help someone else that has the same problem, here is my work around. The difficult problem is that I have a vector of group variables and in my problem, the length of the vector could be arbitrary and
|
Not to detract from the request, but the following might be a simpler fix in the interim: library(tidyverse)
df <- data.frame(
group1=factor(c('A','B'), levels=c('A','B','C')),
group2=factor(c('W','X'), levels=c('W','X')),
value = 1:2)
vector <- c('group1','group2')
df |> complete(!!! rlang::parse_exprs(vector))
#> # A tibble: 6 × 3
#> group1 group2 value
#> <fct> <fct> <int>
#> 1 A W 1
#> 2 A X NA
#> 3 B W NA
#> 4 B X 2
#> 5 C W NA
#> 6 C X NA Created on 2023-10-05 with reprex v2.0.2 |
@JakeRuss |
Duplicate of #1397 |
Because
complete()
can't act on grouping variables, we need to be able to work around this when necessary. One solution is to pull the grouping variables viagroup_vars()
, thenungroup()
the data and supply those strings tocomplete()
. However, complete does not accept string inputs via direct use ofall_of( )
orany_of()
or the indirect use inside ofacross()
viaacross(all_of( my_grp_vars ))
solution. All of the other more nebulous tricks that I've found success in other scenarios, (e.g. {{ }}, !!ensym(), or !!enquo() ) also don't work.The text was updated successfully, but these errors were encountered: