Skip to content

check_model fails if dependent variable is labelled #727

@sjewo

Description

@sjewo

Hi there,

i run i a bug with labelled data, similar to #629 .

check_model() will fail if the dependend variable is labelled

library(labelled)
library(performance)
library(see)

var_label(mtcars$wt) <- "Weight (1000 lbs)"
var_label(mtcars$mpg) <- "Miles/(US) gallon"
mtcars$am <- labelled(mtcars$am, c("automatic" = 0, "manual" = 1))

# this variable causes the error
mtcars$mpg <- labelled(mtcars$mpg, c("21" = 21))

m <- lm(mpg ~ wt + cyl + gear + disp + am, data = mtcars)

check_model(m)
> check_model(m)
Error: `check_model()` returned following error: Can't combine `..1` <character> and `..2` <double>.
  
If the error message does not help identifying your problem, another reason why `check_model()` failed might be that models of class `lm` are not yet
  supported.
> sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: aarch64-apple-darwin20
Running under: macOS Sonoma 14.5

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/Berlin
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] see_0.8.4            performance_0.11.0.9 labelled_2.13.0     

loaded via a namespace (and not attached):
 [1] vctrs_0.6.5       cli_3.6.2         rlang_1.1.3       forcats_1.0.0     haven_2.5.4       generics_0.1.3    glue_1.7.0        colorspace_2.1-0  datawizard_0.10.0
[10] hms_1.1.3         scales_1.3.0      fansi_1.0.6       grid_4.4.0        munsell_0.5.1     tibble_3.2.1      lifecycle_1.0.4   insight_0.19.11   compiler_4.4.0   
[19] dplyr_1.1.4       pkgconfig_2.0.3   rstudioapi_0.16.0 R6_2.5.1          tidyselect_1.2.1  utf8_1.2.4        pillar_1.9.0      magrittr_2.0.3    tools_4.4.0      
[28] gtable_0.3.5      bayestestR_0.13.2 ggplot2_3.5.1    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions