I've got a dataframe with values:
x y value
A B 10
B A 15
A C 5
C A 10
B C 20
df <- data.frame(x = c("A", "B", "A", "C", "B"),
y = c("A", "A", "C", "A", "C"),
value = c(10, 15, 5, 10, 20))
I would like to summarise this data to each combination of x and y and get the sum of the value per combination. The result would be:
x y value
A B 25
A C 15
B C 20
I found this question which is more or less the same question as I have. But the solutions don't work in my case. This is because the values in x and y are strings and min()
and max()
won't work.
Any ideas how to do this?