Amherst-Statistics / IS5inR

Companion materials for De Veaux, Velleman, and Bock's "Intro Stats" 5th edition
MIT License
0 stars 3 forks source link

Adding the Indicator for a Residuals/Fitted Plot #22

Closed mchien20 closed 6 years ago

mchien20 commented 6 years ago

For Chapter 9 page 290, I can't get color = ~ indicator variable to work. library(mosaic) library(readr) Coasters <- read_csv("http://nhorton.people.amherst.edu/is5/data/Coasters_2015.csv") gf_point(Duration ~ Drop, color = ~ as.factor(Inversions), data = Coasters) %>% gf_lm() %>% gf_labs(color = "Inversions") coasterlm2 <- lm(Duration ~ Drop + as.factor(Inversions), data = Coasters) msummary(coasterlm2) gf_point(resid(coasterlm2) ~ fitted(coasterlm2)) %>% gf_labs(x = "Predicted", y = "Residuals")

mchien20 commented 6 years ago

https://github.com/Amherst-Statistics/IS5inR/commit/de258ed94866de545c0d297e2d839a2936de21e6