Closed sjewo closed 1 month ago
Thanks, should be fixed in insight, which will be submitted to CRAN the next days.
@larmarange Is it necessary to preserve haven_labelled
and vctrs
class attributes when labelled::labelled()
is used?
See from ?haven::labelled
:
This class provides few methods, as I expect you'll coerce to a standard R class (e.g. a factor) soon after importing.
label(s) attributes can be used for standard R classes, so no need to keep the vectrs
class attribute. The latter behaves differently than standard R classes, which can cause errors (like described in this issue), which are a pain to debug (and it's literally not clear to users, where the error comes from - namely, R language behaviour is "broken", and there's not bug in the package's code).
If not really necessary in your package, maybe it's possible to remove the haven_labelled
and vctrs
class attributes?
Hi. labelled::labelled() is identical to haven::labelled()
The labelled package just provides functions to manipulate such vectors.
Such vectors are not intended to be used in a model. They should be transformed into factors with to_factor() or numeric/character vectors with unclass() before modelling (You could also use unlabelled()).
In performance, I do not see the need to support such vectors. In gtsummary, fire example, there is a warning saying to the user if he didn't forget to transform these vectors before analysis.
So the error here is to use a haven_labelled vector in a model. The variable am should have been transformed into a factor to be correctly be considered as categorical by the model.
Yes, I agree. The problem often is that users aren't aware that labelled data can be of classes haven_labelled
and vctrs
, and thus problems can arise. We fixed this issues in our packages by removing those class attributes whenever model-data is extracted.
Hi there,
i run i a bug with labelled data, similar to https://github.com/easystats/performance/issues/629 .
check_model()
will fail if the dependend variable islabelled