Type: Package
Title: R Interface to e-Stat API
Version: 0.4.0
Description: Provides an interface to e-Stat API, the one-stop service for official statistics of the Japanese government.
URL: https://yutannihilation.github.io/estatapi/
BugReports: https://github.com/yutannihilation/estatapi/issues
License: MIT + file LICENSE
LazyData: TRUE
Depends: R (≥ 3.3)
Imports: httr, purrr (≥ 0.2), readr (≥ 0.2), dplyr (≥ 0.5.0), tibble, rlang
RoxygenNote: 7.1.0
Suggests: testthat, keyring
Encoding: UTF-8
NeedsCompilation: no
Packaged: 2020-04-12 06:03:19 UTC; yutani
Author: Hiroaki Yutani ORCID iD [aut, cre]
Maintainer: Hiroaki Yutani <yutani.ini@gmail.com>
Repository: CRAN
Date/Publication: 2020-04-12 06:20:02 UTC

R Interface to e-Stat API

Description

Provides an interface to e-Stat API, the one-stop service for official statistics of the Japanese government.

Author(s)

Maintainer: Hiroaki Yutani yutani.ini@gmail.com (ORCID)

See Also

http://www.e-stat.go.jp/SG1/estat/eStatTopPortalE.do


Util

Description

Util

Usage

ESTAT_API_URL

Format

An object of class character of length 1.


e-Stat API

Description

Get Statistical Something From e-Stat API

Usage

estat_api(path, appId, ...)

Arguments

path

API endpoint.

appId

Application ID.

...

Other parameters.


getDataCatalog API

Description

Get information about the statistical dataset files and databases via e-Stat API.

Usage

estat_getDataCatalog(
  appId,
  lang = c("J", "E"),
  .use_label = TRUE,
  surveyYears = NULL,
  openYears = NULL,
  statsField = NULL,
  statsCode = NULL,
  searchWord = NULL,
  dataType = NULL,
  catalogId = NULL,
  resourceId = NULL,
  startPosition = NULL,
  limit = NULL,
  updatedDate = NULL,
  ...
)

Arguments

appId

Application ID.

lang

Language of the data. "J"(Japanese) or "E"(English).

.use_label

Whether to take the human-redable label value or the code value when flattening a field containing both (default: TRUE).

surveyYears

Year and month when the survey was conducted. The format is either "YYYY", "YYYYMM", or "YYYYMM-YYYYMM".

openYears

Year and month when the survey result was opened. The format is the same as surveyYears.

statsField

Field of statistics. The format is either two digits(large classification) or four digits (small classification). For the detail of the classification, see http://www.soumu.go.jp/toukei_toukatsu/index/seido/sangyo/26index.htm.

statsCode

Code assigned for each statistical agency and statistics. The format can be five digits (agency), and eight digits (statistics). For the detail, see http://www.stat.go.jp/info/guide/public/code/code.htm.

searchWord

Keyword for searching. You can use OR and AND to combine conditions (e.g.: "apple AND orange").

dataType

Type of data. XLS: Excel file, CSV: CSV file, PDF: PDF file, DB: Database.

catalogId

Catalog ID.

resourceId

Catalog resource ID.

startPosition

Index of the first record to get.

limit

Max number of records to get.

updatedDate

Last updated date. The format is either "YYYY", "YYYYMM", or "YYYYMM-YYYYMM".

...

Other parameters.

See Also

http://www.e-stat.go.jp/api/e-stat-manual3-0/#api_2_6 http://www.e-stat.go.jp/api/e-stat-manual3-0/#api_3_7

Examples

## Not run: 
estat_getDataCatalog(
  appId = "XXXX",
  searchWord = "CD",
  dataType = "XLS",
  limit = 3
)

## End(Not run)

getMetaInfo API

Description

Get meta-information about the statistical dataset via e-Stat API.

Usage

estat_getMetaInfo(appId, statsDataId, lang = c("J", "E"), ...)

Arguments

appId

Application ID.

statsDataId

ID of the statistical dataset.

lang

Language of data. "J"(Japanese) or "E"(English).

...

Other parameters.

See Also

http://www.e-stat.go.jp/api/e-stat-manual3-0/#api_2_2 http://www.e-stat.go.jp/api/e-stat-manual3-0/#api_3_3

Examples

## Not run: 
estat_getMetaInfo(appId = "XXXX", statsDataId = "0003065345")

## End(Not run)


getStatsData API

Description

Get some statistical data via e-Stat API.

Usage

