I have a dataset that contains multiple observations per person. In some cases an individual will have their ethnicity recorded in some rows but missing in others. In R, how can I replace the NA's with the ethnicity stated in the other rows without having to manually change them?
Example:
PersonID        Ethnicity
   1                A
   1                A
   1                NA
   1                NA
   1                A
   2                NA
   2                B
   2                NA
   3                NA
   3                NA
   3                A
   3                NA
Need:
PersonID        Ethnicity
   1                A
   1                A
   1                A
   1                A
   1                A
   2                B
   2                B
   2                B
   3                A
   3                A
   3                A
   3                A
 
    