library(tidyverse)
## ── Attaching core tidyverse packages ────────────────────────────────────────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ 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(readxl)

This lab uses different versions of the iris dataset. You can use links or download them to your machine. Copy the code produced by the dropdown menu into the code chunk. As a reminder the steps are:

You can see more about this dataset by running ?iris in the console.

If this is review to you, explore the “Import Options” on the bottom left of the import dataset menu.

  1. Read in the https://sisbid.github.io/Data-Wrangling/data/iris/iris_q1.csv dataset into the iris_q1 R object. What delimiter separates columns?
iris_q1 <- read_csv("https://sisbid.github.io/Data-Wrangling/data/iris/iris_q1.csv") # Your directory may vary!
## Rows: 150 Columns: 5
## ── Column specification ──────────────────────────────────────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Species
## dbl (4): Sepal.Length, Sepal.Width, Petal.Length, Petal.Width
## 
## ℹ 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.
head(iris_q1)
## # A tibble: 6 × 5
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
##          <dbl>       <dbl>        <dbl>       <dbl> <chr>  
## 1          5.1         3.5          1.4         0.2 setosa 
## 2          4.9         3            1.4         0.2 setosa 
## 3          4.7         3.2          1.3         0.2 setosa 
## 4          4.6         3.1          1.5         0.2 setosa 
## 5          5           3.6          1.4         0.2 setosa 
## 6          5.4         3.9          1.7         0.4 setosa
  1. Read in the https://sisbid.github.io/Data-Wrangling/data/iris/iris_q2.tsv dataset into the iris_q2 R object. What delimiter separates columns?
iris_q2 <- read_delim("https://sisbid.github.io/Data-Wrangling/data/iris/iris_q2.tsv", 
    delim = "\t")
## Rows: 150 Columns: 5
## ── Column specification ──────────────────────────────────────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr (1): Species
## dbl (4): Sepal.Length, Sepal.Width, Petal.Length, Petal.Width
## 
## ℹ 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.
head(iris_q2)
## # A tibble: 6 × 5
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
##          <dbl>       <dbl>        <dbl>       <dbl> <chr>  
## 1          5.1         3.5          1.4         0.2 setosa 
## 2          4.9         3            1.4         0.2 setosa 
## 3          4.7         3.2          1.3         0.2 setosa 
## 4          4.6         3.1          1.5         0.2 setosa 
## 5          5           3.6          1.4         0.2 setosa 
## 6          5.4         3.9          1.7         0.4 setosa
  1. Read in the https://sisbid.github.io/Data-Wrangling/data/iris/iris_q3.txt dataset into the iris_q3 R object. What delimiter separates columns?
iris_q3 <- read_table("https://sisbid.github.io/Data-Wrangling/data/iris/iris_q3.txt")
## 
## ── Column specification ──────────────────────────────────────────────────────────────────────────────────────────
## cols(
##   Sepal.Length = col_double(),
##   Sepal.Width = col_double(),
##   Petal.Length = col_double(),
##   Petal.Width = col_double(),
##   Species = col_character()
## )
head(iris_q3)
## # A tibble: 6 × 5
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
##          <dbl>       <dbl>        <dbl>       <dbl> <chr>  
## 1          5.1         3.5          1.4         0.2 setosa 
## 2          4.9         3            1.4         0.2 setosa 
## 3          4.7         3.2          1.3         0.2 setosa 
## 4          4.6         3.1          1.5         0.2 setosa 
## 5          5           3.6          1.4         0.2 setosa 
## 6          5.4         3.9          1.7         0.4 setosa
  1. Read in the https://sisbid.github.io/Data-Wrangling/data/iris/iris_q4.csv dataset into the iris_q4 R object. What delimiter separates columns? [hint: file extension is ambiguous]
iris_q4 <- read_delim("https://sisbid.github.io/Data-Wrangling/data/iris/iris_q4.csv", 
    delim = ":", escape_double = FALSE, trim_ws = TRUE)
## Rows: 150 Columns: 5
## ── Column specification ──────────────────────────────────────────────────────────────────────────────────────────
## Delimiter: ":"
## chr (1): Species
## dbl (4): Sepal.Length, Sepal.Width, Petal.Length, Petal.Width
## 
## ℹ 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.
head(iris_q4)
## # A tibble: 6 × 5
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
##          <dbl>       <dbl>        <dbl>       <dbl> <chr>  
## 1          5.1         3.5          1.4         0.2 setosa 
## 2          4.9         3            1.4         0.2 setosa 
## 3          4.7         3.2          1.3         0.2 setosa 
## 4          4.6         3.1          1.5         0.2 setosa 
## 5          5           3.6          1.4         0.2 setosa 
## 6          5.4         3.9          1.7         0.4 setosa
  1. Read in the https://sisbid.github.io/Data-Wrangling/data/iris/iris_xl.xlsx dataset into the iris_xl R object.
url <- "https://sisbid.github.io/Data-Wrangling/data/iris/iris_xl.xlsx"
destfile <- "iris_xl.xlsx"
curl::curl_download(url, destfile)
iris_xl <- read_excel(destfile)
head(iris_xl)
## # A tibble: 6 × 5
##   Sepal.Length Sepal.Width Petal.Length Petal.Width Species
##          <dbl>       <dbl>        <dbl>       <dbl> <chr>  
## 1          5.1         3.5          1.4         0.2 setosa 
## 2          4.9         3            1.4         0.2 setosa 
## 3          4.7         3.2          1.3         0.2 setosa 
## 4          4.6         3.1          1.5         0.2 setosa 
## 5          5           3.6          1.4         0.2 setosa 
## 6          5.4         3.9          1.7         0.4 setosa