[datatable-help] svyby with multiple factor and/or looping difficulty
edhunter
hrayrwannis at gmail.com
Tue Dec 13 11:41:33 CET 2016
Hello,
I am try to generate weighted tables with svyby with multiple
covariates/factors but not nested:
df<- data.frame(attend=(sample(c(0,100),500,prob = c(.35,.65),replace =
TRUE)),sex=sample(c("m","f"),500,prob=c(.45,.55),replace =
TRUE),wgt=sample(c(.88,.99,1.32,1.45,1.76),500,replace=TRUE),agecat=sample(c(1,2,3,4),500,replace=TRUE))
adesg<- svydesign(id=~1, weights = ~wgt,data=df)
1. svyby(~attend,~sex,design = adesg,svymean,vartype = "ci")
2. svyby(~attend,~agecat,adesg,svymean)
I want to generate the above two (and many other cov) in one go in a single
table. Though the code at 3.)nests the variables rather than providing
results per category values as above. I've also tries to loop the above
codes but that opens up host of other issues that so far turned up to dead
end.
3. svyby(~attend, ~agecat+sex,adesg,svymean)
Any thoughts?
thanks,
--
View this message in context: http://r.789695.n4.nabble.com/svyby-with-multiple-factor-and-or-looping-difficulty-tp4727340.html
Sent from the datatable-help mailing list archive at Nabble.com.
More information about the datatable-help
mailing list