# Overview of Datasets

The {ialiquor} package provides a dataset summarizing the the monthly Class E liquor sales (along with other attributes) in the State of Iowa.

The `liquor_sales` dataset contains the following fields:

- `year` - The year in which the sale information was recorded
- `year_mon` - The year and month of the sale in YYYY-MM-DD format (already in date-time format)
- `county` - Name of county where sale occurred
- `population` - The population of the county for that year (based on US Census Bureau data and retrieved via the Iowa Data Portal API)
- `type` - A high level grouping variable to classify common categories
- `category` - A grouping variable defined by the State to classify brands of liquor
- `state_cost` - Amount paid for the liquor by the State of Iowa in US$ (not adjusted for inflation)
- `state_revenue` - Amount paid to the State of Iowa by the retailers (all retailers in county) in US$ (not adjusted for inflation)
- `bottles_sold` - Number of bottles sold (regardless of size of bottle or volume)
- `volume` - Volume of liquor sold (in liters)

Data Source: Iowa Data Portal API

    library(ialiquor)

    str(liquor_sales)
    #> Classes 'tbl_df', 'tbl' and 'data.frame':    280736 obs. of  10 variables:
    #>  $ year         : num  2015 2015 2015 2015 2015 ...
    #>  $ year_month   : POSIXct, format: "2015-01-01" "2015-01-01" ...
    #>  $ county       : chr  "adair" "adair" "adair" "adair" ...
    #>  $ population   : num  7145 7145 7145 7145 7145 ...
    #>  $ type         : chr  "vodka" "other" "liqueur" "cocktail" ...
    #>  $ category     : chr  "100 proof vodka" "american alcohol" "american amaretto" "american cocktails" ...
    #>  $ state_cost   : num  254 54 89 182 346 ...
    #>  $ state_revenue: num  381 81 134 277 519 ...
    #>  $ bottles_sold : num  54 6 18 26 36 24 47 5 18 36 ...
    #>  $ volume       : num  58.5 4.5 19.5 45.5 27 ...

    head(liquor_sales)
    #>   year year_month county population     type                    category
    #> 1 2015 2015-01-01  adair       7145    vodka             100 proof vodka
    #> 2 2015 2015-01-01  adair       7145    other            american alcohol
    #> 3 2015 2015-01-01  adair       7145  liqueur           american amaretto
    #> 4 2015 2015-01-01  adair       7145 cocktail          american cocktails
    #> 5 2015 2015-01-01  adair       7145  liqueur american cordials & liqueur
    #> 6 2015 2015-01-01  adair       7145      gin           american dry gins
    #>   state_cost state_revenue bottles_sold volume
    #> 1     253.62        380.70           54   58.5
    #> 2      54.00         81.00            6    4.5
    #> 3      88.98        133.50           18   19.5
    #> 4     182.40        277.10           26   45.5
    #> 5     346.29        519.45           36   27.0
    #> 6      99.57        149.38           24   15.0

## Background on Data

The State of Iowa records daily transactions for Class E liquor sales and makes them available to the public monthly. The original dataset (found through the Iowa Data Portal) consists of more granular information such as liquor sales by vendor/retailer. Furthermore, the population data were also obtained from the Iowa Data Portal API. This information is derived from the US Census Bureau. As of November 2020, no current population data were available for any county in Iowa from the aforementioned API.

## Data Cleaning

The only ‘cleaning’ done during the data acquisition phase was to ensure that no null values were present for county. Furthermore, the results were aggregated to a monthly level and the variable `type` was derived to create a higher level grouping.