Merge and aggregate datasets: Difference between revisions

Line 351:
# merge patients and aggregate dataset
# all.x = all the non matching cases of df_patient are appended to the result as well (i.e. 'left join')
df_result <- merge(df_patient, df_agg, by = 'PATIENT_ID', all.x = TRUE)</lang>
 
print(df_result)</lang>
{{out}}
<pre>
PATIENT_ID LASTNAME last_visit score_avg score_sum
1 1001 Hopper 18585 5.8 17.4
2 2002 Gosling 18543 6.8 6.8
3 3003 Kemeny 18578 NaN 0
4 4004 Wirth 18571 7.7 15.4
5 5005 Kurtz <NA> <NA> <NA>
</pre>
 
=={{header|SPSS}}==
Anonymous user