#All variables on both sides
heart_disease %>%
dplyr::select(
where(is.numeric)
) %>%
dish(
f = cor
)
#Simple regression of each numeric variable on each other variable
heart_disease %>%
dish(
f =
function(y, x) {
mod <- lm(y ~ x)
tibble::tibble(
Parameter = names(mod$coef),
Estimate = mod$coef
)
},
left = where(is.numeric)
) %>%
#Bind rows together
fasten(
into = c("Outcome", "Predictor")
)
#Multiple regression of each numeric variable on all others simultaneously
heart_disease %>%
dish(
f =
function(y, x) {
mod <- lm(y ~ ., data = x)
tibble::tibble(
Parameter = names(mod$coef),
Estimate = mod$coef
)
},
left = where(is.numeric),
each_right = FALSE
) %>%
#Bind rows together
fasten(
into = "Outcome"
)
Run the code above in your browser using DataLab