Import data

## # A tibble: 27 × 35
##    country country_code  year `Cardiovascular diseases (%)` `Cancers (%)`
##    <chr>   <chr>        <dbl>                         <dbl>         <dbl>
##  1 World   OWID_WRL      1990                          26.5          12.2
##  2 World   OWID_WRL      1991                          26.6          12.4
##  3 World   OWID_WRL      1992                          27.0          12.5
##  4 World   OWID_WRL      1993                          27.3          12.7
##  5 World   OWID_WRL      1994                          27.3          12.7
##  6 World   OWID_WRL      1995                          27.6          12.9
##  7 World   OWID_WRL      1996                          27.6          13.0
##  8 World   OWID_WRL      1997                          27.7          13.1
##  9 World   OWID_WRL      1998                          27.8          13.3
## 10 World   OWID_WRL      1999                          28.0          13.4
## # ℹ 17 more rows
## # ℹ 30 more variables: `Respiratory diseases (%)` <dbl>, `Diabetes (%)` <dbl>,
## #   `Dementia (%)` <dbl>, `Lower respiratory infections (%)` <dbl>,
## #   `Neonatal deaths (%)` <dbl>, `Diarrheal diseases (%)` <dbl>,
## #   `Road accidents (%)` <dbl>, `Liver disease (%)` <dbl>,
## #   `Tuberculosis (%)` <dbl>, `Kidney disease (%)` <dbl>,
## #   `Digestive diseases (%)` <dbl>, `HIV/AIDS (%)` <dbl>, …

Apply the following dplyr verbs to your data

Filter rows

## # A tibble: 1 × 35
##   country country_code  year `Cardiovascular diseases (%)` `Cancers (%)`
##   <chr>   <chr>        <dbl>                         <dbl>         <dbl>
## 1 World   OWID_WRL      1990                          26.5          12.2
## # ℹ 30 more variables: `Respiratory diseases (%)` <dbl>, `Diabetes (%)` <dbl>,
## #   `Dementia (%)` <dbl>, `Lower respiratory infections (%)` <dbl>,
## #   `Neonatal deaths (%)` <dbl>, `Diarrheal diseases (%)` <dbl>,
## #   `Road accidents (%)` <dbl>, `Liver disease (%)` <dbl>,
## #   `Tuberculosis (%)` <dbl>, `Kidney disease (%)` <dbl>,
## #   `Digestive diseases (%)` <dbl>, `HIV/AIDS (%)` <dbl>, `Suicide (%)` <dbl>,
## #   `Malaria (%)` <dbl>, `Homicide (%)` <dbl>, …
## # A tibble: 1 × 35
##   country country_code  year `Cardiovascular diseases (%)` `Cancers (%)`
##   <chr>   <chr>        <dbl>                         <dbl>         <dbl>
## 1 World   OWID_WRL      2016                          32.3          16.3
## # ℹ 30 more variables: `Respiratory diseases (%)` <dbl>, `Diabetes (%)` <dbl>,
## #   `Dementia (%)` <dbl>, `Lower respiratory infections (%)` <dbl>,
## #   `Neonatal deaths (%)` <dbl>, `Diarrheal diseases (%)` <dbl>,
## #   `Road accidents (%)` <dbl>, `Liver disease (%)` <dbl>,
## #   `Tuberculosis (%)` <dbl>, `Kidney disease (%)` <dbl>,
## #   `Digestive diseases (%)` <dbl>, `HIV/AIDS (%)` <dbl>, `Suicide (%)` <dbl>,
## #   `Malaria (%)` <dbl>, `Homicide (%)` <dbl>, …
## # A tibble: 27 × 35
##    country country_code  year `Cardiovascular diseases (%)` `Cancers (%)`
##    <chr>   <chr>        <dbl>                         <dbl>         <dbl>
##  1 World   OWID_WRL      1990                          26.5          12.2
##  2 World   OWID_WRL      1991                          26.6          12.4
##  3 World   OWID_WRL      1992                          27.0          12.5
##  4 World   OWID_WRL      1993                          27.3          12.7
##  5 World   OWID_WRL      1994                          27.3          12.7
##  6 World   OWID_WRL      1995                          27.6          12.9
##  7 World   OWID_WRL      1996                          27.6          13.0
##  8 World   OWID_WRL      1997                          27.7          13.1
##  9 World   OWID_WRL      1998                          27.8          13.3
## 10 World   OWID_WRL      1999                          28.0          13.4
## # ℹ 17 more rows
## # ℹ 30 more variables: `Respiratory diseases (%)` <dbl>, `Diabetes (%)` <dbl>,
## #   `Dementia (%)` <dbl>, `Lower respiratory infections (%)` <dbl>,
## #   `Neonatal deaths (%)` <dbl>, `Diarrheal diseases (%)` <dbl>,
## #   `Road accidents (%)` <dbl>, `Liver disease (%)` <dbl>,
## #   `Tuberculosis (%)` <dbl>, `Kidney disease (%)` <dbl>,
## #   `Digestive diseases (%)` <dbl>, `HIV/AIDS (%)` <dbl>, …

