pivot_wider()
## Rows: 12
## Columns: 4
## $ country <chr> "Afghanistan", "Afghanistan", "Afghanistan", "Afghanistan", "B…
## $ year <dbl> 1999, 1999, 2000, 2000, 1999, 1999, 2000, 2000, 1999, 1999, 20…
## $ type <chr> "cases", "population", "cases", "population", "cases", "popula…
## $ count <dbl> 745, 19987071, 2666, 20595360, 37737, 172006362, 80488, 174504…
table2 %>%
pivot_wider(names_from = type, values_from = count)
## # A tibble: 6 × 4
## country year cases population
## <chr> <dbl> <dbl> <dbl>
## 1 Afghanistan 1999 745 19987071
## 2 Afghanistan 2000 2666 20595360
## 3 Brazil 1999 37737 172006362
## 4 Brazil 2000 80488 174504898
## 5 China 1999 212258 1272915272
## 6 China 2000 213766 1280428583