✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.
This question is about tidy temporal data. Below are the data on military expenditure for different countries
head(expenditure)
## # A tibble: 6 × 4
## Entity Code Year military_expenditure
## <chr> <chr> <dbl> <dbl>
## 1 Afghanistan AFG 1970 5373185
## 2 Afghanistan AFG 1973 6230685
## 3 Afghanistan AFG 1974 6056124
## 4 Afghanistan AFG 1975 6357396
## 5 Afghanistan AFG 1976 8108200
## 6 Afghanistan AFG 1977 8553767
To compare expenditure counts of Australia and Germany between 2015 and 2020, we are going to select the observations for those two countries and that time range. Then we want change the data format so that the expenditure for Australia and the expenditure for Germany across different years appears in two different columns.
Fill in the blanks for the following code to get our desired output:
exp2 <- expenditure %>%
# (a) which pivot function
# (b) which id_cols
# (c) which column forms names_from
# (d) which colum forms values_from
dplyr::---(Entity %in% c("Australia", "Germany",
Year >= 2015) %>%
pivot_---(id_cols = ---,
names_from = ---,
values_from = ---)
Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!