This is probably a very easy question, but I cannot seem to figure it out...
I have the following list
l <- list(May=data.frame(date=c(NA, as.Date("2019/5/1"), NA, NA, NA, NA, as.Date("2019/5/2"), NA, NA, NA, NA, NA, NA, NA), ID = c( "107349", "110024", "6187" , "100420", "94436", "88995" , "110165" ,"91644", "108508", "105213", "108773", "102636" ,"102339" ,"100413")),
April = data.frame(date=c(as.Date("2019/4/1"), as.Date("2019/4/2"), NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, as.Date("2019/4/3"), NA, as.Date("2019/4/4"), NA, NA, NA, NA, NA), ID=c("37866", "107349", "93051", "6187", "98274", "100420", "94436", "88995" ,"105107", "105109", "91644", "105103" ,"108508" ,"105213", "108773", "85409" ,"104145","102636" ,"102339" ,"100413")),
March = data.frame(date= c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, as.Date("2019/3/1"), NA, NA, NA, NA, NA, NA), ID=c("93051" , "104499" ,"6187", "98274", "100420" ,"94436", "88995" ,"105107" ,"105109", "91644" ,"105103", "105213" ,"85409" , "104145", "100989", "102636" ,"102339", "100413")),
February = data.frame(date= c(NA , NA, as.Date("2019/2/1"), NA, NA, NA, NA ,as.Date("2019/2/2"), as.Date("2019/2/3"), as.Date("2019/2/4"), NA, as.Date("2019/2/5"), NA ,NA, as.Date("2019/2/6"), NA, NA, NA, NA, NA, NA, NA), ID=c("94266" , "93051", "104499" ,"6187" , "98274", "100420", "94436" ,"88995", "105107", "105109", "91644" ,"105103", "85409" ,"102252", "104145", "94559", "101426", "100992" ,"100989" ,"102636" ,"102339" ,"100413")),
January = data.frame(date = seq(as.Date("2019/1/1"), by = "day", length.out = 18), ID=c("94266" , "93051", "99836", "6187" , "98274", "100420", "94436", "91644", "85409", "102252", "94412", "94559", "101426", "100992", "100989", "102636", "102339", "100413")))
I'm trying to match a specific value in one column (Date) and replace it with the corresponding value from the same column if values in the other column (ID) are the same. The date column should be the same across all dataframes if the corresponding ID values in the ID columns match but I've got a date only for the first time the ID appears and NAs for the following appearances of an ID.
I tried using match and subset but I couldn't figure it out.