Can the expss package solve the question asked in this link?, it's about multiple response question with a weighting variable in the dataset
How to use the R survey package to analyze multiple response questions in a weighted sample?
Let's suppose we have this dataset:
demo <- tribble(
~dummy1, ~dummy2, ~dummy3, ~survey_weight,
1, 0, 0, 1.5,
1, 1, 0, 1.5,
1, 1, 1, .5,
0, 1, 1, 1.5,
1, 1, 1, .5,
0, 0, 1, .5,
)
I need to calculate the percentage based on total respondents who answered the question, and not on total responses
Yes, it is quite easy:
library(expss)
demo = text_to_columns("
dummy1 dummy2 dummy3 survey_weight
1 0 0 1.5
1 1 0 1.5
1 1 1 .5
0 1 1 1.5
1 1 1 .5
0 0 1 .5
")
demo %>%
tab_cells(mdset(dummy1 %to% dummy3)) %>% # 'mdset' designate that with have multiple dichotomy set
tab_weight(survey_weight) %>% # weight
tab_stat_cpct() %>% # statistic
tab_pivot()
# | | #Total |
# | ------------ | ------ |
# | dummy1 | 66.7 |
# | dummy2 | 66.7 |
# | dummy3 | 50.0 |
# | #Total cases | 6.0 |
# shorter notation with the same result
calc_cro_cpct(demo, mdset(dummy1 %to% dummy3), weight = survey_weight)
But note that expss
use simple frequency weights in the SPSS style while 'survey' package can provide more accurate weighting schemes.