Dear all,
I'm writing you because I am stuck on this point.
I have a dataframe like this:
Rif year Var1 Var2
Name1 2015 11 15
Name1 2016 15 17
Name1 2017 10 12
Name1 2018 20 5
Name2 2015 26 10
Name2 2016 13 20
Name2 2017 5 7
Name3 2015 16 8
Name4 2015 19 11
Name4 2017 15 17
Name5 2017 21 9
Name5 2018 30 25
So, I am studying a period from 2015 to 2018, but there are missing values on some couples (Rif_year).
I would like to calcute the weighted mean for Var1 and Var2 with the following weights:
2018 = 0.5 -- 2017 = 0.3 -- 2016 = 0.15 -- 2015 = 0.05
For some Rif (Name2, Name3, Name4, Name5), Var1 e Var2 are missing on some years.
I would like to get all years for each Rif. Where I have the missing value, I would like to have row/rows containing Rif, the missing year/years, mode of Var1 and mode of Var2, where modes are computed on that specific Rif.
Hope to have been clear enough.
Thank you for your support!