Open iago-pssjd opened 1 year ago
Could you please rework your reproducible example to use the reprex package ? That makes it easier to see both the input and the output, formatted in such a way that I can easily re-run in a local session.
@hadley done:
library(haven)
library(forcats)
path <- system.file("examples", "iris.dta", package = "haven")
t <- read_dta(path)
t$species |> str()
#> chr [1:150] "setosa" "setosa" "setosa" "setosa" "setosa" "setosa" "setosa" ...
#> - attr(*, "label")= chr "Species"
#> - attr(*, "format.stata")= chr "%10s"
t$species |> fct_recode(seto = "setosa") |> str()
#> Factor w/ 3 levels "seto","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ...
Created on 2023-10-31 with reprex v2.0.2
Thanks!
It seems this is not limited to fct_recode()
, as I experience the same with most forcats
functions.
This feature would be much appreciated by those like me that rely a lot on attributes like label
.
Hi!
fct_recode
removeslabel
attribute (and seems that it removes all the attributes). I expect it would not do (it may have sense that it removes alabels
attribute, but not others).Reprex: