Learn R Programming

ggtern (version 1.0.6.1)

point.in.sequence: Put Points in Sequence

Description

The point.in.sequence function takes numeric input vectors x and y or a data.frame object, and orders the values in such way that they are correctly sequenced by the angle subtended between each point, and, the centroid of the total set. If the data is provided in the format of a data.frame, then it must containing columns named x and y, else an error will be thrown.

Usage

point.in.sequence(x, y, ..., df = data.frame(x = x, y = y), close = FALSE)

Arguments

x
vector of numeric x values
y
vector of numeric y values
...
not used
df
data.frame containing colums x and y
close
logical value (default FALSE), as to whether the set should be closed by adding (duplicating) the first row (after ordering) to the end of the set.

Value

  • data.frame object containing the re-ordered input set.

Details

The arguments x and y represent cartesian coordinates. This is useful if a path is sought that passes through each point in the ordered set, however, no two lines in the total path cross over each other. Uses the atan2 function to determine the angle (theta) between each point (x,y) and the centroid of the data, it then orders based on increasing values of theta.