p_glm: Fits generalized linear models, with support for piping

View source: R/p_glm.r

p_glmR Documentation

Fits generalized linear models, with support for piping

Description

A wrapper function for glm(), with the data argument listed first to support piping.

Usage

p_glm(data, formula, ...)

Arguments

data

the data

formula

the formula

...

additional arguments passed to stats::glm().

Value

a glm object

Examples

# load the data
data(nhanes)

# define asthma
nhanes<-nhanes |> transform(
  asthma=base_match(mcq010,'No'=2,'History of asthma'=1)
)

# define smoking
nhanes<-nhanes |> transform(
  smoking=base_match(smq020,'No'=2,'History of smoking'=1)
)

# fit a model
my_model<-nhanes |> p_glm(asthma~smoking,family=binomial(link='logit'))

# obtain model details
my_model |> summary()

# obtain confidence interval
my_model |> confint() |> exp()

baseverse documentation built on April 29, 2026, 1:08 a.m.