Códigos del módulo

En este apartado podéis encontrar los códigos del módulo 4 Indicadores Políticos.

Democracia

Para realizar las actividades de este apartado, cargad los siguientes paquetes:

library(tidyverse)
library(readxl)
library(foreign)
library(countrycode)
devtools::install_github("vdeminstitute/vdemdata")
library(vdemdata)

1. Democracia minimalista

1.2 Medidas dicotómicas

tibble(Country = c("Francia", "Sudáfrica", "Unión Soviética", "Arabia Saudí"),
       Year = c(1985, 1985, 1985, 1985),
       Contestation = c(1, 1, 0, 0),
       Inclusion = c(1, 0, 1, 0),
       Democracy = Contestation & Inclusion)%>%
  View()

1.3 Medidas continuas

Polity, DD y DCD

#DD dataset
dd <- as_tibble(read.dta("https://uofi.box.com/shared/static/bba3968d7c3397c024ec.dta"))

#DCD dataset
dcd <- read_csv("https://sites.google.com/site/mkmtwo/democracy-v3.0.csv?attredirects=0")

#Polity V dataset
download.file("http://www.systemicpeace.org/inscr/p5v2018.xls", "p5v2018.xls")
polity <- read_xls("p5v2018.xls")

2. Democracia sustantiva

tibble(N = c("A","B", "C", "D"),
              Contestation = c(10, 1, 10, 7),
              Inclusion = c(10, 9, 3, 6),
              Freedoms = c(5, 8, 4, 6),
              Direct = c(4, 5, 8, 7),
              Equality = c(4, 10, 8, 7),
              Democracy = c(Contestation + Inclusion + Freedoms + Direct + Equality)/5)%>%
  View()

2.2 Freedom House

fiw <- read_xlsx("All_data_FIW_2013-2021.xlsx", sheet = 2, skip = 1)

2.3 Varieties of democracy

devtools::install_github("vdeminstitute/vdemdata") 
library(vdemdata)

plot_indicator("v2x_libdem", "Bolivia", min_year = 1975, max_year = 2020)

Gobernanza

En este apartado necesitaremos los siguientes paquetes:

library(tidyverse)
library(devtools)
install_github("ropengov/rqog") 
library(rqog)

1. Buena gobernanza

1.3 European Quality of Government Index

library(devtools)
install_github("ropengov/rqog")
library(rqog)

qog_basic <- read_qog(which_data = "basic") %>%
  tibble()

Preferencias políticas

En este apartado necesitaremos los siguientes paquetes:

library(tidyverse)
library(manifestoR)

2. Partidos políticos

2.2 Análisis de programas electorales

Comparative Party Manifesto (CPM)

library(manifestoR)

mp_setapikey("manifesto_apikey.txt") #busca el perfil de usuario
cpm <- mp_maindataset()
mp_describe_code("107")

cpm %>%
  mutate(edate = as.Date(edate, "%d/%m/%Y")) %>%
  filter(countryname == "Sweden") %>% filter(edate == last(edate)) %>%
  arrange(desc(date)) %>%
  select(Partit = partyname, Data = edate, Internacionalisme = per107)

2.3 Encuestas a expertos

Global Party Survey

tibble(x) %>%
  filter(Country %in% c("Angola", "Chad", "El Salvador", "United Kingdom")) %>%
  mutate(Country = countrycode(ISO, "iso3c", "cldr.name.ca")) %>%
  count(Country, Experts)%>%
  View()
Previous