Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mollietaylor
Last active October 21, 2018 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mollietaylor/8203926 to your computer and use it in GitHub Desktop.
Save mollietaylor/8203926 to your computer and use it in GitHub Desktop.
ggplot or Lattice Fit Line in R
ols <- lm(Temp ~ Solar.R,
data = airquality)
summary(ols)
str(ols)
plot(Temp ~ Solar.R,
data = airquality)
abline(ols)
library(ggplot2)
# ggplot(data = airquality,
# aes(Solar.R, Temp)) +
# geom_point(pch = 19) +
# geom_abline(intercept = ols$coefficients[1],
# slope = ols$coefficients[2])
ggplot(data = airquality,
aes(Solar.R, Temp)) +
geom_point(pch = 19) +
geom_smooth(method = lm,
se = FALSE)
library(lattice)
xyplot(Temp ~ Solar.R,
data = airquality,
type = c("p", "r"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment