Correlation and Linear Regression
cor measures how two variables move together. lm fits a linear model and summary shows coefficients and fit.
Example
x <- c(1, 2, 3, 4, 5); y <- c(2, 4, 5, 4, 5)
print(round(cor(x, y), 3))
m <- lm(y ~ x)
print(round(coef(m), 2))Exercise
Fit a linear model.
m <- (y ~ x)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.