Learn R Programming

dentomedical (version 0.2.0)

linreg: Linear Regression Table with Univariable and Multivariable Analysis

Description

Fits univariable and multivariable linear regression models for a continuous outcome, summarizing beta coefficients, 95% confidence intervals, and p-values. Factor predictors include reference levels in the table. Returns a formatted flextable and optionally provides an automatic textual interpretation of results.

Usage

linreg(data, outcome, predictors, report = TRUE)

Value

If report = FALSE, returns a flextable summarizing univariable and multivariable beta coefficients, 95% CI, and p-values. If report = TRUE, returns a list with table (the flextable) and interpretation (textual summary of multivariable results).

Arguments

data

A data frame containing the outcome and predictor variables.

outcome

Name of the continuous outcome variable (character).

predictors

Character vector of predictor variable names.

report

Logical; if TRUE, prints an automatic textual interpretation of multivariable results (default: TRUE).

Examples

Run this code
# Apply linear regression on iris dataset
linreg(
  data = iris,
  outcome = "Sepal.Length",
  predictors = c("Sepal.Width", "Petal.Length", "Species"),
  report = TRUE
)

Run the code above in your browser using DataLab