lundi 22 mars 2021

How to replace missing data in one column from a duplicate row

Here is a sample of data the data set is large and I want to be able to replace all missing values with the correct value based on if the value in the ID column is equal.

Id.data<-data.frame(
  ID = c(564,758,987,1568,4987,413578,987,65647,4895,564,135,1568),
  gender= c("male","female","female","male","male","female","female","male", "female","male","male","male"),
  race= c ("Caucasian","Black","Caucasion","Hispanic","Hispanic","Asian","NA","BLack","Black","NA","Asian","NA"),
  Hours = c(45,54,32,24,56,40,42,25,40,36,56,24),
  stringsAsFactors = FALSE
)

Aucun commentaire:

Enregistrer un commentaire