It is not necessary to use Survey, mainly for simpler procedures. In this case, a simple aggregate()
would be enough for you. I don’t have the PNAD data on my computer right now, but follow an example:
library(survey)
dados <- data.frame(Peso = rchisq(100, 10), Idade = rnorm(100, 40, 10))
delineamento <- svydesign(ids = ~ 1, weights = ~ Peso, data = dados)
svytable(~ Idade > 30, delineamento)
aggregate(Peso ~ Idade > 30, dados, FUN = sum)
Note that the 2 results are equal. Importantly, a simple table()
does not serve because each observation has different weight.
with(dados, table(Idade > 30))
I wrote a blog post about Survey, may be useful (especially the links in the comments).
you should use the Survey package not for the package itself, but as a means of including the sample plan in the analysis. You should do this because due to the PNAD sampling procedure individuals have different weights. I think your question, and others you may have, can be resolved in the following book:http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470284307.html
– Flavio Barros