Fitting a principal curve to a data matrix in arbitrary dimensions. A principal curve is a smooth curve passing through the middle of a multidimensional dataset. This package is an R/C++ reimplementation of the S/Fortran code provided by Trevor Hastie, with multiple performance tweaks.
Usage of princurve is demonstrated with a toy dataset.
t <- runif(100, -1, 1) x <- cbind(t, t ^ 2) + rnorm(200, sd = 0.05) colnames(x) <- c("dim1", "dim2") plot(x)
A principal curve can be fit to the data as follows:
library(princurve) fit <- principal_curve(x) plot(fit); whiskers(x, fit$s, col = "gray")
?principal_curve for more information on how to use the
news(package = "princurve") or NEWS.md for a full
list of changes.
project_to_curve(): Return error message when
contain insufficient rows.
BUG FIX unit tests: Switch from
pdf() as support for
svg() might be optional.
project_to_curve(): Fix pass-by-reference bug, issue #33. Thanks to @szcf-weiya for detecting and fixing this bug!
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.