Skip to contents

infer_reg() creates a small table summarizing a linear regression test. The traditional columns of t and p-value are removed by default but a full table can be accessed with simple = FALSE.

Usage

infer_reg(data, formula, digits = 3, caption = NULL, reduced = c("yes", "no"))

Arguments

data

A data frame (or tibble).

formula

The variables to run the test on, in formula syntax. Passed on to stats::lm().

digits

The number of digits to round table values to. Defaults to 3.

caption

An override to the table caption. A sensible default is provided.

reduced

Should a simple table be created (i.e., removal of the t and p-value columns)? Defaults to "yes".

Value

An object of class flextable. In an interactive session, results are viewable immediately.

Examples

infer_reg(mtcars, drat~wt)
Linear Model Coefficients Table
Degrees of Freedom: 1
R-Squared: 0.508

Term

Estimate

Standard
Error

(Intercept)

4.849

0.235

wt

-0.389

0.070

infer_reg(mtcars, drat~wt, reduced = "no")
Linear Model Coefficients Table
Degrees of Freedom: 1
R-Squared: 0.508
Overall F: 30.923

Term

Estimate

Standard
Error

t

p-value

(Intercept)

4.849

0.235

20.624

< 0.0001

wt

-0.389

0.070

-5.561

< 0.0001

infer_reg(mtcars, drat~wt, digits = 4)
Linear Model Coefficients Table
Degrees of Freedom: 1
R-Squared: 0.5076

Term

Estimate

Standard
Error

(Intercept)

4.8491

0.23510

wt

-0.3893

0.07001

infer_reg(mtcars, drat~wt + qsec)
Linear Model Coefficients Table
Degrees of Freedom: 2
R-Squared: 0.509

Term

Estimate

Standard
Error

(Intercept)

5.043

0.7840

wt

-0.3930

0.0722

qsec

-0.0103

0.0396