Tidyverse Recipes

Libraries

Tidyverse

dplyr

Load in data from fivethirtyeight github page.

Here I loaded in the Data in regards to alcohol comsumption in varies countries

tidy <-read_csv("https://raw.githubusercontent.com/fivethirtyeight/data/master/alcohol-consumption/drinks.csv")
## Parsed with column specification:
## cols(
##   country = col_character(),
##   beer_servings = col_integer(),
##   spirit_servings = col_integer(),
##   wine_servings = col_integer(),
##   total_litres_of_pure_alcohol = col_double()
## )
tidy
## # A tibble: 193 x 5
##    country   beer_servings spirit_servings wine_servings total_litres_of_~
##    <chr>             <int>           <int>         <int>             <dbl>
##  1 Afghanis~             0               0             0               0  
##  2 Albania              89             132            54               4.9
##  3 Algeria              25               0            14               0.7
##  4 Andorra             245             138           312              12.4
##  5 Angola              217              57            45               5.9
##  6 Antigua ~           102             128            45               4.9
##  7 Argentina           193              25           221               8.3
##  8 Armenia              21             179            11               3.8
##  9 Australia           261              72           212              10.4
## 10 Austria             279              75           191               9.7
## # ... with 183 more rows

To create this visualization, I chose to use ggplot which is part of the Tidyverse libarary

The scatter plot reveals to us the serving of beer from different countries.

tidy1 <- ggplot(data = tidy) +
  geom_point(mapping = aes(x= tidy$country, y = tidy$beer_servings, color= tidy$total_litres_of_pure_alcohol))

tidy1

tidy2 <- ggplot(data = tidy) +
  geom_bar(mapping = aes(x = tidy$total_litres_of_pure_alcohol))
          
tidy2