lm_num_cat: Linear model plot function with 'ggplot2' Function for...

Description Usage Arguments Value Examples

View source: R/NumCatPredictors_lm.R

Description

Linear model plot function with 'ggplot2' Function for plotting a linear regression model using the 'ggplot2' package. This function includes a colored trend line.

Usage

1
lm_num_cat(ants, min_ma, max_ma, subfamily)

Arguments

data

A data frame.

response

A column in the data frame to be used as a response variable.

num_predictor

A column in the data frame containing numerical values to be used as the predictor variable.

cat_predictor

A column in the data frame containing categorical values to be used as an additional predictor variable distinguished by color; If left blank, the linear regression plot will be returned with only one predictor value.

Value

A linear regression plot with a colored trend line.

Examples

1
2
3
4
5
6
7
8
  ants %>% 
   change_na_rm("None") %>% 
   lm_num_cat(min_ma, max_ma)
  ants %>%
   change_na_rm("None") %>%
   lm_num_cat(min_ma, max_ma, Genus) +
   annotate("text", x = 42, y = 27, 
   label = "R^2 == 0.987", parse = TRUE, size = 4)

kateparrish9887/R_package_Parrish documentation built on Dec. 21, 2021, 5:20 a.m.