zlm {zfit} | R Documentation |
Run an lm model in a pipe.
Description
This function wraps around the lm function in order to make it more friendly to pipe syntax (with the data first).
Usage
zlm(
data,
formula,
subset,
weights,
na.action,
method = "qr",
model = TRUE,
x = FALSE,
y = FALSE,
qr = TRUE,
singular.ok = TRUE,
contrasts = NULL,
offset,
...
)
Arguments
data |
A |
formula |
The |
subset |
See the |
weights |
See the |
na.action |
See the |
method |
See the |
model |
See the |
x |
See the |
y |
See the |
qr |
See the |
singular.ok |
See the |
contrasts |
See the |
offset |
See the |
... |
Other arguments to be passed to the |
Value
A fitted model.
See Also
-
zglm is a wrapper for
glm
, to fit generalized linear models.
Examples
# Usage is possible without pipes
zlm( cars, dist ~ speed )
# zfit works well with dplyr and magrittr pipes
if ( require("dplyr", warn.conflicts=FALSE) ) {
# Pipe cars dataset into zlm for fitting
cars %>% zlm(speed ~ dist)
# Process iris with filter before piping to zlm
iris %>%
filter(Species == "setosa") %>%
zlm(Sepal.Length ~ Sepal.Width + Petal.Width)
}
# zfit also works well with the native pipe
if ( require("dplyr") && getRversion() >= "4.1.0" ) {
# Pipe cars dataset into zlm for fitting
cars |> zlm(speed ~ dist)
# Process iris with filter() before piping. Print a
# summary of the fitted model using zprint() before
# assigning the model itself (not the summary) to m.
m <- iris |>
filter(Species == "setosa") |>
zlm(Sepal.Length ~ Sepal.Width + Petal.Width) |>
zprint(summary)
}
[Package zfit version 0.4.0 Index]