My first dataset contains rows and columns like this below. Some values in the second column (Score_d1
) are missing (NA
).
StudentID Score_d1
012343 NA
081245 NA
957600 78
212945 86
305049 NA
407903 92
Second dataset is as follows. This dataset contains Scores values only for those StudentIds where the Score values were missing in the first dataset. For example, in the first dataset , the score values for StudentID 012343
was missing and the Score_d2
column in this second dataset contains these values ( 75, 85)
StudentID Score_d2
012343 75
012343 85
081245 94
081245 65
305049 46
I want to merge these two datasets by StudentID such that the missing(NA) Score_d1
values from the first dataset is replaced by the Score_d2
values from the second dataset do i merge these two datasets to create a final dataset like this below, one-to-many ??
StudentID Score
012343 75
012343 85
081245 94
081245 65
957600 78
212945 86
305049 46
407903 92
Any help on accomplishing this is much appreciated.