dish | R Documentation |
Split up columns into groups and apply a function to combinations of those columns with control over whether each group is entered as a single data.frame
or individual vector
's.
dish( data, f, left, right, each_left = TRUE, each_right = TRUE, ... )
data |
A |
f |
A |
left |
A vector of quoted/unquoted columns, positions, and/or |
right |
A vector of quoted/unquoted columns, positions, and/or |
each_left |
Should each |
each_right |
Should each |
... |
Additional arguments to be passed to |
A list
Alex Zajichek
#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" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.