|
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.
tidyr/R/id.R
Line 41 in cbdd14e
I think you'd want to add
exact = TRUEhere 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 intoid_var(). It matched the"names"attribute and returned the variable without adding the"n"attribute.