hHI there:
I have a large dataset imported from SPSS with the haven
package and I'm trying to weight weight the data using the srvyr
package; but it looks like the two do not play well together. It looks like I need to somehow to convert haven_labelled
to someother class. I think I've read that before about the haven_labelled
class, but this could become a real barrier to combining haven
with labelled data. Can anyone suggest efficient workflows for dealing with larger datasets to deal with this problem?
var1<-haven::labelled(rep(c(1,2),100), c("Male"=1, "Female"=2))
var2<-rnorm(100)
df<-data.frame(var1, var2)
df
library(srvyr)
df1<-as_survey_design(df, weights=var2)
str(df)
df1 %>%
group_by(var1) %>%
summarize(out=survey_mean())```