makepath {condvis} | R Documentation |
Provides a default path (a set of sections), useful as input to
a conditional tour (condtour
). Clusters the data using
k-means or partitioning around medoids (from the cluster
package).
The cluster centres/prototypes are then ordered to create a sensible way to
visit each section as smoothly as possible. Ordering uses either the
DendSer
or TSP
package. Linear interpolation is then used to
create intermediate points between the path nodes.
makepath(x, ncentroids, ninterp = 4)
x |
A dataframe |
ncentroids |
The number of centroids to use as path nodes. |
ninterp |
The number of points to linearly interpolate between path nodes. |
A list with two dataframes: centers
giving the path nodes, and
path
giving the full interpolated path.
d <- data.frame(x = runif(500), y = runif(500))
plot(d)
mp1 <- makepath(d, 5)
points(mp1$centers, type = "b", col = "blue", pch = 16)
mp2 <- makepath(d, 40)
points(mp2$centers, type = "b", col = "red", pch = 16)