Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curve_intersect: "Error in approxfun", when one of the curves is a vertical line #5

Open
csapot opened this issue Jul 22, 2020 · 1 comment

Comments

@csapot
Copy link

csapot commented Jul 22, 2020

I'm trying the following code:

> curve1_temp
      x   y
165 885 621
166 886 622
167 887 622
168 888 623
169 889 623
170 890 624
171 891 624
172 892 626
173 893 627
174 894 627
175 895 628

> line1_temp
    x   y
1 889 610
2 889 630

and the result of curve_intersect is:

> intersect1_temp = curve_intersect(curve1_temp, line1_temp)
Error in approxfun(curve2$x, curve2$y, rule = 2) : 
  need at least two non-NA values to interpolate

based on visual plotting, the two curves should have an intersect:

ggplot(data = curve1_temp, aes(x = x, y = y)) + geom_line(color = "red") + geom_line(data = line1_temp, aes(x = x, y = y), color = "green")

curve_intersect_Rplot

Can you please help what can be the issue?

@csapot csapot changed the title curve_intersect: Error in approxfun, when one of the curves is a vertical line curve_intersect: "Error in approxfun", when one of the curves is a vertical line Jul 22, 2020
@csapot
Copy link
Author

csapot commented Jul 22, 2020

seems that the 'approxfun' function can't interpolate values where the x-coordinates are the same.
https://stackoverflow.com/questions/44386686/interpolation-function-approx-in-r-gives-error-need-at-least-two-non-na-valu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant