I would like to draw smooth curves instead of polygons. I could not find any spline function to do that : given an x and a y vectors, they all take the x in increasing order. Is there a function to draw a smooth curve through a set of points in any order ? with many thanks in advance Alain Guerreau CNRS Paris [[alternate HTML version deleted]]
>>>>> "guerreau" == guerreau <alain.guerreau at fnac.net> >>>>> on Fri, 6 Dec 2002 11:21:48 +0100 writes:guerreau> I would like to draw smooth curves instead of guerreau> polygons. I could not find any spline function to guerreau> do that : given an x and a y vectors, they all guerreau> take the x in increasing order. Is there a guerreau> function to draw a smooth curve through a set of guerreau> points in any order ? I've always wanted to try the following. Your e-mail prompted me to. I attach an R source file that shows one solution, using interpolating spline(s), one through (t, x(t)) the other (t, y(t)) Repeatedly sourcing this file also shows you the limitation of splines for this situation. The functions are for your convenience to do more experiments. Martin Maechler <maechler at stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <>< -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: spline-non-function-curve.R Url: https://stat.ethz.ch/pipermail/r-help/attachments/20021206/b5cdb74c/spline-non-function-curve.pl
>>>>> "guerreau" == guerreau <alain.guerreau at fnac.net> writes:> I would like to draw smooth curves instead of polygons. I > could not find any spline function to do that : given an x > and a y vectors, they all take the x in increasing order. > Is there a function to draw a smooth curve through a set of > points in any order ? The locfit package local regression, likelihood and density estimation) can be used to that: library(locfit) data(ethanol) fit <- locfit(NOx~E,data=ethanol) plot(NOx~E,data=ethanol) lines(fit) Mike -- Michael A. Miller mmiller3 at iupui.edu Imaging Sciences, Department of Radiology, IU School of Medicine
On 6 Dec 2002, Michael A. Miller wrote:> >>>>> "guerreau" == guerreau <alain.guerreau at fnac.net> writes: > > > I would like to draw smooth curves instead of polygons. I > > could not find any spline function to do that : given an x > > and a y vectors, they all take the x in increasing order. > > Is there a function to draw a smooth curve through a set of > > points in any order ? > > The locfit package local regression, likelihood and density > estimation) can be used to that: > > library(locfit) > data(ethanol) > fit <- locfit(NOx~E,data=ethanol) > plot(NOx~E,data=ethanol) > lines(fit)1) That package is in CRAN/Devel because it does not work (fully) with current R. 2) Your example is of a *smoothed* fit, not of a smooth interpolating curve. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595