linefit | R Documentation |
Convenient wrapper for stats::lowess(), stats::lm(), and stats::coef(stats::line())
linefit(
x,
y,
type = "b",
cex = 4,
show.lowess = TRUE,
show.lm = TRUE,
show.line = TRUE
)
x |
x values, required |
y |
y values, required |
type |
passed through to |
cex |
scaling for lowess |
show.lowess |
Logical value, optional, TRUE by default. Defines if lowess is shown |
show.lm |
Logical value, optional, TRUE by default. Defines if lm line is shown |
show.line |
Logical value, optional, TRUE by default. Defines if should show abline(coef(line(x,y))) |
This function adds lines to a scatter plot, using lines(stats::lowess()), abline(stats::lm()), and abline(stats::coef()) DOESN'T SEEM TO WORK IF log = 'xy' was used in original plot() NOTE: coef(line()) and lm() give different results
Provides a plot just as a side effect
## Not run:
# see
#?lm or ?aov or ?glm
# ?line
require(graphics)
plot(cars)
(z <- line(cars))
abline(coef(z))
## Tukey-Anscombe Plot :
plot(residuals(z) ~ fitted(z), main = deparse(z$call))
# ?predict
# ?lowess
# ?scatterplot
#The scatterplot( ) function in the car package offers many enhanced features, including
#fit lines, marginal box plots, conditioning on a factor, and interactive point identification.
#Each of these features is optional.
# Enhanced Scatterplot of MPG vs. Weight
# by Number of Car Cylinders
library(car)
scatterplot(mpg ~ wt | cyl, data = mtcars,
xlab = "Weight of Car", ylab = "Miles Per Gallon",
main = "Enhanced Scatter Plot",
labels = row.names(mtcars))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.