I need to do several aggregate.
For example:
2012ocup10 <- aggregate(PNAD2012[c("peso_pes")], by=PNAD2012["klems"],
FUN=sum,na.rm=T)
But I need to do the same procedure for PNAD2011,PNAD2010,
...
I use loop this way:
for(ano in (1995:2012)[-c(6,16)]){
tabela.p <- apply(get(paste0("PNAD",ano))[c( "idade", "anos_est", "rend_prin",
"rend_tot",
"horas", "horas_s")],
2,FUN=mean,na.rm=T)
}
When I adapt pro aggregate I can not get it to create multiple tables (2012ocup10,2011ocup10,...)
. Using get (paste0 ...) I can not seem to access the variables inside data.frame