attr_getter() uses partial matching, which is error-prone/dangerous #460
Here’s a bug/misfeature is was bitten by today. Basically, I was trying to extract the
However, for some of the variables, the value of the
It’s to late to change the base
To fix this, one only needs to add
library(purrr) x = c(0, 1, 1, 0) attr(x, "labels") = c(`0` = "Female", `1` = "Male") get_label = attr_getter("label") get_label(x) # Expected output: NULL #> 0 1 #> "Female" "Male"
The text was updated successfully, but these errors were encountered:
Changed the `attr_getter()` fuction to no longer uses partial matching. For example, if an `x` object has a `labels` attribute but no `label` attribute, `attr_getter("label")(x)` will no longer extract the `labels` attribute (fixes tidyverse#460). Also added some documentation on the `attr_getter()` function.