Last updated on

October 21, 2024

About the Material

This site serves as a compendium of teaching and coding material that I developed along the last couple of years. The material is based on text books (references will be given), websites (e.g., https://stats.stackexchange.com/), AI tools (e.g., ChatGPT, Blackbox AI). Many of the materials are also available as a Revealjs presentation that I usually use in teaching.

Used Software

Package Overview

The majority of the provided code is from the statistical software (R Core Team, 2024). Below, I list the packages I use most frequently, along with their respective versions.

pkgList <- c("base",
             "pak",
             "quarto",
             "rmarkdown",
             "knitr",
             "devtools",
             "haven",
             "renv",
             "stringr",
             "dplyr",
             "moments",
             "psych",
             "lme4",
             "merTools",
             "mice",
             "lavaan",
             "kableExtra",
             "flextable",
             "ggplot2")
  1. base (v4.4.1, R Core Team, 2024)
  2. pak (v0.8.0, Csárdi & Hester, 2024)
  3. quarto (v1.4.4, Allaire & Dervieux, 2024)
  4. rmarkdown (v2.27, Allaire et al., 2024)
  5. knitr (v1.47, Xie, 2023)
  6. devtools (v2.4.5, Wickham et al., 2022)
  7. haven (v2.5.4, Wickham, Miller, et al., 2023)
  8. renv (v1.0.9, Ushey & Wickham, 2024)
  9. stringr (v1.5.1, Wickham, 2023)
  10. dplyr (v1.1.4, Wickham, François, et al., 2023)
  11. moments (v0.14.1, Komsta & Novomestky, 2022)
  12. psych (v2.4.6.26, Revelle, 2024)
  13. lme4 (v1.1.35.4, Bates et al., 2024)
  14. merTools (v0.6.2, Knowles & Frederick, 2024)
  15. mice (v3.16.0, van Buuren & Groothuis-Oudshoorn, 2023)
  16. lavaan (v0.6.18, Rosseel et al., 2023)
  17. kableExtra (v1.4.0, Zhu, 2024)
  18. flextable (v0.9.6, Gohel & Skintzos, 2024)
  19. ggplot2 (v3.5.1, Wickham, Chang, et al., 2023)

Installation

Before installing the packages, install the pak package (Csárdi & Hester, 2024). The pak package is desinged to overcome some limitations of the install.packages() function and makes package management in R more reliable.

install.packages("pak", dependencies = TRUE)

To install the packages, run one of the following code snippets.

How I generated the code
installedPkgs <- as.data.frame(installed.packages()[, c("Package", "Version")]) |>
                    subset(subset = Package %in% pkgList[-1]) # delete base

paste0("myPks <- c(",
    paste0("'", with(installedPkgs, paste0(Package, "@", Version)), "'",
           collapse = ", "),
    ")") |>
      stringr::str_wrap(width = 80) |>
      cat()
myPks <- c('devtools@2.4.5', 'dplyr@1.1.4', 'flextable@0.9.6', 'ggplot2@3.5.1',
'haven@2.5.4', 'kableExtra@1.4.0', 'knitr@1.47', 'lavaan@0.6-18',
'lme4@1.1-35.4', 'merTools@0.6.2', 'mice@3.16.0', 'moments@0.14.1',
'pak@0.8.0', 'psych@2.4.6.26', 'quarto@1.4.4', 'renv@1.0.9', 'rmarkdown@2.27',
'stringr@1.5.1')
pak::pkg_install(pkg = myPks, upgrade = FALSE)
pak::pkg_install(pkg = pkgList, upgrade = TRUE)

Disclaimer

All material is licensed under the MIT License (MIT) and comes with ABSOLUTELY NO WARRANTY.

Important

The MIT License

Copyright (c) 2023

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bugs & Errors

Found errors or any bugs? Please send me an email or report them directly to github.com. At every page, below the table of contents, there is link to the repository of the website. If you think your issue may important for others, please use this option.

References

Allaire, J., & Dervieux, C. (2024). Quarto: R interface to quarto markdown publishing system. https://github.com/quarto-dev/quarto-r
Allaire, J., Xie, Y., Dervieux, C., McPherson, J., Luraschi, J., Ushey, K., Atkins, A., Wickham, H., Cheng, J., Chang, W., & Iannone, R. (2024). Rmarkdown: Dynamic documents for r. https://github.com/rstudio/rmarkdown
Bates, D., Maechler, M., Bolker, B., & Walker, S. (2024). lme4: Linear mixed-effects models using eigen and S4. https://github.com/lme4/lme4/
Csárdi, G., & Hester, J. (2024). Pak: Another approach to package installation. https://pak.r-lib.org/
Gohel, D., & Skintzos, P. (2024). Flextable: Functions for tabular reporting. https://ardata-fr.github.io/flextable-book/
Knowles, J. E., & Frederick, C. (2024). merTools: Tools for analyzing mixed effect regression models. https://CRAN.R-project.org/package=merTools
Komsta, L., & Novomestky, F. (2022). Moments: Moments, cumulants, skewness, kurtosis and related tests. https://www.r-project.org
R Core Team. (2024). R: A language and environment for statistical computing. R Foundation for Statistical Computing. https://www.R-project.org/
Revelle, W. (2024). Psych: Procedures for psychological, psychometric, and personality research. https://personality-project.org/r/psych/ https://personality-project.org/r/psych-manual.pdf
Rosseel, Y., Jorgensen, T. D., & De Wilde, L. (2023). Lavaan: Latent variable analysis. https://lavaan.ugent.be
Ushey, K., & Wickham, H. (2024). Renv: Project environments. https://rstudio.github.io/renv/
van Buuren, S., & Groothuis-Oudshoorn, K. (2023). Mice: Multivariate imputation by chained equations. https://github.com/amices/mice
Wickham, H. (2023). Stringr: Simple, consistent wrappers for common string operations. https://stringr.tidyverse.org
Wickham, H., Chang, W., Henry, L., Pedersen, T. L., Takahashi, K., Wilke, C., Woo, K., Yutani, H., & Dunnington, D. (2023). ggplot2: Create elegant data visualisations using the grammar of graphics. https://ggplot2.tidyverse.org
Wickham, H., François, R., Henry, L., Müller, K., & Vaughan, D. (2023). Dplyr: A grammar of data manipulation. https://dplyr.tidyverse.org
Wickham, H., Hester, J., Chang, W., & Bryan, J. (2022). Devtools: Tools to make developing r packages easier. https://devtools.r-lib.org/
Wickham, H., Miller, E., & Smith, D. (2023). Haven: Import and export SPSS, stata and SAS files. https://haven.tidyverse.org
Xie, Y. (2023). Knitr: A general-purpose package for dynamic report generation in r. https://yihui.org/knitr/
Zhu, H. (2024). kableExtra: Construct complex table with kable and pipe syntax. http://haozhu233.github.io/kableExtra/