groupedstats (version 0.1.1)

grouped_lm: Running linear model (lm) across multiple grouping variables.

Description

Running linear model (lm) across multiple grouping variables.

Usage

grouped_lm(
  data,
  grouping.vars,
  ...,
  output = "tidy",
  tidy.args = list(conf.int = TRUE, conf.level = 0.95),
  augment.args = list()
)

Arguments

data

Dataframe (or tibble) from which variables are to be taken.

grouping.vars

Grouping variables.

...

Additional arguments to broom::tidy, broom::glance, or broom::augment S3 method.

output

A character describing what output is expected. Two possible options: "tidy" (default), which will return the results, or "glance", which will return model summaries.

tidy.args

A list of arguments to be used in the relevant S3 method.

augment.args

A list of arguments to be used in the relevant S3 method.

Value

A tibble dataframe with tidy results from linear model.

See Also

grouped_slr, grouped_tidy

Examples

Run this code
# NOT RUN {
# loading needed libraries
library(ggplot2)

# getting tidy output of results
grouped_lm(
  data = mtcars,
  grouping.vars = cyl,
  formula = mpg ~ am * wt,
  output = "tidy"
)

# getting model summaries
# diamonds dataset from ggplot2
grouped_lm(
  data = diamonds,
  grouping.vars = c(cut, color),
  formula = price ~ carat * clarity,
  output = "glance"
)
# }

Run the code above in your browser using DataLab