How to download average world GDP per capita (constant 2015 US$) by using WDI

Hi, I'm a new beginner of R.I want to use WDI to download global GDP per capita (constant 2015 US$) , like this figure. But I don't know how to define "country" in wdi. I only get all country of GDP, but I can't get a global data.

global_gdp<- WDI(indicator="NY.GDP.PCAP.KD",start=1990,end=2019)

Hi, have a look at the examples here. You can specify the country in the initial query.

https://www.r-project.org/nosvn/pandoc/WDI.html

Grab World Bank Data in R with {WDI} | Steven V. Miller (svmiller.com)

Thank you so much,williaml.I know how to catch the country's data that I want by WDI package.The problem is that I want to figure out how can I ONLY catch the global average GDP per capita data,not only countries.

You can use the code 1W for example.

library(WDI)

gdp <- WDI(indicator = 'NY.GDP.PCAP.KD', country = "1W", start = 2010, end = 2020)

Or download everything then filter for what you want.

1 Like

Thank you sooooooo much williaml ,you saved me!!!!! :grinning:
Hope you all good!!!!

Thank you so much ,williaml!!!You are great ,you solved my problem!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.