Load all the necessary packages

This shows you how to load all the packages required for all the tutorials.

If the package is not yet installed, the function will install it for you.

This list of packages avoids the use of the tidyverse package, which has been problematic for some.

Each time you start an R session, can copy and paste this code into your console and run it.

Alternatively, if you’re working on an assignment, you can copy and past this code into a code chunk at the beginning of your markdown document, and run it.

all.package.names <- c("dplyr", "readr","ggplot2", "tinytex", "skimr", "palmerpenguins", "knitr", "naniar", "janitor", "ggmosaic", "ggExtra", "infer", "binom", "epitools", "car", "broom", "kableExtra", "boot", "here", "gtsummary")

# Now let's load all the packages, first checking if the given package needs installing

# Load the packages using lapply

lapply(all.package.names, function(package) {
  if (!requireNamespace(package, quietly = TRUE)) {
    install.packages(package, dependencies = TRUE)
  }
  library(package, character.only = TRUE)
})
## [[1]]
##  [1] "boot"           "broom"          "car"            "carData"       
##  [5] "epitools"       "binom"          "infer"          "ggExtra"       
##  [9] "ggmosaic"       "naniar"         "janitor"        "knitr"         
## [13] "palmerpenguins" "here"           "skimr"          "lubridate"     
## [17] "forcats"        "stringr"        "dplyr"          "purrr"         
## [21] "readr"          "tidyr"          "tibble"         "ggplot2"       
## [25] "tidyverse"      "stats"          "graphics"       "grDevices"     
## [29] "utils"          "datasets"       "methods"        "base"          
## 
## [[2]]
##  [1] "boot"           "broom"          "car"            "carData"       
##  [5] "epitools"       "binom"          "infer"          "ggExtra"       
##  [9] "ggmosaic"       "naniar"         "janitor"        "knitr"         
## [13] "palmerpenguins" "here"           "skimr"          "lubridate"     
## [17] "forcats"        "stringr"        "dplyr"          "purrr"         
## [21] "readr"          "tidyr"          "tibble"         "ggplot2"       
## [25] "tidyverse"      "stats"          "graphics"       "grDevices"     
## [29] "utils"          "datasets"       "methods"        "base"          
## 
## [[3]]
##  [1] "boot"           "broom"          "car"            "carData"       
##  [5] "epitools"       "binom"          "infer"          "ggExtra"       
##  [9] "ggmosaic"       "naniar"         "janitor"        "knitr"         
## [13] "palmerpenguins" "here"           "skimr"          "lubridate"     
## [17] "forcats"        "stringr"        "dplyr"          "purrr"         
## [21] "readr"          "tidyr"          "tibble"         "ggplot2"       
## [25] "tidyverse"      "stats"          "graphics"       "grDevices"     
## [29] "utils"          "datasets"       "methods"        "base"          
## 
## [[4]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[5]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[6]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[7]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[8]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[9]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[10]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[11]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[12]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[13]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[14]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[15]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[16]]
##  [1] "tinytex"        "boot"           "broom"          "car"           
##  [5] "carData"        "epitools"       "binom"          "infer"         
##  [9] "ggExtra"        "ggmosaic"       "naniar"         "janitor"       
## [13] "knitr"          "palmerpenguins" "here"           "skimr"         
## [17] "lubridate"      "forcats"        "stringr"        "dplyr"         
## [21] "purrr"          "readr"          "tidyr"          "tibble"        
## [25] "ggplot2"        "tidyverse"      "stats"          "graphics"      
## [29] "grDevices"      "utils"          "datasets"       "methods"       
## [33] "base"          
## 
## [[17]]
##  [1] "kableExtra"     "tinytex"        "boot"           "broom"         
##  [5] "car"            "carData"        "epitools"       "binom"         
##  [9] "infer"          "ggExtra"        "ggmosaic"       "naniar"        
## [13] "janitor"        "knitr"          "palmerpenguins" "here"          
## [17] "skimr"          "lubridate"      "forcats"        "stringr"       
## [21] "dplyr"          "purrr"          "readr"          "tidyr"         
## [25] "tibble"         "ggplot2"        "tidyverse"      "stats"         
## [29] "graphics"       "grDevices"      "utils"          "datasets"      
## [33] "methods"        "base"          
## 
## [[18]]
##  [1] "kableExtra"     "tinytex"        "boot"           "broom"         
##  [5] "car"            "carData"        "epitools"       "binom"         
##  [9] "infer"          "ggExtra"        "ggmosaic"       "naniar"        
## [13] "janitor"        "knitr"          "palmerpenguins" "here"          
## [17] "skimr"          "lubridate"      "forcats"        "stringr"       
## [21] "dplyr"          "purrr"          "readr"          "tidyr"         
## [25] "tibble"         "ggplot2"        "tidyverse"      "stats"         
## [29] "graphics"       "grDevices"      "utils"          "datasets"      
## [33] "methods"        "base"          
## 
## [[19]]
##  [1] "kableExtra"     "tinytex"        "boot"           "broom"         
##  [5] "car"            "carData"        "epitools"       "binom"         
##  [9] "infer"          "ggExtra"        "ggmosaic"       "naniar"        
## [13] "janitor"        "knitr"          "palmerpenguins" "here"          
## [17] "skimr"          "lubridate"      "forcats"        "stringr"       
## [21] "dplyr"          "purrr"          "readr"          "tidyr"         
## [25] "tibble"         "ggplot2"        "tidyverse"      "stats"         
## [29] "graphics"       "grDevices"      "utils"          "datasets"      
## [33] "methods"        "base"          
## 
## [[20]]
##  [1] "gtsummary"      "kableExtra"     "tinytex"        "boot"          
##  [5] "broom"          "car"            "carData"        "epitools"      
##  [9] "binom"          "infer"          "ggExtra"        "ggmosaic"      
## [13] "naniar"         "janitor"        "knitr"          "palmerpenguins"
## [17] "here"           "skimr"          "lubridate"      "forcats"       
## [21] "stringr"        "dplyr"          "purrr"          "readr"         
## [25] "tidyr"          "tibble"         "ggplot2"        "tidyverse"     
## [29] "stats"          "graphics"       "grDevices"      "utils"         
## [33] "datasets"       "methods"        "base"