Skip to content

Make pivot_wider error messages more useful, like spread errors #1113

@hrecht

Description

@hrecht

Hello, I have found that the pivot_ family error messages are much less helpful than spread and gather error messages. For example, here's an error message from the exact same dataset that had a few rows with repeated values, using pivot_wider vs spread.

The spread error message tells me exactly where the issue is. The pivot_wider one is very difficult to understand and doesn't point me to the error. When I added values_fn = length to the pivot call I got another error, Error: 1 components of ...were not used. We detected these problematic arguments: *vaues_fn``
Could you please consider incorporating some of the old context?

pivot_wider:

Warning message:
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 

spread:

Error: Each row of output must be identified by a unique combination of keys.
Keys are shared for 6 rows:
* 427, 428
* 540, 541
* 800, 802

(edited to add text for error messages)

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