15.1 Load packages and import data

Load the usual packages, and broom, which has been used in some tutorials:

library(tidyverse)
library(skimr)
library(broom)

And we need these two packages also: car, boot. Install these if you don’t have them (as per instructions in a previous tutorial), then load them:

library(car)  
library(boot)

The “marine.csv” dataset is discussed in example 13.1 in the text book. The “flowers.csv” dataset is described below. The “students.csv” data include data about BIOL202 students from a few years ago.

Let’s make sure to treat any categorical variables as factor variables, using the “stringsAsFactors = T” argument:

marine <- read_csv("https://raw.githubusercontent.com/ubco-biology/BIOL202/main/data/marine.csv")
## Rows: 32 Columns: 1
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (1): biomassRatio
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
flowers <- read_csv("https://raw.githubusercontent.com/ubco-biology/BIOL202/main/data/flowers.csv")
## Rows: 30 Columns: 1
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl (1): propFertile
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
students <- read_csv("https://raw.githubusercontent.com/ubco-biology/BIOL202/main/data/students.csv")
## Rows: 154 Columns: 6
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): Dominant_hand, Dominant_foot, Dominant_eye
## dbl (3): height_cm, head_circum_cm, Number_of_siblings
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Explore the marine and flowers datasets:

marine %>%
  skim_without_charts()
(#tab:skim_marine)Data summary
Name Piped data
Number of rows 32
Number of columns 1
_______________________
Column type frequency:
numeric 1
________________________
Group variables None

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100
biomassRatio 0 1 1.73 0.75 0.83 1.27 1.49 1.85 4.25
flowers %>%
  skim_without_charts()
(#tab:skim_flowers)Data summary
Name Piped data
Number of rows 30
Number of columns 1
_______________________
Column type frequency:
numeric 1
________________________
Group variables None

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100
propFertile 0 1 0.47 0.33 0.01 0.13 0.49 0.75 0.99