3.10 Exercise - spread()

Using the GBD dataset with variables cause, year (1990 and 2017 only), sex (as shown in Table 3.3):

Spread the cause variable into columns using the deaths_millions as values:

TABLE 3.4: Exercise: putting the cause variable into the wide format using spread.
year sex Communicable diseases Injuries Non-communicable diseases
1990 Female 7.30 1.41 12.80
1990 Male 8.06 2.84 13.91
2017 Female 4.91 1.42 19.15
2017 Male 5.47 3.05 21.74

Solution