% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/p_glm.r
\name{p_glm}
\alias{p_glm}
\title{Fits generalized linear models, with support for piping}
\usage{
p_glm(data, formula, ...)
}
\arguments{
\item{data}{the data}

\item{formula}{the formula}

\item{...}{additional arguments passed to \code{\link[stats:glm]{stats::glm()}}.}
}
\value{
a \code{glm} object
}
\description{
A wrapper function for \code{glm()}, with the \code{data} argument listed first to support piping.
}
\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()
}
