Wednesday, March 23, 2011

How to find the least dense part of a curve in R

Suppose we have vectors x and y of same size. Then we plotted x vs. y using plot(x,y) in R. How to find the least dense part of this curve?

k<-length(x)
a<-c()
for(i in c(1:k-1)) {
t<-sqrt((x[i+1]-x[i])^2+(y[i+1]-y[i])^2)
a<-c(a, t)
}
a<-c(a, t)
plot(x,a)

No comments:

Visitors