Similar to this post, I want to group a data frame by an ID (lets say Month
) and calculate the mean and standard deviation per group. The difference is that I want the two columns Rate 1
and Rate 2
to be combined into one with the mean and sd of both.
Name Month Rate1 Rate2
Aira 1 12 23
Aira 2 18 73
Aira 3 19 45
Ben 1 53 19
Ben 2 22 87
The data frame above should be grouped by Month
and for each month calculate the mean
rate over both columns. For example, the mean of month 1 should be (12 + 23 + 53 + 19) / 4 = 26.75. I assume the approach for sd
is similar.
Month Mean_rate
1 26.75
2 50
3 32