I have a data frame that has duplicate IDS. I want to keep the ID that has the least amount of NAs (so the most complete set for the ID). In this example i would want to keep the second 123 and the second 124 (lease NAs)
I can identify the duplicates but I cant write a code to essentially say 1)For each duplicate, keep the one with less NAs The code could also say 2)For each duplicate, remove the one with more NAs,
Here is example data
id Col1 col1 2 col 3 col 4
123 10 NA NA 3
123 50 3 2 NA
124 30 5 7 NA
124 30 8 1 2