---
title: "AMECO Dataset"
author: "Eric Persson"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{AMECO Dataset}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

## Introduction

This package contains the entire [European Commission Annual macro-economic 
(AMECO) 
database](http://ec.europa.eu/economy_finance/db_indicators/ameco/index_en.htm) 
in a format amenable to analysis in R.

The AMECO database was last updated: 11 May 2017.

## Simple example

The dataset is in a clean, long format:

```{r head}
library(dplyr)
library(ameco)
head(ameco)
```

Filtering with the `sub.chapter` variable allows you to easily find the variable
of interest:

```{r find_var}
ameco %>% 
  filter(sub.chapter == "01 Population") %>% 
  .$title %>% 
  unique()
```

Being interested in the total population of a few countries, we can easily
subset the data and plot the results:

```{r example, fig.width = 7, fig.height = 4}
library(ggplot2)

ameco %>% 
  dplyr::filter(title == "Total population",
         year == 2015,
         cntry %in% c("USA", "JPN", "DEU", "FRA", "ESP", "ITA")) %>% 
  ggplot(aes(x = reorder(country, -value), y = value / 1000)) +
  geom_bar(stat = "identity") +
  theme_bw() +
  labs(x = NULL, y = "Population (millions)", title = "Total population")
```

## Disclaimer

This package is not affiliated with, nor endorsed by, the European Commission. I
aim to update it whenever the AMECO database is updated. If you ever see that it
is out-of-date, don't hesitate to send a pull request and/or remind me to update
it.