Closed DanChaltiel closed 1 year ago
Hi,
This is a minor bug that can be annoying when working with labels. When using forcats modifiers like fct_drop() on factors, everything is fine, but if you use it on a character vector it removes all attributes (such as labels):
forcats
fct_drop()
library(forcats) library(expss) fct("a") %>% set_var_lab("foo") %>% fct_drop() %>% var_lab() #> [1] "foo" "a" %>% set_var_lab("foo") %>% fct_drop() %>% var_lab() #> NULL
Created on 2022-12-02 with reprex v2.0.2
Actually, this might be easily fixed by changing factor() to forcats::fct() in forcats:::check_factor() (https://github.com/tidyverse/forcats/blob/main/R/utils.R#L16).
factor()
forcats::fct()
forcats:::check_factor()
You're converting an object from one type to another; I don't think there's a string a priori motivation for preserving attributes here.
Hi,
This is a minor bug that can be annoying when working with labels. When using
forcats
modifiers likefct_drop()
on factors, everything is fine, but if you use it on a character vector it removes all attributes (such as labels):Created on 2022-12-02 with reprex v2.0.2
Actually, this might be easily fixed by changing
factor()
toforcats::fct()
inforcats:::check_factor()
(https://github.com/tidyverse/forcats/blob/main/R/utils.R#L16).