I have a series of tables created using the "tables" package in R, to allow for multiple variables, e.g.
##create sample data frame
x<-runif(1000, 0, 1)
x<-round(x,0)
y<-runif(1000, 0, 1)
y<-round(y,0)
z<-runif(1000, 1, 6)
z<-round(z, 0)
data<-as.data.frame(cbind(x,y,z))
names(data)<-c("Q1_1", "gender", "agegrp")
data$Q1_1<-as.factor(data$Q1_1)
data$weights<-runif(1000, 0, 0.5)
##create table
tabular((Q1_1+1)~((factor(agegrp)+factor(gender))*Percent("row")), data=data)
This works fine (and allows the addition of more variables, which I would need), but I would like to produce the same tables using weighted data. The "survey" package gives me the svytable option, but this is limited to producing crosstables of two variables, rather than crossing 1 or more variables against a series of others. Within tables, I can produce a weighted mean, but can see no way of weighting percentages. One alternative is to create several weighted tables, where I can create a list of variables to cross against a single other and then bind them, but this seems a little inefficient?
Does anybody know of a way to create such a table using the tabular command, or am I better off finding another way to create the table which will suit weighting better?