This is the list of lab exercises from Tuesday’s class. Work your way through them, show your neighbour to check if you have them correct, and then to a tutor. Nothing to turn in today though.
library(tidyverse)
## ── Attaching packages ───────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 2.2.1.9000 ✔ purrr 0.2.4
## ✔ tibble 1.4.2 ✔ dplyr 0.7.4
## ✔ tidyr 0.8.0 ✔ stringr 1.3.0
## ✔ readr 1.1.1 ✔ forcats 0.3.0
## ── Conflicts ──────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
41% Of Fliers Think You’re Rude If You Recline Your Seat. In the following table, V1 is a response to the question “Is it rude to recline your seat on a plane?”, and V2 is the response to the question “Do you ever recline your seat when you fly?”. The data is in the form of a contingency table.
fly_tbl <- read_csv("data/fly_tbl.csv")
## Parsed with column specification:
## cols(
## V1 = col_character(),
## `V2:Always` = col_integer(),
## `V2:Usually` = col_integer(),
## `V2:About half the time` = col_integer(),
## `V2:Once in a while` = col_integer(),
## `V2:Never` = col_integer()
## )
fly_tbl
## # A tibble: 3 x 6
## V1 `V2:Always` `V2:Usually` `V2:About half th… `V2:Once in a wh…
## <chr> <int> <int> <int> <int>
## 1 No, not r… 124 145 82 116
## 2 Yes, some… 9 27 35 129
## 3 Yes, very… 3 3 NA 11
## # ... with 1 more variable: `V2:Never` <int>
V2
as the key variable, and count
as the value).You can get the data from the course web site.
Your job is to tidy the TB incidence data.
You can get the data from the course web site.
For the data set, rates.csv
,
rates <- read_csv("data/rates.csv")
## Parsed with column specification:
## cols(
## .default = col_double(),
## date = col_date(format = ""),
## BBD = col_integer(),
## BMD = col_integer(),
## BSD = col_integer(),
## CUC = col_integer(),
## PAB = col_integer(),
## USD = col_integer()
## )
## See spec(...) for full column specifications.
head(rates)
## # A tibble: 6 x 169
## date AED AFN ALL AMD ANG AOA ARS AUD AWG AZN
## <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 2017-06-20 3.67 68.1 119 481 1.78 166 16.1 1.32 1.80 1.70
## 2 2017-06-21 3.67 68.1 119 480 1.78 166 16.2 1.32 1.79 1.70
## 3 2017-06-22 3.67 68.1 119 481 1.78 166 16.1 1.33 1.79 1.70
## 4 2017-06-23 3.67 68.1 118 479 1.78 166 16.2 1.32 1.80 1.70
## 5 2017-06-24 3.67 68.1 118 479 1.78 166 16.2 1.32 1.80 1.70
## 6 2017-06-25 3.67 67.9 118 479 1.78 166 16.1 1.32 1.80 1.70
## # ... with 158 more variables: BAM <dbl>, BBD <int>, BDT <dbl>, BGN <dbl>,
## # BHD <dbl>, BIF <dbl>, BMD <int>, BND <dbl>, BOB <dbl>, BRL <dbl>,
## # BSD <int>, BTC <dbl>, BTN <dbl>, BWP <dbl>, BYN <dbl>, BZD <dbl>,
## # CAD <dbl>, CDF <dbl>, CHF <dbl>, CLF <dbl>, CLP <dbl>, CNH <dbl>,
## # CNY <dbl>, COP <dbl>, CRC <dbl>, CUC <int>, CUP <dbl>, CVE <dbl>,
## # CZK <dbl>, DJF <dbl>, DKK <dbl>, DOP <dbl>, DZD <dbl>, EGP <dbl>,
## # ERN <dbl>, ETB <dbl>, EUR <dbl>, FJD <dbl>, FKP <dbl>, GBP <dbl>,
## # GEL <dbl>, GGP <dbl>, GHS <dbl>, GIP <dbl>, GMD <dbl>, GNF <dbl>,
## # GTQ <dbl>, GYD <dbl>, HKD <dbl>, HNL <dbl>, HRK <dbl>, HTG <dbl>,
## # HUF <dbl>, IDR <dbl>, ILS <dbl>, IMP <dbl>, INR <dbl>, IQD <dbl>,
## # IRR <dbl>, ISK <dbl>, JEP <dbl>, JMD <dbl>, JOD <dbl>, JPY <dbl>,
## # KES <dbl>, KGS <dbl>, KHR <dbl>, KMF <dbl>, KPW <dbl>, KRW <dbl>,
## # KWD <dbl>, KYD <dbl>, KZT <dbl>, LAK <dbl>, LBP <dbl>, LKR <dbl>,
## # LRD <dbl>, LSL <dbl>, LYD <dbl>, MAD <dbl>, MDL <dbl>, MGA <dbl>,
## # MKD <dbl>, MMK <dbl>, MNT <dbl>, MOP <dbl>, MRO <dbl>, MUR <dbl>,
## # MVR <dbl>, MWK <dbl>, MXN <dbl>, MYR <dbl>, MZN <dbl>, NAD <dbl>,
## # NGN <dbl>, NIO <dbl>, NOK <dbl>, NPR <dbl>, NZD <dbl>, OMR <dbl>, …
You can get the data from rates.csv
## Parsed with column specification:
## cols(
## .default = col_double(),
## date = col_date(format = ""),
## BBD = col_integer(),
## BMD = col_integer(),
## BSD = col_integer(),
## CUC = col_integer(),
## PAB = col_integer(),
## USD = col_integer()
## )
## See spec(...) for full column specifications.
You can get the data from the course web site.