✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.
This question is about tidy temporal data. Below are total daily pedestrian traffic counts for the month of March for 2020 and 2019.
walk_daily_counts %>%
arrange(day, month)
## # A tibble: 62 × 6
## Date Count year month day wday
## <date> <int> <dbl> <ord> <int> <ord>
## 1 2019-03-01 34485 2019 Mar 1 Fri
## 2 2020-03-01 26840 2020 Mar 1 Sun
## 3 2019-03-02 33896 2019 Mar 2 Sat
## 4 2020-03-02 27900 2020 Mar 2 Mon
## 5 2019-03-03 27036 2019 Mar 3 Sun
## 6 2020-03-03 28003 2020 Mar 3 Tue
## 7 2019-03-04 33865 2019 Mar 4 Mon
## 8 2020-03-04 27949 2020 Mar 4 Wed
## 9 2019-03-05 34463 2019 Mar 5 Tue
## 10 2020-03-05 24936 2020 Mar 5 Thu
## # … with 52 more rows
To compare daily counts of pedestrians in March for 2019 compared to 2020, we could use a scatterplot. But first we would need to pivot the data to make daily counts for each year as column.
Fill in the blanks for the following code to get our desired output:
walk_daily_counts_wide <- walk_daily_counts_wide %>%
# (a) which pivot function
# (b) which id_cols
# (c) which column forms names_from
# (d) which column forms values_from
pivot_---(id_cols = ---, names_from = ---, values = ---)
## # A tibble: 31 × 3
## day `2019` `2020`
## <int> <int> <int>
## 1 1 34485 26840
## 2 2 33896 27900
## 3 3 27036 28003
## 4 4 33865 27949
## 5 5 34463 24936
## 6 6 33763 33456
## 7 7 35403 30580
## 8 8 43030 27444
## 9 9 40673 25149
## 10 10 36208 26425
## # … with 21 more rows
Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!