Thu Thập Dữ Liệu

tmt

2024-03-11

Thu thập dữ liệu từ World Bank

  • Cơ sở dữ liệu của world bank là một cơ sở dữ liệu khổng lồ chứa rất nhiều thông tin về kinh tế, xã hội, môi trường,… của các nước thành viên (189 thành viên).
  • Để lấy được dữ liệu từ World bank chúng ta cần cài đặt gói WDI.

Thu thập dữ liệu từ World Bank (tt)

Thu thập dữ liệu về dự trữ ngoại hối của Việt Nam (đơn vị tính là số tháng nhập khẩu)

library(tidyverse)
library(WDI)
ind <- WDIsearch('Total reserves')
tmp <- WDI(indicator = 'FI.RES.TOTL.MO', country = c('VNM'))
d <- tmp %>% select(year,FI.RES.TOTL.MO)
d <- na.omit(d)
names(d) <- c('year','DuTru')
head(d)
  year    DuTru
1 2022 2.641353
2 2021 3.686074
3 2020 3.978296
4 2019 3.366794
5 2018 2.529580
6 2017 2.462901

Thu thập dữ liệu từ World Bank (tt)

Thu thập dữ liệu về nợ nước ngoài của Việt Nam (đơn vị tính USD)

library(tidyverse)
library(WDI)
ind <- WDIsearch('debt')
tmp <- WDI(indicator = 'DT.DOD.DECT.CD', country = c('VNM'))
d <- tmp %>% select(year,DT.DOD.DECT.CD)
d <- na.omit(d)
names(d) <- c('year','No')
head(d)
  year           No
1 2022 146589136160
2 2021 139811946474
3 2020 129435488930
4 2019 122453706199
5 2018 112588329457
6 2017 109867474470

Thu thập dữ liệu từ World Bank (tt)

Thu thập dữ liệu về GDP của Việt Nam (đơn vị tính USD, giá hiện hành)

library(tidyverse)
library(WDI)
ind <- WDIsearch('GDP')
tmp <- WDI(indicator = 'NY.GDP.MKTP.CD', country = c('VNM'))
d <- tmp %>% select(year,NY.GDP.MKTP.CD)
d <- na.omit(d)
names(d) <- c('year','GDP')
head(d)
  year          GDP
1 2022 408802378905
2 2021 366137569122
3 2020 346615738538
4 2019 334365270497
5 2018 310106478395
6 2017 281353605987

Thu thập dữ liệu từ World Bank (tt)

Thu thập dữ liệu về tổng đầu tư cho giáo dục của Việt Nam (đơn vị tính % của GDP)

library(tidyverse)
library(WDI)
ind <- WDIsearch('education')
tmp <- WDI(indicator = 'SE.XPD.TOTL.GD.ZS', country = c('VNM'))
d <- tmp %>% select(year,SE.XPD.TOTL.GD.ZS)
d <- na.omit(d)
names(d) <- c('year','TyLe')
head(d)
  year     TyLe
1 2022 2.898134
2 2021 2.947887
3 2020 3.216529
4 2019 3.084998
5 2018 3.295370
6 2017 3.418657

Thu thập dữ liệu từ World Bank (tt)

Thu thập dữ liệu về thu thuế của Mỹ (đơn vị tính USD)

library(tidyverse)
library(WDI)
ind <- WDIsearch('tax revenue')
tmp <- WDI(indicator = 'GC.TAX.TOTL.CN', country = c('USA'))
d <- tmp %>% select(year,GC.TAX.TOTL.CN)
d <- na.omit(d)
names(d) <- c('year','Thue')
head(d)
  year         Thue
1 2022 3.135088e+12
2 2021 2.666222e+12
3 2020 2.177330e+12
4 2019 2.129405e+12
5 2018 2.051097e+12
6 2017 2.256154e+12

Thu thập dữ liệu từ IMF

  • Giới thiệu về csdl của IFM
  • Để thu thập được dữ liệu từ IMF chúng ta có nhiều package hỗ trợ như ifm.data, imfr.

Thu thập dữ liệu từ IMF (tt)

Thu thập dữ liệu về CPI của Việt Nam.

library(tidyverse)
library(imf.data)
tmp <- load_datasets('CPI')
cpi <- tmp$get_series(freq = 'M', ref_area = 'VN', indicator = 'PCPI_IX')
cpi <- na.omit(cpi)
names(cpi) <- c('ThoiGian','NamGoc','CPI')
head(cpi)
    ThoiGian NamGoc              CPI
624  2001-12  2019A 29.4869050755837
625  2002-01  2019A 29.7947965871095
626  2002-02  2019A 30.4502821120259
627  2002-03  2019A 30.2066798551297
628  2002-04  2019A 30.2066798551297
629  2002-05  2019A 30.2972998946951

Thu thập dữ liệu từ IMF (tt)

Thu thập dữ liệu về nợ công của Việt Nam (đơn vị tính: % trên GPD).

library(tidyverse)
library(imf.data)
tmp <- load_datasets('HPDD')
debt <- tmp$get_series(freq = 'A', ref_area = 'VN', indicator = 'GGXWDG_GDP')
debt <- na.omit(debt)
names(debt) <- c('ThoiGian','Debt')
head(debt)
  ThoiGian    Debt
1     1992 229.318
2     1993 174.589
3     1995 111.123
4     1996 94.4395
5     1997 76.1495
6     1998 79.3128