Created
December 27, 2022 01:48
-
-
Save lundquist-ecology-lab/e83d4deec4dfd90404cc409f83c14eba to your computer and use it in GitHub Desktop.
Correlation and regression in R with examples
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
library(palmerpenguins) | |
data(penguins) | |
penguins <- na.omit(penguins) | |
# Correlation | |
cor.test(penguins$bill_length_mm, penguins$bill_depth_mm) | |
# Regression (linear model) | |
model_1 <- lm(bill_length_mm ~ bill_depth_mm, data = penguins) | |
summary(model_1) | |
plot(bill_length_mm ~ bill_depth_mm, data = penguins) | |
abline(model_1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment