Tal Galili
2011-May-17 19:36 UTC
[Rd] lines.loess method - in order to make the plotting of loess consistent with that of lowess
Hello dear R developers,
# Bellow is an added method to lines to make the plotting of loess
consistent with what we get when using lines on lowess (which is also, IMHO,
more "intuitive")
lines.loess <- function(object,...)
{
# object: a loess object to plot using lines
# ...: passes to lines
ss <- order(object$x)
lines(object$fitted[ss] ~ object$x[ss],...)
}
# example of why this is useful:
set.seed(134)
y <- rnorm(100)
x <- rnorm(100)
plot(y~x)
lines(lowess(y~x), col = 1, lwd = 3)
lines.default(loess(y~x), col = 2)
lines.loess(loess(y~x), col = 3, lwd = 5)
legend("topright", legend = c("lines.default",
"lines.loess", "lines for
lowess"), fill = c(2,3,1))
Best,
Tal Galili
----------------Contact
Details:-------------------------------------------------------
Contact me: Tal.Galili@gmail.com | 972-52-7275845
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
----------------------------------------------------------------------------------------------
[[alternative HTML version deleted]]