I have read a lot of "how to get a percentile" answers but could not find a solution to my problem.
I have a data.frame with 3 columns: Heart rate (beats per minute), Temperature (ranging from 35 to 45 - without decimals), Activity (ranging from 1 to 15 - without decimals).
I would like to add a 4th column with the percentile value of the Heart rate considering the distribution of Heart rate characterized by a given Temperature and a given Activity.
Example: at Temperature=37 and Activity=5 a Heart rate of 60 beats per minutes has a percentile of ...
#example of data frame
n = 1000
df <- data.frame(HeartRate = round(runif(n, 60, 100)),
Temperature = round(runif(n, 35, 45)),
Activity = round(runif(n, 1, 15)))
Thank you very much in advance for your help.