I cannot replicate the issue above with the small example files below but the other problem is still there. I need 1s and 0s as values of the MatchedResponseURNs, instead I can see 1s and NA. I think the problem is with having "NAs" rather than blank fields in the Service.car.data.all
car.service.data.17.short <- data.frame(stringsAsFactors=FALSE,
DF.URN = c("aaa", "bbb", "ccc", "ggg", "hhh", "iii"),
InterviewDate = c("2019-07-09 07:21:00", "2019-07-09 08:31:00",
"2019-07-09 08:44:00",
"2019-07-09 08:38:00",
"2019-07-09 09:32:00",
"2019-07-09 09:43:00"),
Rec = c(10, 9, 9, 8, 8, 7))
final.vital.data <- data.frame(stringsAsFactors=FALSE,
DF.URN = c("aaa", "bbb", "ccc", "ddd", "eee", "fff", "zzz", "yyy"),
RoDate = c("2019-10-02", "2019-10-12", "2019-10-02", "2019-10-02",
"2019-10-02",
"2019-10-02",
"2019-10-02",
"2019-11-02")
)
Service.car.data <- merge(car.service.data.17.short, final.vital.data, by="DF.URN")
Service.car.data.all <- merge(car.service.data.17.short, final.vital.data, by="DF.URN", all.y = TRUE)
Service.car.data.all$MatchedResponseURNs <- ifelse(Service.car.data.all$Rec >0, 1, 0)
Can you help?