使用 svytotal() 進行彙總
我們也可以用 svytotal() 來估計計數。語法如下:
svytotal(x = ~interaction(Var1, Var2),
design = design,
na.rm = TRUE)
對於兩個變數的每一種組合,我們都會得到總數的估計值以及標準誤。
本練習屬於課程
在 R 中分析問卷資料
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Estimate the totals for combos of Depressed and HealthGen
tab_totals <- svy___(x = ~interaction(___, ___),
design = NHANES_design,
na.rm = TRUE)
# Print table of totals
___