Arrange rows

## # A tibble: 27 × 35
##    country country_code  year `Cardiovascular diseases (%)` `Cancers (%)`
##    <chr>   <chr>        <dbl>                         <dbl>         <dbl>
##  1 World   OWID_WRL      2016                          32.3          16.3
##  2 World   OWID_WRL      2015                          31.9          16.2
##  3 World   OWID_WRL      2014                          31.6          15.9
##  4 World   OWID_WRL      2013                          31.3          15.7
##  5 World   OWID_WRL      2012                          31.0          15.5
##  6 World   OWID_WRL      2011                          30.6          15.3
##  7 World   OWID_WRL      2010                          30.3          15.1
##  8 World   OWID_WRL      2009                          30.1          15.0
##  9 World   OWID_WRL      2008                          29.7          14.7
## 10 World   OWID_WRL      2007                          29.6          14.6
## # ℹ 17 more rows
## # ℹ 30 more variables: `Respiratory diseases (%)` <dbl>, `Diabetes (%)` <dbl>,
## #   `Dementia (%)` <dbl>, `Lower respiratory infections (%)` <dbl>,
## #   `Neonatal deaths (%)` <dbl>, `Diarrheal diseases (%)` <dbl>,
## #   `Road accidents (%)` <dbl>, `Liver disease (%)` <dbl>,
## #   `Tuberculosis (%)` <dbl>, `Kidney disease (%)` <dbl>,
## #   `Digestive diseases (%)` <dbl>, `HIV/AIDS (%)` <dbl>, …

Select columns

## # A tibble: 27 × 1
##     year
##    <dbl>
##  1  1990
##  2  1991
##  3  1992
##  4  1993
##  5  1994
##  6  1995
##  7  1996
##  8  1997
##  9  1998
## 10  1999
## # ℹ 17 more rows
## # A tibble: 27 × 1
##    country
##    <chr>  
##  1 World  
##  2 World  
##  3 World  
##  4 World  
##  5 World  
##  6 World  
##  7 World  
##  8 World  
##  9 World  
## 10 World  
## # ℹ 17 more rows

Add columns

## # A tibble: 27 × 1
##     gain
##    <dbl>
##  1  14.3
##  2  14.2
##  3  14.4
##  4  14.7
##  5  14.7
##  6  14.8
##  7  14.6
##  8  14.6
##  9  14.5
## 10  14.7
## # ℹ 17 more rows

Summarize by groups

Collapsing data to a single row

## # A tibble: 27 × 35
##    country country_code  year `Cardiovascular diseases (%)` `Cancers (%)`
##    <chr>   <chr>        <dbl>                         <dbl>         <dbl>
##  1 World   OWID_WRL      1990                          26.5          12.2
##  2 World   OWID_WRL      1991                          26.6          12.4
##  3 World   OWID_WRL      1992                          27.0          12.5
##  4 World   OWID_WRL      1993                          27.3          12.7
##  5 World   OWID_WRL      1994                          27.3          12.7
##  6 World   OWID_WRL      1995                          27.6          12.9
##  7 World   OWID_WRL      1996                          27.6          13.0
##  8 World   OWID_WRL      1997                          27.7          13.1
##  9 World   OWID_WRL      1998                          27.8          13.3
## 10 World   OWID_WRL      1999                          28.0          13.4
## # ℹ 17 more rows
## # ℹ 30 more variables: `Respiratory diseases (%)` <dbl>, `Diabetes (%)` <dbl>,
## #   `Dementia (%)` <dbl>, `Lower respiratory infections (%)` <dbl>,
## #   `Neonatal deaths (%)` <dbl>, `Diarrheal diseases (%)` <dbl>,
## #   `Road accidents (%)` <dbl>, `Liver disease (%)` <dbl>,
## #   `Tuberculosis (%)` <dbl>, `Kidney disease (%)` <dbl>,
## #   `Digestive diseases (%)` <dbl>, `HIV/AIDS (%)` <dbl>, …
## # A tibble: 1 × 1
##   average
##     <dbl>
## 1    29.0