I have a dataframe that looks like this
plots <- data.frame(plot=c("A", "A", "A", "B", "B", "C", "C", "C"),
value= c(1,1,1,2,2,3,3,3))
plot value
1 A 1
2 A 1
3 A 1
4 B 2
5 B 2
6 C 3
7 C 3
8 C 3
I want to have a third column sum
where I would sum all the values from the same plots, so it would look like this:
plot value sum
1 A 1 3
2 A 1 3
3 A 1 3
4 B 2 4
5 B 2 4
6 C 3 9
7 C 3 9
8 C 3 9