• 1 Preface
  • 2 Introduction
    • 2.1 Goals
      • 2.1.1 Tip
    • 2.2 What is R?
      • 2.2.1 Benefits of Using R
      • 2.2.2 R Packages
  • 3 Quick Reference
  • 4 Installation Links
    • 4.1 Updating Software and Packages
      • 4.1.1 R
      • 4.1.2 RStudio
      • 4.1.3 R-Packages
  • 5 RStudio
    • 5.1 Create a New Script
    • 5.2 RStudio Overview
      • 5.2.1 Source Window
      • 5.2.2 Console Window
      • 5.2.3 Environment, History, Connections, Build, and Git
      • 5.2.4 Files, Plots, Packages, Help, and Viewer
      • 5.2.5 Files Tab
      • 5.2.6 Plots Tab
      • 5.2.7 Packages Tab
      • 5.2.8 Help Tab
      • 5.2.9 Viewer Tab
    • 5.3 Shortcuts
  • 6 R Project
    • 6.1 Create a New R Project
    • 6.2 Navigate Between Packages
    • 6.3 Recommended Workflow
  • 7 Version Control
    • 7.1 Git Resources
    • 7.2 Link R Studio to GitHub Repository
    • 7.3 Push and Pull Repository Changes in R Studio
      • 7.3.1 Pull
      • 7.3.2 Commit
      • 7.3.3 Push
    • 7.4 Repository Branch
      • 7.4.1 Create a New Branch
    • 7.5 Merge Branches
  • 8 R Markdown
    • 8.1 Benefits
    • 8.2 Basic Overview
    • 8.3 Create a New Document
    • 8.4 Editing
      • 8.4.1 YAML Header
      • 8.4.2 Heading Text
      • 8.4.3 Plain Text
      • 8.4.4 Insert Code Chunks
    • 8.5 Compile the Document
    • 8.6 File Management
    • 8.7 Child Documents
      • 8.7.1 Extract and Run R-Code from R Markdown Files
    • 8.8 Parameterized Reports
  • 9 Base R
    • 9.1 Data Types
      • 9.1.1 Numeric (Double)
      • 9.1.2 Integer
      • 9.1.3 Logical
      • 9.1.4 Character
      • 9.1.5 Factor
  • 10 Data Structures
    • 10.1 Vectors
    • 10.2 Matrices
    • 10.3 Arrays
    • 10.4 Data Frames
    • 10.5 Lists
  • 11 Data Structure Manipulation
    • 11.1 Assignment Opperator (<-)
    • 11.2 Manipulting Vectors
    • 11.3 Manipulating Data Frames
    • 11.4 Importing Data
      • 11.4.1 file_path
      • 11.4.2 read.csv
  • 12 Style Guide
    • 12.1 Names
      • 12.1.1 Object Names: Discriptive Suffix
    • 12.2 Spacing and Indenting
  • 13 Writing Functions
  • 14 Loops
    • 14.1 for loop
    • 14.2 apply family
      • 14.2.1 apply
      • 14.2.2 lapply
      • 14.2.3 sapply
  • 15 Tidyverse
    • 15.1 Tidyverse Directory
    • 15.2 magrittr
      • 15.2.1 Example Data
      • 15.2.2 Pipe Operator (%>%)
  • 16 dplyr
    • 16.0.1 Example Data
    • 16.0.2 Rename
    • 16.0.3 Filter
    • 16.0.4 Select
    • 16.0.5 distinct
    • 16.0.6 mutate
    • 16.0.7 group_by
    • 16.0.8 summarize
    • 16.0.9 Joins
    • 16.0.10 Bind
  • 17 tidyr
    • 17.0.1 Example Data
    • 17.0.2 spread
    • 17.0.3 gather
    • 17.0.4 complete
    • 17.0.5 separate
    • 17.0.6 unite
  • 18 lubridate
    • 18.0.1 Example Data
    • 18.0.2 mdy, ymd, dmy, ymd_hms, …
    • 18.0.3 year, month, mday, yday, hour, minute, and second
    • 18.0.4 round_date, floor_date, and ceiling_date
  • 19 ggplot2
    • 19.0.1 Example Data
    • 19.0.2 ggplot
    • 19.0.3 aes
    • 19.0.4 geom_boxplot
  • 20 Shiny
    • 20.1 What is Shiny?
    • 20.2 Resources
    • 20.3 Project Composition
      • 20.3.1 ui.R
      • 20.3.2 server.R
      • 20.3.3 global.R
      • 20.3.4 Structure
      • 20.3.5 R-Packages
    • 20.4 Helpful R-Packages
      • 20.4.1 DT (Interactive Tables)
      • 20.4.2 dygraphs (Interactive Time Series Plots)
      • 20.4.3 leaflet (Interactive Maps)
      • 20.4.4 plotly (Interactive Figures)
    • 20.5 Publishing
      • 20.5.1 How to Publish to shinyapps.io
    • 20.6 Data Management
      • 20.6.1 Small Data Sets
      • 20.6.2 Large Data Sets
  • 21 Default Shiny Example

R in Practice

4 Installation Links

Please install R and RStudio by following the links below. I highly recommend that you also install Git (link below) and create an account on GitHub (link below). The Git related tools are very useful but some workplaces will not allow the use of these tools for security reasons. Therefore, I will briefly cover Git but you are not required to use these tools during the workshop.

Software Link
R https://cran.r-project.org/bin/windows/base/
RStudio https://www.rstudio.com/products/rstudio/download/#download
Git https://git-scm.com/downloads
GitHub https://github.com

4.1 Updating Software and Packages

4.1.1 R

Run the following code in the RGui, NOT in RStudio. The RGui should be installed when you install R. On my Windows machine, I access R by clicking on the R program file, “R x64 3.5.1”.

You should get a window like this if you have opened the correct program.

This code was copied from: https://www.r-statistics.com/2013/03/updating-r-from-r-on-windows-using-the-installr-package/). Make sure R Studio is closed before running this code within the RGui.

# installing/loading the package:
if(!require(installr)) {
install.packages("installr");
require(installr)
} #load / install+load installr

# using the package:
updateR()

4.1.2 RStudio

  1. Open RStudio
  2. Click on “Help” on the toolbar
  3. Click on “Check for Updates”
  4. Follow instructions

4.1.3 R-Packages

  1. Open RStudio
  2. Click on “Tools” on the toolbar
  3. Click on “Check for Package Updates…”
  4. Follow instructions

4.1.3.1 Packages for Workshop

Please run the following code within RStudio to make sure you have all of necessary packages for this workshop installed.

  1. Open RStudio
  2. Copy the following code
package.vec <- c("tidyverse", "lubridate",
                 "knitr", "rmarkdown", "markdown", "caTools", "bitops",
                 "DT", "leaflet", "shiny", "jsonlite",
                 "data.table", "rprojroot", "viridis")

install.packages(package.vec)
  1. Paste the code into the Console within RStudio
  1. Hit Enter
    • If prompted with “Do you want to restart R prior to installing?”, select “Yes”
    • If prompted again then select “No”
  2. The packages should begin to install. This may take some time.