I have the following data.table:
data.table(group = c('A', 'B', 'B', 'A', 'B', 'B', 'A', 'A'), value = c(NA, 2, NA, 6, NA, 2, 6, NA))
group value
1: A NA
2: B 2
3: B NA
4: A 6
5: B NA
6: B 2
7: A 6
8: A NA
I want to fill the NA values to be the same as the group's value that are not NA. The expected output is:
group value
1: A 6
2: B 2
3: B 2
4: A 6
5: B 2
6: B 2
7: A 6
8: A 6
Any sugestions?