Skip to content

Instantly share code, notes, and snippets.

@rudeboybert
Last active March 13, 2019 18:48
Show Gist options
  • Save rudeboybert/1dcbc9fc49caf2ed9da44af826fd8953 to your computer and use it in GitHub Desktop.
Save rudeboybert/1dcbc9fc49caf2ed9da44af826fd8953 to your computer and use it in GitHub Desktop.
Demo of moderndive package functions for tidyverse & novice friendly linear regression
library(tidyverse)
library(moderndive)
# Convert to tibble:
mtcars <- mtcars %>%
rownames_to_column()
# Fit lm
mpg_model <- lm(mpg ~ hp, data = mtcars)
# Two options for regression table:
summary(mpg_model)
get_regression_table(mpg_model)
# Get observed & fitted values + residuals
library(broom)
augment(mpg_model)
get_regression_points(mpg_model, ID = "rowname")
# Scalar summaries
get_regression_summaries(mpg_model)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment