sum_lm: Print Core Results from summary(lm()) in a Neat Table

View source: R/sum_lm.R

sum_lmR Documentation

Print Core Results from summary(lm()) in a Neat Table

Description

sum_lm takes the built in R functions summary(lm()) and lets you use them in a sequence of pipes. In particular this is useful when you want to test for the magnitude of a relationship between two variables in many different subsets of data at once.

Usage

sum_lm(dataset, y = NULL, x = NULL, coefs_only = TRUE, dgts = 5)

Arguments

dataset

The dataset to be used for regression analysis.

y

The response variable in the linear model.

x

The predictor variable in the linear model.

coefs_only

Logical, indicating whether to display only the coefficients table (default: TRUE).

dgts

Number of digits for rounding coefficients (default: 5).

Value

If coefs_only is TRUE, returns a rounded coefficients table; otherwise, returns the full summary.

Note

dat is the default dataset name, but you can put in whatever

Examples

# example 1: entire dataset
PaluckMetaSOP::contact_data |> sum_lm()
# example 2: split and apply to many subsets
## Not run: 
library(purrr)
PaluckMetaSOP::sv_data |> split(~study_design) |> map(sum_lm)

## End(Not run)

setgree/PrejMetaFunctions documentation built on May 8, 2024, 6:38 p.m.