I'm a newbie in R and I'm trying to improve my skills. At the moment, I'm stuck with a very easy problem (I hope).
Background
In my data, the length of the variables P21, PONDERA and ESTADO are the same...
I'm working with a huge database, and I want to calculate an average income. In my data, P21
refers to the value for an entry in the sample, and what I'm trying to do is to weight it so that it is representative of the entire population. In turn, ESTADO == 1
refers to the person is occupied, that is why the weight is in relation to the busy people. Then I divide it by population and get the average income.
Salario_OP <- Base_total %>%
group_by(ANO4) %>%
summarise(Ingreso = sum(P21*(PONDERA[ESTADO == 1))/sum(PONDERA[ESTADO == 1]))
I really think it's easy to solve, but the language does not help me understand everything (I'm argentinian). Hope you can help me. Thank you in advance for your help!