estat_getStatsData(
  appId,
  statsDataId,
  startPosition = NULL,
  limit = NULL,
  lang = c("J", "E"),
  .fetch_all = TRUE,
  ...
)

Arguments

appId

Application ID.

statsDataId

ID of the statistical dataset.

startPosition

Index of the first record to get.

limit

Max number of records to get.

lang

Language of the data. "J"(Japanese) or "E"(English).

.fetch_all

Whether to fetch all records when the number of records is larger than 100,000.

...

Other parameters.

  • lvTab: Level of the meta-information. The format can be X or X-Y, -X and ⁠X-⁠.

  • cdTab: Code(s) of the meta-infomation items to select. The format can be a character vector (c("001", "002")) or a chraracter of values and commas ("001,002").

  • cdTabFrom: The code of the first meta-information item to select.

  • cdTabTo: The code of the last meta-information item to select.

  • lvTime: Level of the time to select. The format is the same as lvTab

  • cdTime Time(s) to select. The format is the same way like cdTab

  • cdTimeFrom: The first time to select. The format is the same way like cdTabFrom

  • cdTimeTo: The last time to select. The format is the same way like cdTabTo

  • lvArea: Level of the area to select. The format is the same as lvTab

  • cdArea Code(s) of the Area to select. The format is the same way like cdTab

  • cdAreaFrom: The code of the first area to select. The format is the same way like cdTabFrom

  • cdAreaTo: The code of the last area to select. The format is the same way like cdTabTo

  • lvCat01, cdCat01, cdCat01From, cdCat01To, ...: The same way like above.

See Also

http://www.e-stat.go.jp/api/e-stat-manual3-0/#api_2_3 http://www.e-stat.go.jp/api/e-stat-manual3-0/#api_3_4

Examples

## Not run: 
# fetch all data, which may take time
estat_getStatsData(
  appId = "XXXX",
  statsDataId = "0003065345"
)

# fetch data up to 10 records
estat_getStatsData(
  appId = "XXXX",
  statsDataId = "0003065345",
  limit = 10
)

# fetch data up to 100,000 records (max number of records available at once)
estat_getStatsData(
  appId = "XXXX",
  statsDataId = "0003065345",
  .fetch_all = FALSE
)

# fetch all data in the specifed category
estat_getStatsData(
  appId = "XXXX",
  statsDataId = "0003065345",
  cdCat01 = c("008", "009", "010")
)

## End(Not run)


getStatsList API

Description

Search for statistical datasets via e-Stat API.

Usage

estat_getStatsList(
  appId,
  searchWord,
  lang = c("J", "E"),
  .use_label = TRUE,
  surveyYears = NULL,
  openYears = NULL,
  statsField = NULL,
  statsCode = NULL,
  searchKind = NULL,
  collectArea = NULL,
  startPosition = NULL,
  limit = NULL,
  updatedDate = NULL,
  ...
)

Arguments

appId

Application ID.

searchWord

Keyword for searching. You can use OR and AND to combine conditions (e.g.: "apple AND orange").

lang

Language of the data. "J"(Japanese) or "E"(English).

.use_label

Whether to take the human-redable label value or the code value when flattening a field containing both (default: TRUE).

surveyYears

Year and month when the survey was conducted. The format is either "YYYY", "YYYYMM", or "YYYYMM-YYYYMM".

openYears

Year and month when the survey result was opened. The format is the same as surveyYears.

statsField

Field of statistics. The format is either two digits(large classification) or four digits (small classification). For the detail of the classification, see http://www.soumu.go.jp/toukei_toukatsu/index/seido/sangyo/26index.htm.

statsCode

Code assigned for each statistical agency and statistics. The format can be five digits (agency), and eight digits (statistics). For the detail, see http://www.stat.go.jp/info/guide/public/code/code.htm.

searchKind

Type of statistics.

  • 1: summary

  • 2: regional mesh

collectArea

Area of statistics.

  • 1: country

  • 2: prefecture

  • 3: municipality

startPosition

Index of the first record to get.

limit

Max number of records to get.

updatedDate

Last updated date. The format is either "YYYY", "YYYYMM", or "YYYYMM-YYYYMM".

...

Other parameters.

See Also

http://www.e-stat.go.jp/api/e-stat-manual3-0/#api_2_1 http://www.e-stat.go.jp/api/e-stat-manual3-0/#api_3_2

Examples

## Not run: 
estat_getStatsList(
  appId = "XXXX",
  searchWord = "CD",
  limit = 3
)

## End(Not run)