library(tidyverse)
## ── Attaching core tidyverse packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.2.1 ✔ readr 2.2.0
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ ggplot2 4.0.3 ✔ tibble 3.3.1
## ✔ lubridate 1.9.5 ✔ tidyr 1.3.2
## ✔ purrr 1.2.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 “slices” of the ufo 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:
> File> Import Dataset> From Text (readr)> paste the url> click “Update” and “Import”If this is review to you, explore the “Import Options” on the bottom left of the import dataset menu.
https://sisbid.github.io/Data-Wrangling/data/ufo/ufo_slice_1.csv dataset into the ufo_slice_1 R object. What delimiter separates columns?ufo_slice_1 <- read_csv("https://sisbid.github.io/Data-Wrangling/data/ufo/ufo_slice_1.csv") # Your directory may vary!
## Rows: 20 Columns: 11
## ── Column specification ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Delimiter: ","
## chr (8): datetime, city, state, country, shape, duration (hours/min), commen...
## dbl (3): duration (seconds), latitude, longitude
##
## ℹ 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(ufo_slice_1)
## # A tibble: 6 × 11
## datetime city state country shape `duration (seconds)` `duration (hours/min)`
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr>
## 1 7/28/20… new … ny us chan… 120 2 mins
## 2 8/15/19… mend… nj us fire… 30 30 seconds
## 3 10/16/2… char… mi <NA> cigar 30 30 seconds
## 4 4/25/20… fran… wi us sphe… 360 6 minutes
## 5 1/25/20… colo… co us cigar 180 3 min.
## 6 3/10/20… huson mt us circ… 120 several minutes
## # ℹ 4 more variables: comments <chr>, `date posted` <chr>, latitude <dbl>,
## # longitude <dbl>
https://sisbid.github.io/Data-Wrangling/data/ufo/ufo_slice_2.tsv dataset into the ufo_slice_2 R object. What delimiter separates columns?ufo_slice_2 <- read_delim("https://sisbid.github.io/Data-Wrangling/data/ufo/ufo_slice_2.tsv",
delim = "\t", escape_double = FALSE,
trim_ws = TRUE)
## Rows: 20 Columns: 11
## ── Column specification ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Delimiter: "\t"
## chr (8): datetime, city, state, country, shape, duration (hours/min), commen...
## dbl (3): duration (seconds), latitude, longitude
##
## ℹ 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(ufo_slice_2)
## # A tibble: 6 × 11
## datetime city state country shape `duration (seconds)` `duration (hours/min)`
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr>
## 1 11/15/1… cran… ri us light 5 5 seconds
## 2 12/25/2… prio… mn us light 240 3-4 minutes
## 3 10/29/2… ranc… ca us fire… 540 8-9 minutes
## 4 7/16/20… ottu… ia us light 0 <NA>
## 5 7/7/195… long… ca us light 45 45 seconds
## 6 8/16/20… taft ca <NA> light 3600 1 hour
## # ℹ 4 more variables: comments <chr>, `date posted` <chr>, latitude <dbl>,
## # longitude <dbl>
https://sisbid.github.io/Data-Wrangling/data/ufo/ufo_slice_3.csv dataset into the ufo_slice_3 R object. What delimiter separates columns? [hint: file extension is ambiguous]ufo_slice_3 <- read_delim("https://sisbid.github.io/Data-Wrangling/data/ufo/ufo_slice_3.csv",
delim = ":", escape_double = FALSE, trim_ws = TRUE)
## Rows: 20 Columns: 11
## ── Column specification ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
## Delimiter: ":"
## chr (8): datetime, city, state, country, shape, duration (hours/min), commen...
## dbl (3): duration (seconds), latitude, longitude
##
## ℹ 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(ufo_slice_3)
## # A tibble: 6 × 11
## datetime city state country shape `duration (seconds)` `duration (hours/min)`
## <chr> <chr> <chr> <chr> <chr> <dbl> <chr>
## 1 8/18/20… oakb… mb <NA> circ… 300 5 minutes
## 2 7/19/20… pawl… sc us light 1800 30 minutes
## 3 3/2/200… wash… dc <NA> light 60 1 minute
## 4 3/20/20… conc… nh us light 2 seconds
## 5 1/10/20… shaw… wy us unkn… 0 0002
## 6 6/2/200… albu… <NA> <NA> tria… 180 2-3mins
## # ℹ 4 more variables: comments <chr>, `date posted` <chr>, latitude <dbl>,
## # longitude <dbl>
https://sisbid.github.io/Data-Wrangling/data/ufo/ufo_slice_4.xlsx dataset into the ufo_slice_4 R object.library(readxl)
url <- "https://sisbid.github.io/Data-Wrangling/data/ufo/ufo_slice_4.xlsx"
destfile <- "ufo_slice_4.xlsx"
curl::curl_download(url, destfile)
ufo_slice_4 <- read_excel(destfile)
head(ufo_slice_4)
## # A tibble: 6 × 11
## datetime city state country shape `duration (seconds)`
## <dttm> <chr> <chr> <chr> <chr> <dbl>
## 1 2002-10-04 22:20:00 herzeliya (israe… NA NA light 0
## 2 2001-06-15 16:00:00 dallas tx us disk 30
## 3 1993-07-15 17:30:00 elkton md us light 300
## 4 2005-03-10 13:30:00 baltimore bwi ai… md NA disk 60
## 5 2005-01-08 06:30:00 chicago il us light 600
## 6 1994-06-01 10:28:00 elkton md us unkn… 0
## # ℹ 5 more variables: `duration (hours/min)` <chr>, comments <chr>,
## # `date posted` <dttm>, latitude <dbl>, longitude <dbl>