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

Description Usage Arguments Value See Also Examples

View source: R/grouped_lm.R

Description

Running linear model (lm) across multiple grouping variables.

Usage

1
2
3
4
5
6
7
8
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# 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"
)

IndrajeetPatil/groupedstats documentation built on June 17, 2021, 7:57 a.m.