Skip to content

Instantly share code, notes, and snippets.

@mollietaylor
Last active October 21, 2018 21:52
Show Gist options
  • 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