sum_lm | R Documentation |
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.
sum_lm(dataset, y = NULL, x = NULL, coefs_only = TRUE, dgts = 5)
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). |
If coefs_only is TRUE, returns a rounded coefficients table; otherwise, returns the full summary.
dat
is the default dataset name, but you can put in whatever
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.