Hello R-Helpers.. I am still new in R and I have the following question.. I am applying the function chull on a 2D dataset and have the convex hull nicely calculated and plotted. Do you know if there is a way to extract the coordinates of the line created from the connection of the chull data points.. I have alredy tried with "approx" to lineary interpolate but its not working correctly since the interpolated values sometimes fall inside the convex . Using the "yleft" or "yright" doesnt seem to help.. Any suggestions? Thank you in advance Achilleas.
Convex hull line coordinates..
6 messages · achilleas.psomas@wsl.ch, Romain Francois, Clint Bowman +2 more
2 days later
Hello R-Helpers.. I am still new in R and I have the following question.. I am applying the function chull on a 2D dataset and have the convex hull nicely calculated and plotted. Do you know if there is a way to extract the coordinates of the line created from the connection of the chull data points.. I have alredy tried with "approx" to lineary interpolate but its not working correctly since the interpolated values sometimes fall inside the convex . Using the "yleft" or "yright" doesnt seem to help.. Any suggestions? Thank you in advance Achilleas Psomas
Hello, I'm not sure i got your question right, but i think the whole point is to find the equation of a line which passes by two points See ?lm Romain. Le 21.03.2005 11:09, achilleas.psomas at wsl.ch a ?crit :
Hello R-Helpers.. I am still new in R and I have the following question.. I am applying the function chull on a 2D dataset and have the convex hull nicely calculated and plotted. Do you know if there is a way to extract the coordinates of the line created from the connection of the chull data points.. I have alredy tried with "approx" to lineary interpolate but its not working correctly since the interpolated values sometimes fall inside the convex . Using the "yleft" or "yright" doesnt seem to help.. Any suggestions? Thank you in advance Achilleas Psomas
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Romain FRANCOIS : francoisromain at free.fr page web : http://addictedtor.free.fr/ (en construction) 06 18 39 14 69 / 01 46 80 65 60 _______________________________________________________ Etudiant en 3eme ann?e Institut de Statistique de l'Universit? de Paris (ISUP) Fili?re Industrie et Services http://www.isup.cicrp.jussieu.fr/
?chull
states:
Value:
An integer vector giving the indices of the points lying on the
convex hull, in clockwise order.
therefore (see Example in ?chull) you have the end points of each line
segment from which you can compute the equation of each line segment.
Since the precision of the calculation is finite, there will necessarily
be some portion of each line that may fall on one side or the other of the
"true" convex hull.
Or am I off base?
Clint
On Mon, 21 Mar 2005, Romain Francois wrote:
Hello, I'm not sure i got your question right, but i think the whole point is to find the equation of a line which passes by two points See ?lm Romain. Le 21.03.2005 11:09, achilleas.psomas at wsl.ch a ?crit :
Hello R-Helpers.. I am still new in R and I have the following question.. I am applying the function chull on a 2D dataset and have the convex hull nicely calculated and plotted. Do you know if there is a way to extract the coordinates of the line created from the connection of the chull data points.. I have alredy tried with "approx" to lineary interpolate but its not working correctly since the interpolated values sometimes fall inside the convex . Using the "yleft" or "yright" doesnt seem to help.. Any suggestions? Thank you in advance Achilleas Psomas
______________________________________________ R-help at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Clint Bowman INTERNET: clint at ecy.wa.gov Air Quality Modeler INTERNET: clint at math.utah.edu Department of Ecology VOICE: (360) 407-6815 PO Box 47600 FAX: (360) 407-7534 Olympia, WA 98504-7600
Romain Francois wrote:
Hello, I'm not sure i got your question right, but i think the whole point is to find the equation of a line which passes by two points See ?lm
Or see a basic geometry book, where you will find a formula such as: (x-x1)/(y-y1) = (x2-x1)/(y2-y1) for the equation of a line passing through (x1,y1) and (x2,y2). Just watch out for y2==y1 and the inevitable division by zero. Might be better to ask what you want the line for in order to find a representation that better suits your need - a single point and slope, perhaps. Baz
<achilleas.psomas <at> wsl.ch> writes: : : Hello R-Helpers.. : : I am still new in R and I have the following question.. : I am applying the function chull on a 2D dataset and have the convex hull : nicely : calculated and plotted. : Do you know if there is a way to extract the coordinates of the line created : from the connection of the chull data points.. : I have alredy tried with "approx" to lineary interpolate but its not working : correctly since the interpolated values sometimes fall inside the convex . : Using the "yleft" or "yright" doesnt seem to help.. : : Any suggestions? 1. First suggestion is not to post by following up on an unrelated thread since some people won't see it. e.g. try finding it on gmane. Its there but good luck on finding it. 2. Second suggestion is an example which creates a matrix z whose columns are the regression coefficients of the successive line segments. Note use of lm's subset= arg to simplify code: example(chull) # creates hpts and X and plots convex hull z <- sapply(2:length(hpts), function(i) coef(lm(X[,2] ~ X[,1], subset = hpts[i-1:0])) ) # we can use z to display _full_ lines, on top of the line # _segments_ that were displyed in example(chull): for(i in 1:ncol(z)) abline(coef = z[,i], col = "red", lty = 2)