I have the following Data Frame with rainfall by location in Argentina. The problem is that, for example, for Córdoba Capital and Castellanos I have three values for the same month and year, so I need to be able to summarize that information as an average and that in the data frame there is only one row with Córdoba Capital with the average value.
`codigo anio mes precip.mensual departamento provincia
87244 2000 11 137.5 Rio seco CO
87244 2000 12 150.5 Rio seco CO
87257 2000 1 150.5 San cristobal SF
87257 2000 2 125.9 San cristobal SF
87344 2000 1 96.8 Capital CO
87344 2000 2 135.2 Capital CO
87344 2000 3 184.6 Capital CO
87344 2000 4 125.4 Capital CO
87344 2000 5 47.0 Capital CO
87344 2000 6 0.0 Capital CO
87344 2000 7 12.0 Capital CO
87344 2000 8 0.5 Capital CO
87344 2000 9 14.0 Capital CO
87344 2000 10 124.2 Capital CO
87344 2000 11 192.0 Capital CO
87344 2000 12 175.0 Capital CO
87345 2000 1 150.8 capital CO
87345 2000 2 136.6 capital CO
87345 2000 3 105.1 capital CO
`
You can do it by
dplyr
grouping and summarizing: