Setup for Data Analytics with R Training
Required Software
Students should have a recent versions of the software below installed for the course:
- R (https://cran.r-project.org/
bin/windows/base/) - RStudio Desktop Open Source Edition (https://posit.co/download/rstudio-desktop/)
- R packages as described below.
Instructions
First, download and install R and RStudio from the sources above.
Second, install R packages. Students should do this and test the installation of the following R packages prior to the start of class following the steps below:
- Open the RStudio application.
- Run this first, to change the download option:
options(download.file.method = "wininet")
- Then, copy the below R code into the console within RStudio (see image below). After the code has been copied into the console, press enter. It may take a couple of minutes for the installation to complete.
## This is R Code package_list <- c("data.table", "ggplot2", "tidyverse", "Hmisc", "readr", "dplyr", "readxl", "haven", "reshape2", "GGally", "gapminder", "tidyr", "MASS", "magrittr", "stringr", "car", "effects", "AER", "broom", "rvest", "tesseract", "Matrix", "devtools", "purrr", "HSAUR3", "skimr", "cowplot", "ggthemes") install.packages(package_list)
Third, test the installation of the R packages by copying the following code into the console of the same RStudio session as when you installed the packages and pressing enter.
## testing if R packages were successfully installed installed <- lapply(package_list, require, character.only = TRUE) if (all(unlist(installed))) { message("Success, all packages installed!") } else { message("At least one package was not installed correctly :(") for (i in 1:length(package_list)) { if (!installed[[i]]) { message(paste0("--- '", package_list[i], "' was not installed correctly.")) } } }
If students receive error messages or are otherwise unable to install R, RStudio, or the R packages then please see the following troubleshooting section.
TROUBLESHOOTING
If students have any difficulty in installing R, RStudio, or R packages, there are two places to start for troubleshooting problems.
First, have an admin attempt to perform the installation of whichever step failed. This will often be an IT professional at your organization. Give them this set of instructions to assist with them performing the installation. Professional computers often have security settings that prevent installing software without admin rights.
Also have the admin perform all steps following the step that failed. For instance, if the student failed to install R, have the admin install R, as well as RStudio and all the R packages.
Second, If R and RStudio were successfully installed, but the R packages failed to install, and option 1 has already been attempted, then the student can request a download of the R packages from this link. Follow the steps below to install R packages using this method:
- Request the R packages download from Webucator.
- Open RStudio.
- Find the location of the R library(s) on the student’s computer by typing the following code into the console in RStudio:
.libPaths()
- There will likely be two file paths displayed. Download the R packages file to the directory which is the first file path displayed. If the student is not allowed to copy files into this directory, try the second directory listed in the R output. Keep trying all the listed directories until the student finds a location where they are allowed to download the file to.
- The R packages are in a zipped/compressed file above. It is necessary to unzip this file so that all the individual package files sit directly in the directory that is the R library (from steps 3-4). The directory structure should look something like this at the end of this step:
-R_library (may have a different name)/
----broom/
----conflicted/
----more_r_packages…
- To test the installation, run the following code in the RStudio console:
## testing if R packages were successfully installed package_list <- c("data.table", "ggplot2", "tidyverse", "Hmisc", "readr", "dplyr", "readxl", "haven", "reshape2", "GGally", "gapminder", "tidyr", "MASS", "magrittr", "stringr", "car", "effects", "AER", "broom", "rvest", "tesseract", "Matrix", "devtools", "purrr","HSAUR3", "skimr", "cowplot", "ggthemes") installed <- lapply(package_list, require, character.only = TRUE) if (all(unlist(installed))) { message("Success, all packages installed!") } else { message("At least one package was not installed correctly :(") for (i in 1:length(package_list)) { if (!installed[[i]]) { message(paste0("--- '", package_list[i], "' was not installed correctly.")) } } }
Courses and Class Files
This setup page is used for the following course: