# NOT RUN {
require(tidyverse)
#1) Default uses every variable on both sides
heart_disease %>%
select_if(
is.numeric
) %>%
dish(
f = cor
)
#2) Simple regression of Age and BP on each variable
heart_disease %>%
dish(
f =
function(y, x) {
mod <- lm(y ~ x)
tibble(
Parameter = names(mod$coef),
Estimate = mod$coef
)
},
left = c("Age", "BP"),
bind = TRUE
)
#3) Multiple regression with Age, BP on all variables simultaneously
heart_disease %>%
dish(
f =
function(y, x) {
mod <- lm(y ~ ., data = x)
tibble(
Parameter = names(mod$coef),
Estimate = mod$coef
)
},
left = c("Age", "BP"),
each_right = FALSE,
bind = TRUE
)
# }
Run the code above in your browser using DataLab