I have a data set that can have more than one date per month. I am trying to aggregate them and get the mean so that there will only be one per month. I have tried several aggregate codes and have gotten NAs every time. The code and the outcome is at the bottom. This is only the first data set I have to do this with. I will also put the others I have tried.
head(pa_new1)
head(pa_new1)
Start.Date End.Date Approving Disapproving Unsure.NoData
1 1974-08-02 1974-08-05 24 66 10
2 1974-07-12 1974-07-15 24 63 13
3 1974-06-28 1974-07-01 28 58 14
4 1974-06-21 1974-06-24 26 61 13
5 1974-05-31 1974-06-03 28 61 11
6 1974-05-17 1974-05-20 26 61 13
Date year month
1 1974-08-02 1974 08
2 1974-07-12 1974 07
3 1974-06-28 1974 06
4 1974-06-21 1974 06
5 1974-05-31 1974 05
6 1974-05-17 1974 05
> pa_new1 %>%
+ select(month, year) %>%
+ group_by(year) %>%
+ summarize(mean(month))
# A tibble: 53 x 2
year `mean(month)`
<chr> <dbl>
1 1969 NA
2 1970 NA
3 1971 NA
4 1972 NA
5 1973 NA
6 1974 NA
7 1975 NA
8 1976 NA
9 1977 NA
10 1978 NA
# ... with 43 more rows
There were 50 or more warnings (use warnings() to see the first 50)
##just has second column as NAs
aggregate(month~year, pa_new1, mean)
##just has second column as NAs
aggregate(month~year, pa_new1, mean, na.rm=TRUE)