modelc: Compile an R model to a valid TSQL formula

Description Usage Arguments Value Examples

View source: R/modelc.r

Description

Compile an R model to a valid TSQL formula

Usage

1
modelc(model, modify_scipen = TRUE)

Arguments

model

A list with the same signature as the output of lm or glm

modify_scipen

A boolean indicating whether to modify the "scipen" option to avoid generating invalid SQL

Value

A character string representing a SQL model formula

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
a <- 1:10
b <- 2*1:10
c <- as.factor(a)
df <- data.frame(a, b, c)
formula = b ~ a + c

# A vanilla linear model
linear_model <- lm(formula, data = df)
modelc::modelc(linear_model)

# A generalized linear model with gamma family distribution and log link function
gamma_loglink_model <- glm(formula, data = df, family=Gamma(link="log"))
modelc::modelc(gamma_loglink_model)

# A generalized linear model with gamma family distribution and identity link function
gamma_idlink_model <- glm(formula, data = df, family=Gamma(link="identity"))
modelc::modelc(gamma_idlink_model)

team-sparkfish/modelc documentation built on June 21, 2020, 10:57 a.m.