Dear all,
I'm sure the solution is easier than I think but I have some issues with maximum value by year.
I need to find maximum number of Sequence for each ReferenceNumber and each year.
I simply want to modify my code to see maximum values of Sequence but not only overall but also with 2016 and 2017 column.
response.data <- data.frame(stringsAsFactors=FALSE,
ReferenceNumber = c("aaa", "aaa", "aaa", "eee", "eee", "eee", "eee",
"hhh",
"hhh",
"hhh",
"hhh"),
Sequence = c(2, 1, 3, 2, 1, 5, 3, 2, 5, 4, 5),
S.Year = c(2016, 2016, 2017, 2016, 2016, 2017, 2017, 2017, 2017,
2017,
2017))
response.data %>%
group_by(ReferenceNumber) %>%
summarise(Max = max(Sequence))
As a result I should see maximum Sequence values like that:
# A tibble: 4 x 2
ReferenceNumber Total 2016 2017
1 aaa 3 2 3
2 eee 5 2 5
3 hhh 5 5
>
This might be extremely simple so can you help please?