I have a dataset looks like this
time   value
0.1    2
0.1    3
0.2    2
0.2    4
0.2    1
I also have a threshold value threshold = 2.5
I want to combine the rows with the same time point and calculate the ratio above the threshold and return a table like this:
time    value
0.1     0.50
0.2     0.33
I have tried to use data.table to combine all the rows with same time  points but I am having some trouble to come up a function to calculate ratio at each time point. I know that I could write some for loop but I am wondering if there's a more R way to solve this problem.
My thought is something like this:
results <- dt[,some_function(value, threshold),by=time]
Thank you in advance.
