I have tried to convert the daily values into monthly average in R. But, all columns of the avrage become the same values. Help ASAP. Here is the code and some result.
gewane$month <- lubridate::month(gewane$Date)
gewane$year <- lubridate::year(gewane$Date) head(gewane)
Date Precipitation month year
1 1979-01-01 0.00000000 1 1979
2 1979-01-02 0.00000000 1 1979
3 1979-01-03 0.02059937 1 1979
4 1979-01-04 0.00000000 1 1979
5 1979-01-05 0.00000000 1 1979
6 1979-01-06 0.00000000 1 1979
library(dplyr) gewane %>%
group_by(year,month) %>%
summarize(averPR = mean(gewane$Precipitation))
summarise()
has grouped output by 'year'. You can override using the.groups
argument.A tibble: 427 x 3
Groups: year [36]
year month averPR <dbl> <dbl> <dbl>
1 1979 1 0.673 2 1979 2 0.673 3 1979 3 0.673 4 1979 4 0.673 5 1979 5 0.673 6 1979 6 0.673 7 1979 7 0.673 8 1979 8 0.673 9 1979 9 0.673 10 1979 10 0.673
... with 417 more rows