Skip to content

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

Description

@boshek

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)" 
   )) 
 } 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions