MyNixOS website logo
Description

Korean Statistical Information Service (KOSIS).

API wrapper to download statistical information from the Korean Statistical Information Service (KOSIS) <https://kosis.kr/openapi/index/index.jsp>.

kosis package

R-CMD-check CRAN_Status_Badge

Introduction

Korean Statistical Information Service (KOSIS Open API Service)
(https://kosis.kr/openapi/index/index.jsp)

Service View CodeService View Name
MT_ZTITLE국내통계 주제별
MT_OTITLE국내통계 기관별
MT_GTITLE01e-지방지표(주제별)
MT_GTITLE02e-지방지표(지역별)
MT_CHOSUN_TITLE광복이전통계(1908~1943)
MT_HANKUK_TITLE대한민국통계연감
MT_STOP_TITLE작성중지통계
MT_RTITLE국제통계
MT_BUKHAN북한통계
MT_TM1_TITLE대상별통계
MT_TM2_TITLE이슈별통계
MT_ETITLE영문 KOSIS

Installation

# install dev version
devtools::install_github("seokhoonj/kosis")  

Example

library(kosis)

# set your api key
kosis.setKey(apiKey = "your_api_key")

# or permantly
usethis::edit_r_environ() # add KOSIS_API_KEY="your_api_key" in .Renviron

# get stat list
getStatList(vwCd = "MT_ZTITLE")
getStatList(vwCd = "MT_ZTITLE", parentListId = "F_29") # life tables

# get stat data (Actuarial Life Table)
data <- getStatData(orgId = "101", tblId = "DT_1B41", objL1 = "ALL")
life_table <- castItem(statData = data, itemVar = "ITM_NM")

# or get stat data from URL (recommeded by KOSIS)
browseKosis() # open a webpage where you can find the url to download the data
url <- "https://kosis.kr/openapi/Param/statisticsParameterData.do?method=getList&apiKey=&itmId=T6+T16+T26+T5+T15+T25+T2+T12+T22+T3+T13+T23+T4+T14+T24+T1+T11+T21+&objL1=ALL&objL2=&objL3=&objL4=&objL5=&objL6=&objL7=&objL8=&format=json&jsonVD=Y&prdSe=Y&newEstPrdCnt=3&prdInterval=1&orgId=101&tblId=DT_1B41"
data <- getStatDataFromURL(url)
life_table <- castItem(statData = data, itemVar = "ITM_NM")

Error

# The method using orgId and tblId is relatively easy but not recommended by KOSIS
# Need to manage some errors to use this method.

# default arguments: objL1 = "ALL", objL2 = "", objL3 = "", objL4 = "", ...
getStatData(orgId = "117", tblId = "DT_117N_A00124")
# If the error code is 20, change the objL2 variable
getStatData(orgId = "117", tblId = "DT_117N_A00124", objL2 = "ALL")
# If the error code is 20 again, change the objL3 variable
getStatData(orgId = "117", tblId = "DT_117N_A00124", objL2 = "ALL", objL3 = "ALL")
Metadata

Version

0.0.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows