Closed
Description
Thanks for the haven-package! There is a small issue: With labelled_spss instead of labelled I get an error messages for some (but not all) functions when I use the variable.
I guess it has something to do with the class of the object or maybe I just got something wrong.
Please see the MWE below.
I use R version 4.0.1 (2020-06-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)
rm(list=ls())
set.seed(5)
data <- data.frame(var1=sample(1:5,50,replace=T) , var2=sample(1:5,50,replace=T))
# as expected
data$var1 <- haven::labelled(data$var1, labels=c("very low"=1, "low"=2, "medium"=3, "high"=4, "very high"=5))
sd(data$var1)
mean(data$var1)
# for mean as expected, for sd error "Can't convert <labelled_spss<double>> to <double>."
data$var2 <- haven::labelled_spss(data$var2, labels=c("very low"=1, "low"=2, "medium"=3, "high"=4, "very high"=5))
mean(data$var2)
sd(data$var2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment