library(dplyr)
library(forcats)
library(tidyr)
library(broom)
# This is a wide data frame. You can convert it to a long
# data frame to predict probability of O-ring damage based
# on temperature using logistic regression.
orings_long <- orings %>%
pivot_longer(cols = c(damaged, undamaged), names_to = "outcome", values_to = "n") %>%
uncount(n) %>%
mutate(outcome = fct_relevel(outcome, "undamaged", "damaged"))
orings_mod <- glm(outcome ~ temperature, data = orings_long, family = "binomial")
tidy(orings_mod)
Run the code above in your browser using DataLab