Home > Software design >  Mutate across matching complete rows with incomplete rows
Mutate across matching complete rows with incomplete rows

Time:08-08

Good day,

I have a dataset similar to that attached image and would like to mutate the People_ID to match the complete rows in R programming language.

enter image description here

CodePudding user response:

As mentioned before, tidyr::fill should work fine if all of your results are in order; however, if you need to match based on ID, something like this should work (where df = your raw dataset):

lookup <- df[df$people_id != "",]
final <- merge(lookup, df, by="distinct_id", all = TRUE)
  •  Tags:  
  • r
  • Related