Project Part 1

Preparing the alcohol consumption in 2016 for plotting.

  1. I downloaded Alcohol consumption data from Our World in Data. I selected this data because I am interested in alcohol consumption of men compared to women.

  2. This is the link to the data.

Men vs. Women who drank alcohol in 2016
  1. The following code chunk loads the package I will use to read in and prepare the data for analysis.
  1. Read the data in
males_vs_females_who_drank_alcohol_in_last_year <- read_csv(here::here("_posts/2022-05-09-project-part-1/males-vs-females-who-drank-alcohol-in-last-year.csv"))
  1. Use glimpse to see the names and types of the columns.
glimpse(males_vs_females_who_drank_alcohol_in_last_year)
Rows: 55,705
Columns: 7
$ Entity                                                         <chr> …
$ Code                                                           <chr> …
$ Year                                                           <dbl> …
$ `Indicator:Alcohol, consumers past 12 months (%) - Sex:Male`   <dbl> …
$ `Indicator:Alcohol, consumers past 12 months (%) - Sex:Female` <dbl> …
$ `Population (historical estimates)`                            <dbl> …
$ Continent                                                      <chr> …
# view(males_vs_females_who_drank_alcohol_in_last_year)
  1. Use output from glimpse (and View) to prepare the data for analysis
countries  <- c("China",
                "United States",
                "Italy",
                "India",
                "Spain")

country_alcohol_consumption  <- 
males_vs_females_who_drank_alcohol_in_last_year %>% 
  rename(Country = 1, Male = 4, Female = 5) %>% 
  filter(Year == 2016, Country %in% countries) %>% 
  select(Country, Male, Female)

country_alcohol_consumption
# A tibble: 5 × 3
  Country        Male Female
  <chr>         <dbl>  <dbl>
1 China          68.6   42.6
2 India          51.4   25.4
3 Italy          81.2   54.4
4 Spain          80.9   57  
5 United States  83     60.7

Check that the total for 2016 equals the total in the graph

Country Alcohol Consumption

Write the data to file in the project directory

write_csv(country_alcohol_consumption, file="country_alcohol_consumption.csv")