lm_list: Fit linear models for multiple response variables in a...

Description Usage Arguments Value Examples

View source: R/lm_list.R

Description

Function creates from a vector of response variables in a given dataframe, a list of linear model objects. Additionally, a character vector of RHS terms of linear model formula specification, and a dataset needs to be passed.

Usage

1
lm_list(df, response, rhs_terms)

Arguments

df

A dataframe or any other object of coercible class

response

A character vector of response variables to fit a common formula to using 'lm'.

rhs_terms

A character vector. Used in specifying the model in the same order that was passed. Each element of the vector will be passed as a model term in the formula separated by "+".

Value

List of lm objects

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
mt_trial <- mtcars 
  rownames_to_column("vehicle_name") 
  as_tibble() 
  mutate_at(c("vehicle_name", "vs", "am"), as.factor)

lm_list(mt_trial, response = c("mpg", "drat", "qsec"), rhs_terms = c("am", "vs", "am/vs", "hp"))


## End(Not run)

DeependraD/expdean documentation built on Nov. 25, 2019, 12:33 a.m.