groupedstats (version 0.0.7)

grouped_lm: Function to run linear model (lm) across multiple grouping variables.

Description

Function to run 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.

...

Arguments to function.

These dots support tidy-dots features.

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

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