Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
17 lines (13 sloc)
582 Bytes
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
## Here's the data from the video | |
mouse.data <- data.frame( | |
weight=c(0.9, 1.8, 2.4, 3.5, 3.9, 4.4, 5.1, 5.6, 6.3), | |
size=c(1.4, 2.6, 1.0, 3.7, 5.5, 3.2, 3.0, 4.9, 6.3)) | |
mouse.data # print the data to the screen in a nice format | |
## plot a x/y scatter plot with the data | |
plot(mouse.data$weight, mouse.data$size) | |
## create a "linear model" - that is, do the regression | |
mouse.regression <- lm(size ~ weight, data=mouse.data) | |
## generate a summary of the regression | |
summary(mouse.regression) | |
## add the regression line to our x/y scatter plot | |
abline(mouse.regression, col="blue") |