【R】eurostat

1. はじめに

さんざん使ってきて、今更ですが、eurostatは、Eurostatのオープンデータにアクセス、取得、可視化するパッケージです。

2. インストール

CRANからインストールできます。

install.packages("eurostat")

3. つかってみる

使える関数は以下の通り。

add_nuts_level          Add the statistical aggregation level to data
                        frame
check_access_to_data    Check access to ec.europe.eu
clean_eurostat_cache    Clean Eurostat Cache
cut_to_classes          Cuts the Values Column into Classes and
                        Polishes the Labels
dic_order               Order of Variable Levels from Eurostat
                        Dictionary.
eu_countries            Countries and Country Codes
eurostat_geodata_60_2016
                        Geospatial data of Europe from Gisco in 1:60
                        million scale from year 2016
eurostat-package        R Tools for Eurostat open data
eurotime2date           Date Conversion from Eurostat Time Format
eurotime2num            Conversion of Eurostat Time Format to Numeric
get_bibentry            Create A Data Bibliography
get_eurostat            Read Eurostat Data
get_eurostat_dic        Download Eurostat Dictionary
get_eurostat_geospatial
                        Download Geospatial Data from GISCO
get_eurostat_json       Get Data from Eurostat API in JSON
get_eurostat_raw        Download Data from Eurostat Database
get_eurostat_toc        Download Table of Contents of Eurostat Data
                        Sets
harmonize_country_code
                        Harmonize Country Code
harmonize_geo_code      Harmonize NUTS region codes that changed with
                        the 'NUTS2016' definition
label_eurostat          Get Eurostat Codes
nuts_correspondence     Correspondence Table NUTS2013-NUTS2016
recode_to_nuts_2013     Recode geo labels and rename regions from
                        NUTS2016 to NUTS2013
recode_to_nuts_2016     Recode geo labels and rename regions from
                        NUTS2013 to NUTS2016
regional_changes_2016   Changes in regional boundaries
                        NUTS2013-NUTS2016
search_eurostat         Grep Datasets Titles from Eurostat
tgs00026                Auxiliary Data

Table of contantsを見てみます。

toc <- get_eurostat_toc()

knitr::kable(head(toc))
> knitr::kable(head(toc))


|title                                                    |code      |type    |last update of data |last table structure change |data start |data end |values |
|:--------------------------------------------------------|:---------|:-------|:-------------------|:---------------------------|:----------|:--------|:------|
|Database by themes                                       |data      |folder  |NA                  |NA                          |NA         |NA       |NA     |
|General and regional statistics                          |general   |folder  |NA                  |NA                          |NA         |NA       |NA     |
|European and national indicators for short-term analysis |euroind   |folder  |NA                  |NA                          |NA         |NA       |NA     |
|Business and consumer surveys (source: DG ECFIN)         |ei_bcs    |folder  |NA                  |NA                          |NA         |NA       |NA     |
|Consumer surveys (source: DG ECFIN)                      |ei_bcs_cs |folder  |NA                  |NA                          |NA         |NA       |NA     |
|Consumers - monthly data                                 |ei_bsco_m |dataset |29.04.2021          |29.04.2021                  |1980M01    |2021M04  |NA     |

例えば、”House”に関するデータがあるか調べてみます。

library(eurostat)

house <- search_eurostat("house")
knitr::kable(head(house))
> knitr::kable(head(passengers))


|title                                                                       |code            |type    |last update of data |last table structure change |data start |data end |values |
|:---------------------------------------------------------------------------|:---------------|:-------|:-------------------|:---------------------------|:----------|:--------|:------|
|Private households by type, tenure status and NUTS 2 region                 |cens_11htts_r2  |dataset |23.04.2015          |08.02.2021                  |2011       |2011     |NA     |
|Population by sex, age group, household status and NUTS 3 regions           |cens_01rhtype   |dataset |26.03.2009          |08.02.2021                  |2001       |2001     |NA     |
|Population by sex, age group, size of household and NUTS 3 regions          |cens_01rhsize   |dataset |09.02.2011          |08.02.2021                  |2001       |2001     |NA     |
|Private households by composition, size and NUTS 3 regions                  |cens_01rheco    |dataset |26.03.2009          |08.02.2021                  |2001       |2001     |NA     |
|Private households by composition, age group of children and NUTS 3 regions |cens_01rhagchi  |dataset |26.03.2009          |08.02.2021                  |2001       |2001     |NA     |
|Income of households by NUTS 2 regions                                      |nama_10r_2hhinc |dataset |30.04.2021          |16.03.2021                  |1995       |2019     |NA     |

では、そのデータを取得してみます。

id <- search_eurostat("house", type = "table")$code[1]
dat <- get_eurostat(id, time_format = "num")

head(dat)
> head(dat)
# A tibble: 6 x 6
  unit              direct na_item geo    time values
  <chr>             <chr>  <chr>   <chr> <dbl>  <dbl>
1 PPS_EU27_2020_HAB BAL    B6N     AT11   2008  19200
2 PPS_EU27_2020_HAB BAL    B6N     AT12   2008  20200
3 PPS_EU27_2020_HAB BAL    B6N     AT13   2008  20100
4 PPS_EU27_2020_HAB BAL    B6N     AT21   2008  18700
5 PPS_EU27_2020_HAB BAL    B6N     AT22   2008  19100
6 PPS_EU27_2020_HAB BAL    B6N     AT31   2008  19600

4. さいごに

ヨーロッパのデータを見る機会はありますので、有用なパッケージです。

Add a Comment

メールアドレスが公開されることはありません。