#' Generates the predictors
#'
#' @import tidyverse
#' @import dplyr
#' @import broom
#' @param df dataframe
#' @return Sum of squares for the variable that explains the most variation in the dataset
#' @export predictors
predictors <- function(df, response) {
df <- df %>%
select_if(is.numeric)
final <- c()
names(df) <- make.names(names(df))
for(i in names(df)) {
if(i != response) {
f <- paste(response, "~", i)
m <- lm(formula = f, data = df) %>% anova() %>% pluck("Sum Sq")
final <- append(final, m[1])
}
}
max_index <- index(final, max(final))
value <- names(df)[max_index]
return(c(value, max(final)))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.