I have a large dataset from a survey. I already have a column/variable that is a weight that should be applied to the whole data set. This is simply achieved by in SPSS, but I would like to do this in R as well. What I already know is how to apply the weighting variable to an individual column like this:
gend <- wtd.table(master.data$Q10_GENDER, weights = master.data$Weight_Age_Gender_Income)
This works great for the one variable, but I would hate to have to do that for every single command I run. Is there a way to apply to the entire data set?
I reduced a larger subset of my external database into a simple three variable DF, and I would like to apply one pre-calculated weight variable to the entire DF.
test <- data.frame(br$Q10_GENDER,
br$Q5B_URBANICITY,
br$S4_AGE_GROUP_1)
br$Weight_Age_Gender_Income
Summary output:
br.Q10_GENDER br.Q5B_URBANICITY br.S4_AGE_GROUP_1
Female:4986 Urban, city center :8791 18-24 :3048
Male :4893 Suburbs surrounding city: 827 25-29 :1664
Other : 44 Rural : 305 30-34 :1218
35-39 : 954
40-44 : 806
13-17 : 763
(Other):1470