Skip to content

spread when id column has names #525

Description

@wangyuchen

tidyr/R/id.R

Line 41 in cbdd14e

if (!is_null(attr(x, "n")) && !drop) return(x)

I think you'd want to add exact = TRUE here to match attribute "n" exactly.

Otherwise, when drop = FALSE, the empty attribute condition gets used and it will partial match all attributes. It happened that I had a named vector in my data frame and it was passed into id_var(). It matched the "names" attribute and returned the variable without adding the "n" attribute.

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

    reprexneeds a minimal reproducible example

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions