It uses 'tidyeval' and 'dplyr' to create a linear regression model.

linear_regression_db(df, y_var = NULL, sample_size = NULL, auto_count = FALSE)

Arguments

df

A Local or remote data frame

y_var

Dependent variable

sample_size

Prevents a table count. It is only used for models with three or more independent variables

auto_count

Serves as a safeguard in case sample_size is not passed inadvertently. Defaults to FALSE. If it is ok for the function to count how many records are in the sample, then set to TRUE. It is only used for models with three or more independent variables

Details

The linear_regression_db() function only calls one of three unexported functions. The function used is determined by the number of independent variables. This is so any model of one or two variables can use a simpler formula, which in turn will have less SQL overhead.

Examples

library(dplyr)

mtcars %>%
  select(mpg, wt, qsec) %>%
  linear_regression_db(mpg)
#> # A tibble: 1 × 3
#>   `(Intercept)`    wt  qsec
#>           <dbl> <dbl> <dbl>
#> 1          19.7 -5.05 0.929