Skip to content

Feature request: Add detail to error messages with names_repair #987

@billdenney

Description

@billdenney

When using pivot_wider(), I accidentally created duplicate column names. That was not my intent, but the error message provided made it take a bit more effort to find what the underlying problem was.

It would help if names_repair provided specific error messages indicating what was bad about the names (and possibly how to fix it).

For the toy example below, it would be helpful if the message were something like:

Error: Failed to create output due to bad names:  The name "A" is duplicated.
* Choose another strategy with `names_repair`
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
pivot_wider(
  data.frame(A=1, B="A", C=3),
  names_from="B",
  values_from="C"
)
#> Error in pivot_wider(data.frame(A = 1, B = "A", C = 3), names_from = "B", : could not find function "pivot_wider"

Created on 2020-06-18 by the reprex package (v0.3.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancementpivoting ♻️pivot rectangular data to different "shapes"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions