Coding workshop: Week 8

Multiple linear regression
tidyverse
readxl
here
janitor
GGally
MuMIn
ggeffects
gtsummary
flextable
modelsummary
relocate
ggpairs
model.sel
as_flextable
tbl_regression
modelsummary
ggpredict
reorder
summary
pipe (%>%) operator
github
forking
str
class
Author
Affiliation
Workshop date

May 23, 2024

Modified

June 13, 2024

1. Summary

Packages

  • tidyverse
  • readxl
  • here
  • janitor
  • GGally
  • MuMIn
  • ggeffects
  • gtsummary
  • flextable
  • modelsummary

Operations

New functions

  • move columns in data frame using relocate()
  • visualize correlations using ggpairs()
  • select models using model.sel()
  • create model summary tables using flextable::as_flextable(), gtsummary::tbl_regression(), and modelsummary::modelsummary()
  • reorder x-axis of figure using reorder()

Review

  • read in data using read_csv()
  • chain functions together using %>%
  • look at data using str() and class()
  • visualize data using ggplot()
  • create scatterplot and jitter plot using geom_point()
  • organize file paths using here()
  • construct a linear model using lm()
  • view model summary using summary()
  • visualize model predictions using ggpredict()
  • plot model diagnostics using plot()
  • plot model 95% CI using geom_ribbon()
  • plot model predictions using geom_line()
  • visualize model predictions using ggpredict()

Data sources

The dataset is from Valliere, Justin; Zhang, Jacqueline; Sharifi, M.; Rundel, Philip (2019). Data from: Can we condition native plants to increase drought tolerance and improve restoration success? [Dataset]. Dryad. https://doi.org/10.5061/dryad.v0861f7.

The associated paper is Valliere J. M., J. Zhang, M. R. Sharifi, and P. W. Rundel. 2019. Can we condition native plants to increase drought tolerance and improve restoration success? Ecological Applications 29(3):e01863. 10.1002/eap.1863.

2. Code

All code is in the rendered .html file in this repository.