-
-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Labels
Bug 🐛Something isn't workingSomething isn't working
Description
Hi all,
We found some kind of incompatibility between labelled
and paramters
for some data frames.
Notice that the labels include several NA
in the first example but not the second. In the first, I use the data supplied by the pscl
package. In the second, I use a data frame from Rdatasets
.
My hunch is that labelled
does not apply the labels in the same way to both data frames, but I don’t know this package well enough to be sure.
This was first reported by @raffaem here: vincentarelbundock/modelsummary#891
library(parameters)
library(labelled)
library(Rdatasets)
# Broken
mydf <- pscl::bioChemists
var_label(mydf) <- list(art="MyCount", fem="MyGender", kid5="Kids")
model <- lm(art ~ fem * factor(kid5), data = mydf)
p <- parameters(model, pretty_names = "labels")
attr(p, "pretty_labels")
#> (Intercept) femWomen factor(kid5)1
#> "(Intercept)" "MyGender [Women]" "kid5 [1]"
#> factor(kid5)2 factor(kid5)3 femWomen:factor(kid5)1
#> "kid5 [2]" "kid5 [3]" "MyGender [Women] * NA"
#> femWomen:factor(kid5)2 femWomen:factor(kid5)3
#> "MyGender [Women] * NA" "MyGender [Women] * NA"
# Working
mydf <- rddata("bioChemists")
var_label(mydf) <- list(art="MyCount", fem="MyGender", kid5="Kids")
model <- lm(art ~ fem * factor(kid5), data = mydf)
p <- parameters(model, pretty_names = "labels")
attr(p, "pretty_labels")
#> (Intercept) femWomen factor(kid5)1
#> "(Intercept)" "fem [Women]" "kid5 [1]"
#> factor(kid5)2 factor(kid5)3 femWomen:factor(kid5)1
#> "kid5 [2]" "kid5 [3]" "fem [Women] × kid5 [1]"
#> femWomen:factor(kid5)2 femWomen:factor(kid5)3
#> "fem [Women] × kid5 [2]" "fem [Women] × kid5 [3]"
`
Metadata
Metadata
Assignees
Labels
Bug 🐛Something isn't workingSomething isn't working