I have data that looks like below, that has 1 Date variable, 4 numerical variables and 6 categorical variables.
Date Department average_wait_time_min patients_count doctors_count nurses_count year quarters months fortnights weeks
1 2017-01-01 General Checkup 211 847 165 266 2017 Q1-2017 January-2017 1 -2017 01-2017
2 2017-01-01 General Checkup 164 73 14 26 2017 Q1-2017 January-2017 1 -2017 01-2017
3 2017-01-01 Emergency 52 90 27 35 2017 Q1-2017 January-2017 1 -2017 01-2017
4 2017-01-01 Emergency 42 20 2 6 2017 Q1-2017 January-2017 1 -2017 01-2017
25 2017-01-02 General Checkup 250 811 160 261 2017 Q1-2017 January-2017 1 -2017 01-2017
26 2017-01-02 General Checkup 166 75 17 20 2017 Q1-2017 January-2017 1 -2017 01-2017
27 2017-01-02 Emergency 47 89 24 39 2017 Q1-2017 January-2017 1 -2017 01-2017
28 2017-01-02 Emergency 57 18 3 5 2017 Q1-2017 January-2017 1 -2017 01-2017
I want to sum(add) columns that has numerical data that belong to same date like below(also preserving categorical data). expected output(not with blank rows of course):
Date Department average_wait_time_min patients_count doctors_count nurses_count year quarters months fortnights weeks
1 2017-01-01 General Checkup 375 920 179 292 2017 Q1-2017 January-2017 1 -2017 01-2017
3 2017-01-01 Emergency 94 110 29 41 2017 Q1-2017 January-2017 1 -2017 01-2017
25 2017-01-02 General Checkup 416 886 177 281 2017 Q1-2017 January-2017 1 -2017 01-2017
27 2017-01-02 Emergency 104 107 27 44 2017 Q1-2017 January-2017 1 -2017 01-2017
I've thought of aggregate
function since it fits my requirements really close. But, It applies a function(sum
in my case) only on one column based on the repeated observations in other variables and this stackoverflow question talks about single numerical column too. But, I want to to sum multiple columns. So, that wouldn't help me.(here's the complete data if you want it)
How do I do this?