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

CRAN tidyr accidentally allows specification of pivot_wider() with empty names_from / values_from #1240

Closed
DavisVaughan opened this issue Nov 23, 2021 · 0 comments · Fixed by #1241
Labels
bug an unexpected problem or unintended behavior pivoting ♻️ pivot rectangular data to different "shapes"

Comments

@DavisVaughan
Copy link
Member

DavisVaughan commented Nov 23, 2021

library(tidyr)

df <- tibble::tribble(
  ~x, ~y, ~z,
  1,  2,  4,
  1,  3,  5
)

pivot_wider(df, values_from = c(x, y, z))
#> Warning: Values are not uniquely identified; output will contain list-cols.
#> * Use `values_fn = list` to suppress this warning.
#> * Use `values_fn = length` to identify where the duplicates arise
#> * Use `values_fn = {summary_fun}` to summarise duplicates

#> Warning: Values are not uniquely identified; output will contain list-cols.
#> * Use `values_fn = list` to suppress this warning.
#> * Use `values_fn = length` to identify where the duplicates arise
#> * Use `values_fn = {summary_fun}` to summarise duplicates

#> Warning: Values are not uniquely identified; output will contain list-cols.
#> * Use `values_fn = list` to suppress this warning.
#> * Use `values_fn = length` to identify where the duplicates arise
#> * Use `values_fn = {summary_fun}` to summarise duplicates
#> # A tibble: 1 × 3
#>   x_        y_        z_       
#>   <list>    <list>    <list>   
#> 1 <dbl [2]> <dbl [2]> <dbl [2]>

This should be a tidyselect error because name doesn't exist in the dataset, but it slips by because name and value are defined in the tidyr namespace to NULL to quiet R CMD Check and eval_select() finds this

name <- value <- NULL

Found in #1102

@DavisVaughan DavisVaughan added bug an unexpected problem or unintended behavior pivoting ♻️ pivot rectangular data to different "shapes" labels Nov 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior pivoting ♻️ pivot rectangular data to different "shapes"
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant