Maybe this question is basic but I have issues with merging two data frames together.
No issues with normal merging when I keep only matching records:
Service.car.data <- merge(car.service.data.17.short, final.vital.data, by="DF.URN")
but when I try to keep all records from final.vital.data and I use below:
Service.car.data.all <- merge(car.service.data.17.short, final.vital.data, by="DF.URN", all.y = TRUE)
I have number of records matching final.vital.data (fine) but when I look closer I can see that values not matched are NAs and DF.URN not matched are blank (I should still see them)
When I then try to recode any of numeric variables coming from car.service.data.17.short like below, I have weird results (have only 1s, rather than 1s and 0s):
Service.car.data.all$MatchedResponseURNs <- ifelse(Service.car.data.all$Rec >0, 1, 0)
Is it because I need to remove NAs before recoding? When I merge two databases like in option 1 (only matching records), I don't have this recoding issue.
The df are too large to prepare reprex but pleas let me know if it is required to solve this problem.