You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here’s a bug/misfeature is was bitten by today. Basically, I was trying to extract the label associated with each variable in a tibble, using (bascially) map(df, attr_getter("label")).
However, for some of the variables, the value of the labels (note the s) attribute, a ‘> 1’-length vector, were extracted instead. It turned out that this happens when the label attribute is missing. The reason is partial matching on the attribute name, which unfortunately is the default in attr().
It’s to late to change the base attr() function, but partial matching is dangerous ☠️, and I see no reason that this should be the default in attr_getter() too!
To fix this, one only needs to add exact = TRUE in the call to the attr function in get_attr().
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 (fixestidyverse#460).
Also added some documentation on the `attr_getter()` function.
Here’s a bug/misfeature is was bitten by today. Basically, I was trying to extract the
label
associated with each variable in a tibble, using (bascially)map(df, attr_getter("label"))
.However, for some of the variables, the value of the
labels
(note thes
) attribute, a ‘> 1’-length vector, were extracted instead. It turned out that this happens when thelabel
attribute is missing. The reason is partial matching on the attribute name, which unfortunately is the default inattr()
.It’s to late to change the base
attr()
function, but partial matching is dangerous ☠️, and I see no reason that this should be the default inattr_getter()
too!To fix this, one only needs to add
exact = TRUE
in the call to theattr
function inget_attr()
.Reprex:
The text was updated successfully, but these errors were encountered: