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

Consider changing dplyr suggestion in pivot_wider to use .by #1516

Closed
boshek opened this issue Sep 20, 2023 · 1 comment · Fixed by #1529
Closed

Consider changing dplyr suggestion in pivot_wider to use .by #1516

boshek opened this issue Sep 20, 2023 · 1 comment · Fixed by #1529
Labels
feature a feature request or enhancement

Comments

@boshek
Copy link
Contributor

boshek commented Sep 20, 2023

Given the introduction of the .by syntax, I wonder if it would be worth while changing this nice little helper message to use that making it a little smaller:

So that would change this:

tidyr/R/pivot-wide.R

Lines 439 to 449 in 0764e65

cli::cli_warn(c(
"Values from {duplicate_names} are not uniquely identified; output will contain list-cols.",
"*" = "Use `values_fn = list` to suppress this warning.",
"*" = "Use `values_fn = {{summary_fun}}` to summarise duplicates.",
"*" = "Use the following dplyr code to identify duplicates.",
" " = " {{data}} %>%",
" " = " dplyr::group_by({group_cols}) %>%",
" " = " dplyr::summarise(n = dplyr::n(), .groups = \"drop\") %>%",
" " = " dplyr::filter(n > 1L)"
))
}

to this:

   cli::cli_warn(c( 
     "Values from {duplicate_names} are not uniquely identified; output will contain list-cols.", 
     "*" = "Use `values_fn = list` to suppress this warning.", 
     "*" = "Use `values_fn = {{summary_fun}}` to summarise duplicates.", 
     "*" = "Use the following dplyr code to identify duplicates.", 
     " " = "  {{data}} %>%", 
     " " = "    dplyr::summarise(n = dplyr::n(), .by = c({group_cols})) %>%", 
     " " = "    dplyr::filter(n > 1L)" 
   )) 
 } 
@hadley hadley added documentation feature a feature request or enhancement and removed documentation labels Nov 1, 2023
@hadley
Copy link
Member

hadley commented Nov 1, 2023

For sure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants