| orderPoints {contoureR} | R Documentation | 
Order Points Clockwise or Counter-Clockwise
Description
Returns the indexes of supplied points, x and y, ordered either clockwise or
anticlockwise about another point, which by default is taken to be the non-weighted midpoint
of the supplied data
Usage
orderPoints(x, y, ..., xm = mean(range(x)), ym = mean(range(y)),
  clockwise = TRUE)
Arguments
x | 
 numeric vector of x values  | 
y | 
 numeric vector of y values of same length as x  | 
... | 
 not used  | 
xm | 
 the x value of the reference point  | 
ym | 
 the y value of the reference point  | 
clockwise | 
 order in clockwise or anticlockwise manner  | 
Examples
#Generate a random set of points and put them clockwise order
set.seed(1)
x  = runif(100)
y  = runif(100)
op    = orderPoints(x,y)
#To demonstrate, Lets view the points in order
library(ggplot2)
df    = data.frame(x,y)
df    = df[op,];
df$id = 1:nrow(df)
ggplot(data=df,aes(x,y,colour=id)) +
    geom_path() + geom_point() +
    scale_colour_gradient(low="green",high="red")
[Package contoureR version 1.0.5 Index]