Dear all, To draw a lowess line on a plot was a piece of cake; to draw a loess line, however, seems not that easy. Is the loess plotting implemented at all in relation to the loess function, or do I have to look in add-on packages? Thanks, Marcin
Try this: cars.lo <- loess(dist ~ speed, cars) with(cars, plot(speed, dist)) lines(predict(cars.lo), col="blue") On 03/02/2008, Marcin Kozak <nyggus at gmail.com> wrote:> Dear all, > > To draw a lowess line on a plot was a piece of cake; to draw a loess > line, however, seems not that easy. Is the loess plotting implemented > at all in relation to the loess function, or do I have to look in > add-on packages? > > Thanks, > Marcin > > ______________________________________________ > R-help at r-project.org mailing list > 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. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
lattice has a type = "smooth" for this: library(lattice) xyplot(dist ~ speed, cars, type = c("smooth", "p")) Or with a colored line: xyplot(dist + dist ~ speed, cars, type = c("p", "smooth"), col 1:2, distribute.type = TRUE) In ggplot2 its also a one linear: library(ggplot2) qplot(speed, dist, data = cars, geom = c("point", "smooth")) or with a colored line: qplot(speed, dist, data = cars) + geom_smooth(colour = "red") On Feb 3, 2008 3:29 PM, Marcin Kozak <nyggus at gmail.com> wrote:> Dear all, > > To draw a lowess line on a plot was a piece of cake; to draw a loess > line, however, seems not that easy. Is the loess plotting implemented > at all in relation to the loess function, or do I have to look in > add-on packages? > > Thanks, > Marcin > > ______________________________________________ > R-help at r-project.org mailing list > 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. >
Yes, this is what I wanted and needed. Thank you all for your replies. Marcin On Feb 4, 2008 1:28 AM, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:> lattice has a type = "smooth" for this: > > library(lattice) > xyplot(dist ~ speed, cars, type = c("smooth", "p")) > > Or with a colored line: > > xyplot(dist + dist ~ speed, cars, type = c("p", "smooth"), col > 1:2, distribute.type = TRUE) > > In ggplot2 its also a one linear: > > library(ggplot2) > qplot(speed, dist, data = cars, geom = c("point", "smooth")) > > or with a colored line: > > qplot(speed, dist, data = cars) + geom_smooth(colour = "red") > > > > On Feb 3, 2008 3:29 PM, Marcin Kozak <nyggus at gmail.com> wrote: > > Dear all, > > > > To draw a lowess line on a plot was a piece of cake; to draw a loess > > line, however, seems not that easy. Is the loess plotting implemented > > at all in relation to the loess function, or do I have to look in > > add-on packages? > > > > Thanks, > > Marcin > > > > > ______________________________________________ > > R-help at r-project.org mailing list > > 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. > > >-- "Build up your weaknesses until they become your strong points" -- Knute Rockne