Suppose I have
tibble(id = c(1,1,2,2), data = c(1:4))
i.e.
id data
1 1
1 2
2 3
2 4
I want to add a column with id-secific means, i.e. I want to get to
id data id_means
1 1 1.5
1 2 1.5
2 3 3.5
2 4 3.5
How can I do this?