For a given x, y series, I need to fit a spline. Then at a given value of y (say 0.65), I want to draw a tangent and extract its corresponding x-value. I use the smooth.spline function to fit the curve.
spl <- smooth.spline(y ~ x)
My data is below. Any help how should I go about it.
structure(list(x = c(0.55, 0.575, 0.6, 0.625, 0.65, 0.675, 0.7,
0.725, 0.75, 0.775, 0.8, 0.825, 0.85, 0.875, 0.9, 0.925, 0.95,
0.975, 1, 1.025, 1.05, 1.075, 1.1, 1.125, 1.15, 1.175, 1.2, 1.225,
1.25, 1.275, 1.3, 1.325, 1.35), y = c(0, 0.004065041, 0.02173913,
0.067164179, 0.166666667, 0.357142857, 0.642857143, 0.907407407,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1)), .Names = c("x", "y"), class = "data.frame", row.names = c(NA,
-33L))
There is a similar solution at here! But the new data in this example is a point on x-axis, while in my case the new data is a point on y-axis.