I want to remove rows from a data frame where a column has NA only if the other rows where the NA value is found matches others value in the data frame
For example,
df <- data.frame(ID = c(1,1,2,2),DAY=c(1,1,2,3), VAL=c(1,NA,NA,5))
I want to remove the second row because there is a missing value in VAL and there is already a value for VAL with ID = 1 and DAY = 1 to get
ID DAY VAL
1 1 1
2 2 NA
2 3 5
Any idea how to do this? I could try writing a loop, but that doesn't seem efficient.