![]() |
The World Bank provides a wealth of data that is invaluable for researchers, economists, and policymakers. This data encompasses various aspects of global development, including economic indicators, health statistics, education metrics, and environmental data. Leveraging this dataset in R, a powerful statistical programming language, can yield insightful analyses and visualizations. This guide will walk you through the process of accessing, manipulating, and visualizing World Bank data in R Programming Language. Table of Content 1. Accessing World Bank Data in RTo work with World Bank data in R, you need to install and load specific packages designed to interact with the World Bank’s API. Installing and loading Required PackagesThe
2. Retrieving DataThe To find the indicators you are interested in, use the
Output: indicator name
712 5.51.01.10.gdp Per capita GDP growth
714 6.0.GDP_current GDP (current $)
715 6.0.GDP_growth GDP growth (annual %)
716 6.0.GDP_usd GDP (constant 2005 $)
717 6.0.GDPpc_constant GDP per capita, PPP (constant 2011 international $)
1557 BG.GSR.NFSV.GD.ZS Trade in services (% of GDP) This command returns a dataframe with information about GDP-related indicators, including their codes and descriptions. Once you have identified the indicators you need, you can download the data. For example, to download GDP data for all countries from 2000 to 2020, use:
Output: country iso2c iso3c year NY.GDP.MKTP.CD
1 Africa Eastern and Southern ZH AFE 2020 9.288802e+11
2 Africa Eastern and Southern ZH AFE 2019 1.006191e+12
3 Africa Eastern and Southern ZH AFE 2018 1.012521e+12
4 Africa Eastern and Southern ZH AFE 2017 9.399593e+11
5 Africa Eastern and Southern ZH AFE 2016 8.297383e+11
6 Africa Eastern and Southern ZH AFE 2015 8.992556e+11 In this example, 3. Data ManipulationAfter downloading the data, you might need to clean and manipulate it to fit your analysis needs. Common tasks include handling missing values, filtering data, and reshaping data frames. Handling Missing ValuesTo handle missing values, you can use functions from the
Filtering DataTo focus on specific countries or regions, you can filter the dataset:
Reshaping DataFor certain types of analyses, you might need to reshape your data. The tidyr package from the tidyverse collection is particularly useful for this:
4. Data VisualizationVisualizing data is crucial for conveying insights effectively. The Plotting GDP TrendsTo plot GDP trends over time for the United States and China, you can use the following code:
Output: ![]() World Bank Dataset in R This code creates a line plot that shows how the GDP of the United States and China has evolved from 2000 to 2020. Customizing Plots
Output: ![]() World Bank Dataset in R 5. Advanced AnalysisFor more advanced analyses, you can integrate World Bank data with other datasets or perform statistical analyses. Combining DatasetsTo combine World Bank data with other data sources, use functions such as
Output: country iso2c.x iso3c.x year NY.GDP.MKTP.CD iso2c.y iso3c.y SP.POP.TOTL
1 Africa Eastern and Southern ZH AFE 2020 9.288802e+11 ZH AFE 685112979
2 Africa Eastern and Southern ZH AFE 2019 1.006191e+12 ZH AFE 667242986
3 Africa Eastern and Southern ZH AFE 2018 1.012521e+12 ZH AFE 649757148
4 Africa Eastern and Southern ZH AFE 2017 9.399593e+11 ZH AFE 632746570
5 Africa Eastern and Southern ZH AFE 2016 8.297383e+11 ZH AFE 616377605
6 Africa Eastern and Southern ZH AFE 2015 8.992556e+11 ZH AFE 600008424 Statistical AnalysisYou can perform various statistical analyses using base R or other specialized packages. For example, to calculate the correlation between GDP and population:
Output: [1] 0.6817722 ConclusionAccessing and analyzing World Bank data in R opens up a vast array of opportunities for research and insights into global development trends. By following the steps outlined in this guide, you can efficiently retrieve, manipulate, and visualize World Bank data to support your analyses and presentations. With the powerful combination of the |
Reffered: https://www.geeksforgeeks.org
AI ML DS |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 16 |