Interactively sketch and smooth a curve through 2D points
CurveFinderInteractive.RdLaunches a small Shiny app where you can click points to sketch a polyline
through 2D data xy. When you press **Smooth**, the clicked polyline is
smoothed with mgcv and then used to project the data onto the curve
(via princurve), returning coordinates \(t \in [0,1]\) along the
curve and a residual-like coordinate \(r\) orthogonal to it.
Value
A list with the elements produced by interactiveCurve():
xyt: a data.frame with columnsx,y,t(curve coordinate scaled to[0,1]),r(orthogonal residual-like coordinate),f1,f2(fittedx(t)andy(t)values).curve.plot: a ggplot2 object showing the data and the smoothed curve colored byt.coordinate.plot: a ggplot2 scatter plot colored byt.residuals.plot: a ggplot2 scatter plot colored byr.
Details
- Input xy must be 2 columns corresponding to x and y.
- Click at least 3 points to define a path; use **Clear clicks** to restart.
- Smoothing uses mgcv::gam with a cyclic cubic spline (bs = "cc")
if loop = TRUE, otherwise a cubic regression spline (bs = "cr").
- After smoothing, points are projected to the smoothed curve using
princurve::project_to_curve, and a set of outputs (including plots)
is returned and the app closes.