The World Bank Data

The Word Bank Open Trade and Competitiveness Data

Load the required packages

library(pacman)
p_load(data360r, widgetframe, plotly, tidyverse, tidyselect)

Data is from Worldwide Governance Indicators: here

The WGI measure six broad dimensions of governance:

  1. Voice and Accountability (VA) – capturing perceptions of the extent to which a country’s citizens are able to participate in selecting their government, as well as freedom of expression, freedom of association, and a free media.
  2. Political Stability and Absence of Violence/Terrorism (PV) – capturing perceptions of the likelihood of political instability and/or politically-motivated violence, including terrorism.
  3. Government Effectiveness (GE) – capturing perceptions of the quality of public services, the quality of the civil service and the degree of its independence from political pressures, the quality of policy formulation and implementation, and the credibility of the government’s commitment to such policies.
  4. Regulatory Quality (RQ) – capturing perceptions of the ability of the government to formulate and implement sound policies and regulations that permit and promote private sector development.
  5. Rule of Law (RL) – capturing perceptions of the extent to which agents have confidence in and abide by the rules of society, and in particular the quality of contract enforcement, property rights, the police, and the courts, as well as the likelihood of crime and violence.
  6. Control of Corruption (CC) – capturing perceptions of the extent to which public power is exercised for private gain, including both petty and grand forms of corruption, as well as “capture” of the state by elites and private interests. question_answer

Download and process data with data360r

df   <- get_data360(dataset_id = 51)  %>% as_tibble()
# df  %>% glimpse()
# names(df)  %>% vars_select(contains("20"))
df_corruption  <- df  %>% 
  pivot_longer(cols = contains("20"), names_to = 'year')  %>% 
  janitor::clean_names()  %>% 
  mutate(year = as.numeric(year))   %>% 
  filter( year > 2003)

df_corruption  %>% group_by(subindicator_type)  %>% tally()
## # A tibble: 5 x 2
##   subindicator_type     n
##   <chr>             <int>
## 1 Estimate          18450
## 2 Lower             18450
## 3 Rank              18450
## 4 StdErr            18450
## 5 Upper             18450
df_corruption_est  <- df_corruption   %>% filter(subindicator_type == "Estimate")

df_corruption_est  %>% group_by(indicator)  %>% tally()
## # A tibble: 6 x 2
##   indicator                           n
##   <chr>                           <int>
## 1 Control of Corruption            3060
## 2 Government Effectiveness         3060
## 3 Political Stability No Violence  3090
## 4 Regulatory Quality               3060
## 5 Rule of Law                      3090
## 6 Voice and Accountability         3090
df_corruption_est  %>% 
  group_by(country_iso3, country_name)  %>% 
  tally()  %>% 
  DT::datatable(rownames = FALSE, fillContainer = FALSE, options = list(pageLength = 10))  %>% 
  widgetframe::frameWidget(width = "100%", height = "100%")
p  <- df_corruption_est  %>% 
  filter(country_iso3 %in% c("USA", "RUS"))  %>% 
  ggplot(aes(x = year, y = value, color = country_name)) +
  geom_point() + geom_line() +
  labs(title = "Worldwide Governance Indicators", 
       subtitle = "Source: http://info.worldbank.org/governance/wgi") +
  scale_x_continuous(breaks = seq(from = 2004, to = 2016, by = 4)) +
  facet_wrap(~indicator) +
  hrbrthemes::theme_ipsum() +
  hrbrthemes::scale_color_ipsum() 

ggplotly(p)  %>% widgetframe::frameWidget()
## Warning: `group_by_()` is deprecated as of dplyr 0.7.0.
## Please use `group_by()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
Elizabeth Stanny
Elizabeth Stanny
Professor of Business Administration

My research interests include climate change and political disclosures.