my dt1
looks like
pateint_id NAME col1 col2 col3
1001 aa 33 41 51
1002 bb 34 42 52
1003 cc 35 43 53
1004 dd 36 44 54
1005 ee 37 45 55
1006 gg 38 46 56
1007 ff 39 47 57
1008 hh 40 48 58
1009 kk 41 49 59
1010 ll 42 50 60
my dt2
have record_date
pateint_id NAME Record_date
1001 aa 10-02-2004
1002 bb 25-09-2008
1005 ee 13-06-2005
1006 gg 15-07-2006
class(dt2$Record_date) POSIXct" "POSIXt
i want to match both patient id and get record date from the dt2
dataset
For that i used if condition but resulted in date format error
dt1$fdate <- ifelse(dt1$patient_id %in% dt2$patient_id,dt2$Record_date,NA)
output:
pateint_id NAME Record_date
1001 aa 38027
1002 bb 39716
1005 ee 38516
1006 gg 38913
Expected Output:
pateint_id NAME Record_date
1001 aa 10-02-2004
1002 bb 25-09-2008
1005 ee 13-06-2005
1006 gg 15-07-2006
Thank you in advance...
Aucun commentaire:
Enregistrer un commentaire