This contains data from the article 41% Of Fliers Think You’re Rude If You Recline Your Seat.
V1 is the response to question: “Is it rude to recline your seat on a plane?”
V2 is the response to question: “Do you ever recline your seat when you fly?”.
Answer the following questions in the rmarkdown document.
First, let’s read in the data
library(tidyverse)
## ── Attaching packages ───────────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.0 ✓ purrr 0.3.3
## ✓ tibble 2.1.3 ✓ dplyr 0.8.5
## ✓ tidyr 1.0.2 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ── Conflicts ──────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
# recliners <- read_csv(here::here("recliners.csv")
recliners <- read_csv(here::here("data/recliners.csv"))
## Parsed with column specification:
## cols(
## V1 = col_character(),
## `V2:Always` = col_double(),
## `V2:Usually` = col_double(),
## `V2:About half the time` = col_double(),
## `V2:Once in a while` = col_double(),
## `V2:Never` = col_double()
## )
recliners
## # A tibble: 3 x 6
## V1 `V2:Always` `V2:Usually` `V2:About half t… `V2:Once in a w… `V2:Never`
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 No, no… 124 145 82 116 35
## 2 Yes, s… 9 27 35 129 81
## 3 Yes, v… 3 3 NA 11 54
V2 as the key variable, and count as the value).recline_long <- recliners %>%
pivot_longer(cols = -V1,
# names_to = __,
# values_to = __)
names_to = "response",
values_to = "count")
recline_long
## # A tibble: 15 x 3
## V1 response count
## <chr> <chr> <dbl>
## 1 No, not rude at all V2:Always 124
## 2 No, not rude at all V2:Usually 145
## 3 No, not rude at all V2:About half the time 82
## 4 No, not rude at all V2:Once in a while 116
## 5 No, not rude at all V2:Never 35
## 6 Yes, somewhat rude V2:Always 9
## 7 Yes, somewhat rude V2:Usually 27
## 8 Yes, somewhat rude V2:About half the time 35
## 9 Yes, somewhat rude V2:Once in a while 129
## 10 Yes, somewhat rude V2:Never 81
## 11 Yes, very rude V2:Always 3
## 12 Yes, very rude V2:Usually 3
## 13 Yes, very rude V2:About half the time NA
## 14 Yes, very rude V2:Once in a while 11
## 15 Yes, very rude V2:Never 54
rename function to better describe the variable names.recline_long %>%
rename(question = V1)
## # A tibble: 15 x 3
## question response count
## <chr> <chr> <dbl>
## 1 No, not rude at all V2:Always 124
## 2 No, not rude at all V2:Usually 145
## 3 No, not rude at all V2:About half the time 82
## 4 No, not rude at all V2:Once in a while 116
## 5 No, not rude at all V2:Never 35
## 6 Yes, somewhat rude V2:Always 9
## 7 Yes, somewhat rude V2:Usually 27
## 8 Yes, somewhat rude V2:About half the time 35
## 9 Yes, somewhat rude V2:Once in a while 129
## 10 Yes, somewhat rude V2:Never 81
## 11 Yes, very rude V2:Always 3
## 12 Yes, very rude V2:Usually 3
## 13 Yes, very rude V2:About half the time NA
## 14 Yes, very rude V2:Once in a while 11
## 15 Yes, very rude V2:Never 54