wbstats 提供了世界银行数据库的数据接口
随着wbstats世界银行数据可以检索和数据功能的几个指标要求。不像WDI,数据返回一个“长”表的所有值和指标单独列一列。此外,功能WB让我指定多少值(MRV)我很感兴趣。
安装
install.packages(‘WDI’)
寻找数据
WDIsearch(‘gdp’)
WDIsearch(‘gdp’)[1:10,] indicator name
[1,] “BG.GSR.NFSV.GD.ZS” “Trade in services (% of GDP)”
[2,] “BM.KLT.DINV.GD.ZS” “Foreign direct investment,
netoutflows (% of GDP)”
[3,] “BN.CAB.XOKA.GD.ZS” “Current account balance (% ofGDP)”
[4,] “BN.CUR.GDPM.ZS” “Currentaccount balance excluding net
officialcapital grants (% of GDP)”
[5,] “BN.GSR.FCTY.CD.ZS” “Net income (% of GDP)”
[6,] “BN.KLT.DINV.CD.ZS” “Foreign direct investment (% of GDP)”
[7,] “BN.KLT.PRVT.GD.ZS” “Private capital flows, total (% ofGDP)”
[8,] “BN.TRF.CURR.CD.ZS” “Net current transfers (% ofGDP)”
[9,] “BNCABFUNDCD_” “CurrentAccount Balance, %GDP”
[10,] “BX.KLT.DINV.WD.GD.ZS” “Foreign direct investment,
net inflows (% of GDP)”
WDIsearch(‘gdp.*capita.*constant’) indicator name
[1,] “GDPPCKD” “GDP per Capita, constant US
,
m
i
l
l
i
o
n
s
"
[
2
,
]
"
N
Y
.
G
D
P
.
P
C
A
P
.
K
D
"
"
G
D
P
p
e
r
c
a
p
i
t
a
(
c
o
n
s
t
a
n
t
2000
U
S
,millions" [2,] "NY.GDP.PCAP.KD" "GDP per capita (constant 2000US
,millions"[2,]"NY.GDP.PCAP.KD""GDPpercapita(constant2000US)”
[3,] “NY.GDP.PCAP.KN” “GDP per capita (constant LCU)”
[4,] “NY.GDP.PCAP.PP.KD” “GDP per capita, PPP (constant 2005 international $)”
下载和使用数据
head(dat) iso2c country NY.GDP.PCAP.KD year1
CN China 9374.883 19602
CN China 9479.824 19613
CN China 9967.366 19624
CN China 10290.362 19635
CN China 10774.653 19646
CN China 11283.606 1965
画图和显示
library(ggplot2)
ggplot(dat,aes(year, NY.GDP.PCAP.KD, color=country)) + geom_line() +
xlab('Year') + ylab('GDP per capita')
原文链接:http://f.dataguru.cn/thread-640636-1-1.html
(出处: 炼数成金)