[R] Fit a smooth closed shape through 4 points

Charles Determan cdetermanjr at gmail.com
Mon Mar 21 14:10:39 CET 2016


Hi Allie,

What is you goal here?  Do you just want to plot a curve to the data?  Do
you want a function to approximate the data?

You may find the functions spline() and splinefun() useful.

Quick point though, with so few points you are only going to get a very
rough approximation no matter the method used.

Regards,
Charles


On Mon, Mar 21, 2016 at 7:59 AM, Alexander Shenkin <ashenkin at ufl.edu> wrote:

> Hello all,
>
> I have sets of 4 x/y points through which I would like to fit closed,
> smoothed shapes that go through those 4 points exactly.  smooth.spline
> doesn't like my data, since there are only 3 unique x points, and even
> then, i'm not sure smooth.spline likes making closed shapes.
>
> Might anyone else have suggestions for fitting algorithms I could employ?
>
> Thanks,
> Allie
>
>
> shapepoints = structure(c(8.9, 0, -7.7, 0, 0, 2, 0, 3.8), .Dim = c(4L,
> 2L), .Dimnames = list(NULL, c("x", "y")))
>
> smooth.spline(shapepoints)
>
> # repeat the first point to close the shape
> shapepoints = rbind(shapepoints, shapepoints[1,])
>
> smooth.spline(shapepoints)
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list