0

I would like to fill in a column by group.

df <- data.frame(
  group = c(1,1,1,2,2,2),
  base = c(NA, 2, NA, NA, 3, NA))

So the desired outcome would be:

1     1    2
2     1    2
3     1    2
4     2    3
5     2    3
6     2    3

This is my code so far, but this doesn't seem to work:

base <- group_by(group) %>% summarize(base = max(base))

Any other alternatives?

Stata_user
  • 562
  • 3
  • 14

0 Answers0