I have a dataset with two columns x, y as follows
x y
0.5789474 0.0011382324
1.0000000 0.0024540588
0.8000000 0.0017039382
0.7272727 0.0014921618
0.8421053 0.0018399977
0.8611111 0.0019049152
0.3750000 0.0007843210
0.7837838 0.0016542579
0.7222222 0.0014784711
0.7619048 0.0015895130
0.7435897 0.0015372644
0.4375000 0.0008791528
0.8750000 0.0019537960
0.6666667 0.0013359048
0.8750000 0.0019537960
0.8571429 0.0018911749
0.6896552 0.0013931524
1.0000000 0.0024540588
0.9285714 0.0021543502
0.9523810 0.0022499579
Plotting these values produces a graph as follows
My goal is to find the values of x and y where the slope or rate of change in the curve is maximum. Where the bend or curve is sharpest. I tried ,
(lead(y)-y)/(lead(x)-x)
and this is did not work. Any suggestions or advice is much appreciated. Thanks in advance.
I am giving pointer:
df = read.table(text="
0.5789474 0.0011382324
1.0000000 0.0024540588
0.8000000 0.0017039382
0.7272727 0.0014921618
0.8421053 0.0018399977
0.8611111 0.0019049152
0.3750000 0.0007843210
0.7837838 0.0016542579
0.7222222 0.0014784711
0.7619048 0.0015895130
0.7435897 0.0015372644
0.4375000 0.0008791528
0.8750000 0.0019537960
0.6666667 0.0013359048
0.8750000 0.0019537960
0.8571429 0.0018911749
0.6896552 0.0013931524
1.0000000 0.0024540588
0.9285714 0.0021543502
0.9523810 0.0022499579",header=FALSE)
Now calculate slope:
slope= diff(df$V2)/diff(df$V1)
From the maximum slope retrieve the corresponding x,y points:
df[which.max(slope),]
Output:
V1 V2
18 1 0.002454059
Please feel free to correct me!