EDS 222: Week 1: Discussion Section Lab Setup

{Student name}

2023-10-01

Getting set up for Labs in EDS 222

In EDS 222 labs, we will often be working with exercises based on Introduction to Modern Statistics (Çetinkaya-Rundel and Hardin, 2021). To be able to access the data and custom packages these exercises sometimes rely on, we need to do a bit of setup. This will get you all set for all future labs; you won’t need to do it each time.

Step 1: Create a Labs/ folder where you will store all your lab materials for EDS 222.

Step 2: Download _common.R from our course website and put it in the Labs/ folder.

Step 3: Install the following packages, if they are not already installed:1 Note: This will take a minute or two!

suppressMessages({
  install.packages(c(
    "tidymodels",
    "gghighlight",
    "glue",
    "ggmosaic",
    "ggridges",
    "gridExtra",
    "infer",
    "janitor",
    "knitr",
    "kableExtra",
    "maps",
    "openintro",
    "patchwork",
    "quantreg",
    "tidyverse",
    "scales",
    "skimr",
    "caret",
    "palmerpenguins",
    "survival",
    "waffle",
    "ggrepel",
    "ggpubr",
    "openintro"
  ))
})

Step 4: Load all the packages you need, plus the _common.R source file.2 Note: If you get a namespace load error for tidyverse, you want to remove the problem package, reinstall it, and then load tidyverse again.

# You probably already have these packages installed, so let's just load them
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.8.0     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readr)
library(gt)
library(openintro)
## Loading required package: airports
## Loading required package: cherryblossom
## Loading required package: usdata
## 
## Attaching package: 'openintro'
## 
## The following object is masked from 'package:gt':
## 
##     sp500
# Where is the root directory where all your labs live? Change this filepath to work on your computer.
rootdir <- "~/Dropbox/Teaching/UCSB/EDS_222/EDS222_data" #~/Dropbox/EDS222_data/"

Take a look at the help files for source() and file.path() functions. We will use these a lot in Labs and homework assignments.

# `source()` is a helpful function for calling and running other R scripts.
?source

# `file.path()` is a helpful function for creating file paths from directory and file names
?file.path

Now, use source to run the script _common.R, which loads all the packages we’ll need for our labs and does some extra stuff we won’t use today. You’ll source() this setup script before running all your labs.

source(file.path(rootdir,"labs","_common.R"))
## Warning: package 'glue' was built under R version 4.0.5
## Warning: package 'caret' was built under R version 4.0.5

For labs, we want to see all our code. Set your knitr options to echo=TRUE so you see all your code and output.

Done! First real lab on Thursday in class.