Last active
October 21, 2018 21:52
-
-
Save mollietaylor/8203926 to your computer and use it in GitHub Desktop.
ggplot or Lattice Fit Line in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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