I have the following dataframe:
ID Value Time_hr
1 0.1 0
1 0.15 1
1 0.2 2
2 0.08 0
2 0.12 1
3 0.09 0
3 0.12 1
3 0.13 2
3 0.15 3
I will like to find the mean values of all baseline values (Time_hr=0) for all groups and same for other time frames (1, 2, 3 etc) as follows:
Time_hr Mean_val
0 0.09
1 0.13
2 0.14
3 0.15
Here's my solution that didn't work:
aggregate(df, by=list(df$Value,df$Time_r),FUN=mean)
Has anyone got a solution that will work for this problem? Thanks