Learn R Programming

tldr (version 0.3.0)

inline_coef: Report the coefficient from a regression model inline

Description

inline_coef presents the resuts of a coefficient from a lm or glm model in LaTeX format to be reported inline in an RMarkdown document.

Usage

inline_coef(model, variable, coef = TRUE, stat = TRUE, pval = TRUE, digits = 2)

inline_coef_p(model, variable, digits = 2)

Value

Returns a LaTeX-formatted result for use in RMarkdown document.

Arguments

model

A regression model

variable

A character string giving the name of the variable to be reported

coef

Logical, whether the coefficient value is to be reported (default TRUE)

stat

Logical, whether the test statistic for the coefficient should be reported (default TRUE)

pval

Logical, whether the p-value for the coefficient should be reported (default TRUE)

digits

Number of digits to round to (default to 2)

Details

This function currently only supports lm and glm objects. Suggestions and requests are welcomed.

inline_coef_p is a wrapper for inline_coef to report only the p-value (sets all non-p-value logicals to FALSE).

Examples

Run this code
x1 = rnorm(20)
x2 = rnorm(20)
y = x1 + x2 + rnorm(20)
model1 = lm(y ~ x1 + x2)
inline_coef(model1, 'x1')
inline_coef_p(model1, 'x1')

Run the code above in your browser using DataLab