I have the following dataframe and I need to obtain the bimonthly sums for January and February for the rainfall variable. I did it for years. This is the code I used
df.mensual <- df %>%
group_by(anio,mes,codigo) %>%
summarise(precip.mensual = sum(lluvia,na.rm="TRUE"))
filtering = filter(df.mensual, mes<3)
What I need is to add the months of filtering for each year and code. Then make a table that looks like this:
1980 1981 1982 1983
----------------------------------------------------
codigo1 A A A A
codigo2 A A A A
codigo3 A A A A
where are the A that are the bimonthly sums of January and February for each year and code.
The problem can be solved like this
Then the result is the following