UNIVERSIDAD DE EL SALVADOR

FACULTAD DE CIENCIAS ECONOMICAS

ESCUELA DE ECONOMIA

TEMA: LABORATORIO I

MATERIA: METODOS PARA EL ANALISIS ECONOMICO

DOCENTE: CARLOS ADEMIR PÉREZ ALAS

INTEGRANTES:

APELLIDOS NOMBRES CARNET PARTICIPACIÓN
BOLAÑOS PEÑA ABEL ANTONIO BP18001 \(100\%\)
MOLINA MARTINEZ MONICA VALERIA MM18046 \(100\%\)
PANIAGUA MUÑOZ KARLA REGINA PM18112 \(100\%\)
VILLATORO ROMERO DIANA CAROLINA VR18003 \(100\%\)

CICLO: II-2022

FECHA: 19 DE OCTUBRE DE 2022

CIUDAD UNIVERSITARIA, SAN SALVADOR, EL SALVADOR, CENTROAMERICA

1. ¿Explique que es un API?

Las “API” son una Interfaz de Programación de Aplicaciones las cuales se estructuran para no reinventar la rueda, es decir que funcionan como la primera mano para el acceso a la información, y el conjunto de datos que tenemos disponibles para esas API, por ejemplo en vez de crear la misma base de datos podemos con el uso de las API tenerma de manera estructurada, se puede vincular infinidad de archivos, datos e imagenes en las cuales con una configuración se pueden obtener.

Las funciones de las API son para una comodidad en el ahorro de la información y se utilizan para las tareas de recopilación estadistica y remota y que se extienden por lo largo de la nube. (Fernández, Yubal, 2019)

2. A través del uso del software R, investigue sobre el acceso a los datos disponibles mediante API, para las instituciones: Banco Mundial (wbstats), Fondo Monetario Internacional (imfr), Comtrade de Naciones Unidas (comtradr). Y para Yahoo Finance (quantmod).

a. Prepare un documento en Rmardown Mostrando ejemplos de acceso a la información, para cada una de las API señaladas. Explicando en cada caso la sintaxis de los comandos empleados.

wbstats

wb_search()

Este busca los indicadores disponibles que podemos utilizar para cualquier estudio de investigación que se quiera realizar.

wb_search(pattern, fields=c(“indicator_id”, “indicator”, “indicator_desc”), extra=F, cache, ignore.case=T)

library(wbstats)
new_cache <- wb_cache(lang = "es")
wb_search(
  pattern = "indicators",
  fields = c("indicator_id", "indicator", "indicator_desc"),
  extra = F,
  new_cache,
  ignore.case = T
) -> df

library(kableExtra)

df %>% kable(caption = "INDICADORES",
             align = "c",
             digits = 2) %>% kable_material(html_font = "sans-serif")
INDICADORES
indicator_id indicator indicator_desc
IQ.SCI.PRDC Evaluación de la periodicidad y puntualidad de la capacidad estadística (escala 0 - 100) The periodicity and timeliness indicator assesses the availability and periodicity of key socioeconomic indicators. It measures the extent to which data are made accessible to users through transformation of source data into timely statistical outputs. The periodicity score is calculated as the weighted average of 10 underlying indicator scores. The final periodicity score contributes 1/3 of the overall Statistical Capacity Indicator score.
wb_search(
  pattern = "countries",
  fields = c("indicator_id", "indicator", "indicator_desc"),
  extra = F,
  new_cache,
  ignore.case = T
) -> df

df %>% head(10) %>% kable(caption = "PAISES",
                          align = "c",
                          digits = 2) %>% kable_material(html_font = "sans-serif")
PAISES
indicator_id indicator indicator_desc
DC.DAC.AUSL.CD Flujos de ayuda bilateral neta de donantes del Comité de Ayuda al Desarrollo (CAD), Australia (US$ a precios actuales) Net bilateral aid flows from DAC donors are the net disbursements of official development assistance (ODA) or official aid from the members of the Development Assistance Committee (DAC). Net disbursements are gross disbursements of grants and loans minus repayments of principal on earlier loans. ODA consists of loans made on concessional terms (with a grant element of at least 25 percent, calculated at a rate of discount of 10 percent) and grants made to promote economic development and welfare in countries and territories in the DAC list of ODA recipients. Official aid refers to aid flows from official donors to countries and territories in part II of the DAC list of recipients: more advanced countries of Central and Eastern Europe, the countries of the former Soviet Union, and certain advanced developing countries and territories. Official aid is provided under terms and conditions similar to those for ODA. Part II of the DAC List was abolished in 2005. The collection of data on official aid and other resource flows to Part II countries ended with 2004 data. DAC members are Australia, Austria, Belgium, Canada, Czech Republic, Denmark, Finland, France, Germany, Greece, Iceland, Ireland, Italy, Japan, Republic of Korea, Luxembourg, Netherlands, New Zealand, Norway, Poland, Portugal, Slovak Republic, Slovenia, Spain, Sweden, Switzerland, United Kingdom, United States, and European Union Institutions. Regional aggregates include data for economies not specified elsewhere. World and income group totals include aid not allocated by country or region. Data are in current U.S. dollars.
DC.DAC.AUTL.CD Flujos de ayuda bilateral neta de donantes del CAD, Austria (US$ a precios actuales) Net bilateral aid flows from DAC donors are the net disbursements of official development assistance (ODA) or official aid from the members of the Development Assistance Committee (DAC). Net disbursements are gross disbursements of grants and loans minus repayments of principal on earlier loans. ODA consists of loans made on concessional terms (with a grant element of at least 25 percent, calculated at a rate of discount of 10 percent) and grants made to promote economic development and welfare in countries and territories in the DAC list of ODA recipients. Official aid refers to aid flows from official donors to countries and territories in part II of the DAC list of recipients: more advanced countries of Central and Eastern Europe, the countries of the former Soviet Union, and certain advanced developing countries and territories. Official aid is provided under terms and conditions similar to those for ODA. Part II of the DAC List was abolished in 2005. The collection of data on official aid and other resource flows to Part II countries ended with 2004 data. DAC members are Australia, Austria, Belgium, Canada, Czech Republic, Denmark, Finland, France, Germany, Greece, Iceland, Ireland, Italy, Japan, Republic of Korea, Luxembourg, Netherlands, New Zealand, Norway, Poland, Portugal, Slovak Republic, Slovenia, Spain, Sweden, Switzerland, United Kingdom, United States, and European Union Institutions. Regional aggregates include data for economies not specified elsewhere. World and income group totals include aid not allocated by country or region. Data are in current U.S. dollars.
DC.DAC.BELL.CD Flujos de ayuda bilateral neta de donantes del CAD, Bélgica (US$ a precios actuales) Net bilateral aid flows from DAC donors are the net disbursements of official development assistance (ODA) or official aid from the members of the Development Assistance Committee (DAC). Net disbursements are gross disbursements of grants and loans minus repayments of principal on earlier loans. ODA consists of loans made on concessional terms (with a grant element of at least 25 percent, calculated at a rate of discount of 10 percent) and grants made to promote economic development and welfare in countries and territories in the DAC list of ODA recipients. Official aid refers to aid flows from official donors to countries and territories in part II of the DAC list of recipients: more advanced countries of Central and Eastern Europe, the countries of the former Soviet Union, and certain advanced developing countries and territories. Official aid is provided under terms and conditions similar to those for ODA. Part II of the DAC List was abolished in 2005. The collection of data on official aid and other resource flows to Part II countries ended with 2004 data. DAC members are Australia, Austria, Belgium, Canada, Czech Republic, Denmark, Finland, France, Germany, Greece, Iceland, Ireland, Italy, Japan, Republic of Korea, Luxembourg, Netherlands, New Zealand, Norway, Poland, Portugal, Slovak Republic, Slovenia, Spain, Sweden, Switzerland, United Kingdom, United States, and European Union Institutions. Regional aggregates include data for economies not specified elsewhere. World and income group totals include aid not allocated by country or region. Data are in current U.S. dollars.
DC.DAC.CANL.CD Flujos de ayuda bilateral neta de donantes del CAD, Canadá (US$ a precios actuales) Net bilateral aid flows from DAC donors are the net disbursements of official development assistance (ODA) or official aid from the members of the Development Assistance Committee (DAC). Net disbursements are gross disbursements of grants and loans minus repayments of principal on earlier loans. ODA consists of loans made on concessional terms (with a grant element of at least 25 percent, calculated at a rate of discount of 10 percent) and grants made to promote economic development and welfare in countries and territories in the DAC list of ODA recipients. Official aid refers to aid flows from official donors to countries and territories in part II of the DAC list of recipients: more advanced countries of Central and Eastern Europe, the countries of the former Soviet Union, and certain advanced developing countries and territories. Official aid is provided under terms and conditions similar to those for ODA. Part II of the DAC List was abolished in 2005. The collection of data on official aid and other resource flows to Part II countries ended with 2004 data. DAC members are Australia, Austria, Belgium, Canada, Czech Republic, Denmark, Finland, France, Germany, Greece, Iceland, Ireland, Italy, Japan, Republic of Korea, Luxembourg, Netherlands, New Zealand, Norway, Poland, Portugal, Slovak Republic, Slovenia, Spain, Sweden, Switzerland, United Kingdom, United States, and European Union Institutions. Regional aggregates include data for economies not specified elsewhere. World and income group totals include aid not allocated by country or region. Data are in current U.S. dollars.
DC.DAC.CECL.CD Flujos netos de ayuda bilateral de donantes del CAD, instituciones de la Unión Europea (US$ a precios actuales) Net bilateral aid flows from DAC donors are the net disbursements of official development assistance (ODA) or official aid from the members of the Development Assistance Committee (DAC). Net disbursements are gross disbursements of grants and loans minus repayments of principal on earlier loans. ODA consists of loans made on concessional terms (with a grant element of at least 25 percent, calculated at a rate of discount of 10 percent) and grants made to promote economic development and welfare in countries and territories in the DAC list of ODA recipients. Official aid refers to aid flows from official donors to countries and territories in part II of the DAC list of recipients: more advanced countries of Central and Eastern Europe, the countries of the former Soviet Union, and certain advanced developing countries and territories. Official aid is provided under terms and conditions similar to those for ODA. Part II of the DAC List was abolished in 2005. The collection of data on official aid and other resource flows to Part II countries ended with 2004 data. DAC members are Australia, Austria, Belgium, Canada, Czech Republic, Denmark, Finland, France, Germany, Greece, Iceland, Ireland, Italy, Japan, Republic of Korea, Luxembourg, Netherlands, New Zealand, Norway, Poland, Portugal, Slovak Republic, Slovenia, Spain, Sweden, Switzerland, United Kingdom, United States, and European Union Institutions. Regional aggregates include data for economies not specified elsewhere. World and income group totals include aid not allocated by country or region. Data are in current U.S. dollars.
DC.DAC.CHEL.CD Flujos de ayuda bilateral neta de donantes del Comité de Ayuda al Desarrollo (CAD), Suiza (US$ a precios actuales) Net bilateral aid flows from DAC donors are the net disbursements of official development assistance (ODA) or official aid from the members of the Development Assistance Committee (DAC). Net disbursements are gross disbursements of grants and loans minus repayments of principal on earlier loans. ODA consists of loans made on concessional terms (with a grant element of at least 25 percent, calculated at a rate of discount of 10 percent) and grants made to promote economic development and welfare in countries and territories in the DAC list of ODA recipients. Official aid refers to aid flows from official donors to countries and territories in part II of the DAC list of recipients: more advanced countries of Central and Eastern Europe, the countries of the former Soviet Union, and certain advanced developing countries and territories. Official aid is provided under terms and conditions similar to those for ODA. Part II of the DAC List was abolished in 2005. The collection of data on official aid and other resource flows to Part II countries ended with 2004 data. DAC members are Australia, Austria, Belgium, Canada, Czech Republic, Denmark, Finland, France, Germany, Greece, Iceland, Ireland, Italy, Japan, Republic of Korea, Luxembourg, Netherlands, New Zealand, Norway, Poland, Portugal, Slovak Republic, Slovenia, Spain, Sweden, Switzerland, United Kingdom, United States, and European Union Institutions. Regional aggregates include data for economies not specified elsewhere. World and income group totals include aid not allocated by country or region. Data are in current U.S. dollars.
DC.DAC.CZEL.CD Flujos de ayuda bilateral neta de donantes del Comité de Asistencia para el Desarrollo (CAD), República Checa (USD a precios actuales) Net bilateral aid flows from DAC donors are the net disbursements of official development assistance (ODA) or official aid from the members of the Development Assistance Committee (DAC). Net disbursements are gross disbursements of grants and loans minus repayments of principal on earlier loans. ODA consists of loans made on concessional terms (with a grant element of at least 25 percent, calculated at a rate of discount of 10 percent) and grants made to promote economic development and welfare in countries and territories in the DAC list of ODA recipients. Official aid refers to aid flows from official donors to countries and territories in part II of the DAC list of recipients: more advanced countries of Central and Eastern Europe, the countries of the former Soviet Union, and certain advanced developing countries and territories. Official aid is provided under terms and conditions similar to those for ODA. Part II of the DAC List was abolished in 2005. The collection of data on official aid and other resource flows to Part II countries ended with 2004 data. DAC members are Australia, Austria, Belgium, Canada, Czech Republic, Denmark, Finland, France, Germany, Greece, Iceland, Ireland, Italy, Japan, Republic of Korea, Luxembourg, Netherlands, New Zealand, Norway, Poland, Portugal, Slovak Republic, Slovenia, Spain, Sweden, Switzerland, United Kingdom, United States, and European Union Institutions. Regional aggregates include data for economies not specified elsewhere. World and income group totals include aid not allocated by country or region. Data are in current U.S. dollars.
DC.DAC.DEUL.CD Flujos de ayuda bilateral neta de donantes del CAD, Alemania (US$ a precios actuales) Net bilateral aid flows from DAC donors are the net disbursements of official development assistance (ODA) or official aid from the members of the Development Assistance Committee (DAC). Net disbursements are gross disbursements of grants and loans minus repayments of principal on earlier loans. ODA consists of loans made on concessional terms (with a grant element of at least 25 percent, calculated at a rate of discount of 10 percent) and grants made to promote economic development and welfare in countries and territories in the DAC list of ODA recipients. Official aid refers to aid flows from official donors to countries and territories in part II of the DAC list of recipients: more advanced countries of Central and Eastern Europe, the countries of the former Soviet Union, and certain advanced developing countries and territories. Official aid is provided under terms and conditions similar to those for ODA. Part II of the DAC List was abolished in 2005. The collection of data on official aid and other resource flows to Part II countries ended with 2004 data. DAC members are Australia, Austria, Belgium, Canada, Czech Republic, Denmark, Finland, France, Germany, Greece, Iceland, Ireland, Italy, Japan, Republic of Korea, Luxembourg, Netherlands, New Zealand, Norway, Poland, Portugal, Slovak Republic, Slovenia, Spain, Sweden, Switzerland, United Kingdom, United States, and European Union Institutions. Regional aggregates include data for economies not specified elsewhere. World and income group totals include aid not allocated by country or region. Data are in current U.S. dollars.
DC.DAC.DNKL.CD Flujos de ayuda bilateral neta de donantes del CAD, Dinamarca (US$ a precios actuales) Net bilateral aid flows from DAC donors are the net disbursements of official development assistance (ODA) or official aid from the members of the Development Assistance Committee (DAC). Net disbursements are gross disbursements of grants and loans minus repayments of principal on earlier loans. ODA consists of loans made on concessional terms (with a grant element of at least 25 percent, calculated at a rate of discount of 10 percent) and grants made to promote economic development and welfare in countries and territories in the DAC list of ODA recipients. Official aid refers to aid flows from official donors to countries and territories in part II of the DAC list of recipients: more advanced countries of Central and Eastern Europe, the countries of the former Soviet Union, and certain advanced developing countries and territories. Official aid is provided under terms and conditions similar to those for ODA. Part II of the DAC List was abolished in 2005. The collection of data on official aid and other resource flows to Part II countries ended with 2004 data. DAC members are Australia, Austria, Belgium, Canada, Czech Republic, Denmark, Finland, France, Germany, Greece, Iceland, Ireland, Italy, Japan, Republic of Korea, Luxembourg, Netherlands, New Zealand, Norway, Poland, Portugal, Slovak Republic, Slovenia, Spain, Sweden, Switzerland, United Kingdom, United States, and European Union Institutions. Regional aggregates include data for economies not specified elsewhere. World and income group totals include aid not allocated by country or region. Data are in current U.S. dollars.
DC.DAC.ESPL.CD Flujos de ayuda bilateral neta de donantes del CAD, España (US$ a precios actuales) Net bilateral aid flows from DAC donors are the net disbursements of official development assistance (ODA) or official aid from the members of the Development Assistance Committee (DAC). Net disbursements are gross disbursements of grants and loans minus repayments of principal on earlier loans. ODA consists of loans made on concessional terms (with a grant element of at least 25 percent, calculated at a rate of discount of 10 percent) and grants made to promote economic development and welfare in countries and territories in the DAC list of ODA recipients. Official aid refers to aid flows from official donors to countries and territories in part II of the DAC list of recipients: more advanced countries of Central and Eastern Europe, the countries of the former Soviet Union, and certain advanced developing countries and territories. Official aid is provided under terms and conditions similar to those for ODA. Part II of the DAC List was abolished in 2005. The collection of data on official aid and other resource flows to Part II countries ended with 2004 data. DAC members are Australia, Austria, Belgium, Canada, Czech Republic, Denmark, Finland, France, Germany, Greece, Iceland, Ireland, Italy, Japan, Republic of Korea, Luxembourg, Netherlands, New Zealand, Norway, Poland, Portugal, Slovak Republic, Slovenia, Spain, Sweden, Switzerland, United Kingdom, United States, and European Union Institutions. Regional aggregates include data for economies not specified elsewhere. World and income group totals include aid not allocated by country or region. Data are in current U.S. dollars.

Tambien existen otros indicadores como “poverty | unemployment | employment | education | ‘Food and Agriculture Organization’” se pueden buscar por el comando:

wb_indicators(lang)

wb_indicators(lang = "es") %>% head(10) %>% kable(caption = "PAISES",
                                                  align = "c",
                                                  digits = 2) %>% kable_material(html_font = "sans-serif")
PAISES
indicator_id indicator unit indicator_desc source_org topics source_id source
1.0.HCount.1.90usd Tasa de Incidencia de la Pobreza ($1.90 al día) NA Tasa de Incidencia de la Pobreza mide la proporción de la población con ingreso per cápita diario (en PPA de 2011) por debajo de la línea de pobreza. Tabulaciones del LAC Equity Lab con datos de SEDLAC (CEDLAS y el Banco Mundial) 11 , Pobreza 37 NA
1.0.HCount.2.5usd Tasa de Incidencia de la Pobreza ($2.50 al día) NA Tasa de Incidencia de la Pobreza mide la proporción de la población con ingreso per cápita diario (en PPA de 2005) por debajo de la línea de pobreza. Tabulaciones del LAC Equity Lab con datos de SEDLAC (CEDLAS y el Banco Mundial) 11 , Pobreza 37 NA
1.0.HCount.Mid10to50 Tasa de Incidencia de la Clase Media ($10-50 al día) NA Tasa de Incidencia de la Pobreza mide la proporción de la población con ingreso per cápita diario (en PPA de 2005) por debajo de la línea de pobreza. Tabulaciones del LAC Equity Lab con datos de SEDLAC (CEDLAS y el Banco Mundial) 11 , Pobreza 37 NA
1.0.HCount.Ofcl Tasa Oficial de la Pobreza Moderada-Nacional NA Tasa de Incidencia de la Pobreza mide la proporción de la población con ingreso per cápita diario por debajo de la línea de pobreza desarrollada por cada país. Tabulaciones del LAC Equity Lab de los datos de las Oficinas Nacionales de Estadística 11 , Pobreza 37 NA
1.0.HCount.Poor4uds Tasa de Incidencia de la Pobreza ($4 al día) NA Tasa de Incidencia de la Pobreza mide la proporción de la población con ingreso per cápita diario (en PPA de 2005) por debajo de la línea de pobreza. Tabulaciones del LAC Equity Lab con datos de SEDLAC (CEDLAS y el Banco Mundial) 11 , Pobreza 37 NA
1.0.HCount.Vul4to10 Tasa de incidencia de población Vulnerable ($4-10 al día) NA Tasa de Incidencia de la Pobreza mide la proporción de la población con ingreso per cápita diario (en PPA de 2005) por debajo de la línea de pobreza. Tabulaciones del LAC Equity Lab con datos de SEDLAC (CEDLAS y el Banco Mundial) 11 , Pobreza 37 NA
1.0.PGap.1.90usd Brecha de Pobreza ($1.90 al día) NA La Brecha de Pobreza captura el déficit del ingreso o consumo promedio agregado relativo a la línea de pobreza a través de toda la población. Mide el total de recursos necesarios para traer a todos os pobres al nivel de la línea de pobreza (promediado sobre la población total). Tabulaciones del LAC Equity Lab con datos de SEDLAC (CEDLAS y el Banco Mundial) 11 , Pobreza 37 NA
1.0.PGap.2.5usd Brecha de Pobreza ($2.50 al día) NA La Brecha de Pobreza captura el déficit del ingreso o consumo promedio agregado relativo a la línea de pobreza a través de toda la población. Mide el total de recursos necesarios para traer a todos os pobres al nivel de la línea de pobreza (promediado sobre la población total). Tabulaciones del LAC Equity Lab con datos de SEDLAC (CEDLAS y el Banco Mundial) 11 , Pobreza 37 NA
1.0.PGap.Poor4uds Brecha de Pobreza ($4 al día) NA La Brecha de Pobreza captura el déficit del ingreso o consumo promedio agregado relativo a la línea de pobreza a través de toda la población. Mide el total de recursos necesarios para traer a todos os pobres al nivel de la línea de pobreza (promediado sobre la población total). Tabulaciones del LAC Equity Lab con datos de SEDLAC (CEDLAS y el Banco Mundial) 11 , Pobreza 37 NA
1.0.PSev.1.90usd Severidad de la Pobreza ($1.90 al día) NA El índice de severidad de la pobreza combina información tanto de pobreza como de desigualdad entre los pobres, al promediar los cuadrados de las brechas de pobreza relativas a la línea de pobreza Tabulaciones del LAC Equity Lab con datos de SEDLAC (CEDLAS y el Banco Mundial) 11 , Pobreza 37 NA

wb_data

Este ayuda para obtener ya una base de datos y utilizarla para el manejo de información

wb_data(indicator=“indicador”,country=“pais disponible”,start_date=“fecha inicial”, end_date=“fecha final”)

wb_data(
  indicator = "SP.POP.GROW",
  country = "SLV",
  start_date = 2010,
  end_date = 2022
) -> SLV

SLV %>% kable(caption = "CRECIMIENTO POBLACIONAL",
              align = "c",
              digits = 2) %>% kable_material(html_font = "sans-serif") %>% add_footnote(label =
                                                                                          "Elaboración propia con base datos del Banco Mundial",
                                                                                        notation = "symbol")
CRECIMIENTO POBLACIONAL
iso2c iso3c country date SP.POP.GROW unit obs_status footnote last_updated
SV SLV El Salvador 2010 0.42 NA NA NA 2022-09-16
SV SLV El Salvador 2011 0.43 NA NA NA 2022-09-16
SV SLV El Salvador 2012 0.44 NA NA NA 2022-09-16
SV SLV El Salvador 2013 0.45 NA NA NA 2022-09-16
SV SLV El Salvador 2014 0.46 NA NA NA 2022-09-16
SV SLV El Salvador 2015 0.48 NA NA NA 2022-09-16
SV SLV El Salvador 2016 0.49 NA NA NA 2022-09-16
SV SLV El Salvador 2017 0.50 NA NA NA 2022-09-16
SV SLV El Salvador 2018 0.51 NA NA NA 2022-09-16
SV SLV El Salvador 2019 0.51 NA NA NA 2022-09-16
SV SLV El Salvador 2020 0.50 NA NA NA 2022-09-16
SV SLV El Salvador 2021 0.50 NA NA NA 2022-09-16
* Elaboración propia con base datos del Banco Mundial
Ejemplo de uso de la base de datos
wb_data(
  indicator = "SP.POP.TOTL",
  country = "SLV",
  start_date = 2010,
  end_date = 2022
) -> SLV

SLV %>% kable(caption = "POBLACIÓN TOTAL",
              align = "c",
              digits = 2) %>% kable_material(html_font = "sans-serif") %>% add_footnote(label =
                                                                                          "Elaboración propia con base datos del Banco Mundial",
                                                                                        notation = "symbol")
POBLACIÓN TOTAL
iso2c iso3c country date SP.POP.TOTL unit obs_status footnote last_updated
SV SLV El Salvador 2010 6183877 NA NA NA 2022-09-16
SV SLV El Salvador 2011 6210567 NA NA NA 2022-09-16
SV SLV El Salvador 2012 6237922 NA NA NA 2022-09-16
SV SLV El Salvador 2013 6266076 NA NA NA 2022-09-16
SV SLV El Salvador 2014 6295124 NA NA NA 2022-09-16
SV SLV El Salvador 2015 6325121 NA NA NA 2022-09-16
SV SLV El Salvador 2016 6356137 NA NA NA 2022-09-16
SV SLV El Salvador 2017 6388124 NA NA NA 2022-09-16
SV SLV El Salvador 2018 6420740 NA NA NA 2022-09-16
SV SLV El Salvador 2019 6453550 NA NA NA 2022-09-16
SV SLV El Salvador 2020 6486201 NA NA NA 2022-09-16
SV SLV El Salvador 2021 6518500 NA NA NA 2022-09-16
* Elaboración propia con base datos del Banco Mundial

imfr

imf_ids()

Muestra las bases de datos con su ID y descripción disponible

library(imfr)

bases <- imf_ids()
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |==========================================================            |  83%
  |                                                                            
  |======================================================================| 100%
bases %>% head(10) %>% kable(caption = "IDS DE BASES DE DATOS",
                             align = "c",
                             digits = 2) %>% kable_material(html_font = "sans-serif")
IDS DE BASES DE DATOS
database_id description
BOP_2017M06 Balance of Payments (BOP), 2017 M06
BOP_2020M3 Balance of Payments (BOP), 2020 M03
BOP_2017M11 Balance of Payments (BOP), 2017 M11
DOT_2020Q1 Direction of Trade Statistics (DOTS), 2020 Q1
GFSMAB2016 Government Finance Statistics Yearbook (GFSY 2016), Main Aggregates and Balances
BOP_2019M12 Balance of Payments (BOP), 2019 M12
GFSYFALCS2014 Government Finance Statistics Yearbook (GFSY 2014), Financial Assets and Liabilities by Counterpart Sector
GFSE2016 Government Finance Statistics Yearbook (GFSY 2016), Expense
FM201510 Fiscal Monitor (FM) October 2015
GFSIBS2016 Government Finance Statistics Yearbook (GFSY 2016), Integrated Balance Sheet (Stock Positions and Flows in Assets and Liabilities)

imf_codelist

Explora la lista de codigos en especifico de un indicador de datos

imf_codelist(database_id=“ID de base de datos”)

ED <- imf_codelist(database_id = "ED")
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==============                                                        |  20%
  |                                                                            
  |=====================================                                 |  53%
  |                                                                            
  |======================================================================| 100%
ED %>% kable(caption = "LISTA DE CODIGOS",
             align = "c",
             digits = 2) %>% kable_material(html_font = "sans-serif") %>% kable_minimal()
LISTA DE CODIGOS
codelist description
CL_UNIT_MULT Scale
CL_FREQ Frequency
CL_AREA_ED Geographical Areas
CL_INDICATOR_ED Indicator
CL_TIME_FORMAT Time format
Ejemplo de uso de la base de datos
imf_codes(codelist = "CL_INDICATOR_ED")
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
##           codes                  description
## 1   total_theil Export Diversification Index
## 2 between_theil             Extensive Margin
## 3  within_theil             Intensive Margin
SV <-
  imf_data(
    database_id = "ED",
    indicator = c("total_theil", "between_theil", "within_theil"),
    country = "SV",
    freq = 'A',
    start = 2010
  )
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
SV %>%  kable(caption = "DIVERSIFICACIÓN DE EXPORTACIONES (ANUAL)",
              align = "c",
              digits = 2) %>% kable_material(html_font = "sans-serif") %>% add_footnote(label =
                                                                                          "Elaboración propia con base datos del Fondo Monetario Internacional",
                                                                                        notation = "symbol")
DIVERSIFICACIÓN DE EXPORTACIONES (ANUAL)
iso2c year total_theil between_theil within_theil
SV 2010 3.13 -0.04 3.17
SV 2011 3.04 -0.04 3.08
SV 2012 3.01 -0.04 3.05
SV 2013 3.00 -0.03 3.02
SV 2014 3.08 -0.01 3.08
* Elaboración propia con base datos del Fondo Monetario Internacional

comtradr

Ejemplo de uso de la base de datos

ct_search

Este comando funciona para encontrar las bases de datos nombradas por paises.

ct_search(reporters=“Pais”,partners=c(“Paises socios”),trade_direction=“exports | imports | all”,start_date=“año inicial”,end_date=“año final”)

library(comtradr)
library(dplyr)

socios <- c("Guatemala", "Costa Rica", "Honduras", "Nicaragua")

ct_search(
  reporters = "El Salvador",
  partners = socios,
  trade_direction = "all",
  start_date = 2019,
  end_date = 2020
) %>% select("year", "trade_flow", "reporter", "partner", "trade_value_usd") %>% kable(caption = "EXPORTACIONES E IMPORTACIONES ANUALES DE LOS SOCIOS COMERCIALES DE EL SALVADOR 2019-2020",
                                                                                       align = "c",
                                                                                       digits = 2) %>% kable_material(html_font = "sans-serif") %>% add_footnote(label =
                                                                                                                                                                   "Elaboración propia con base datos del Comtrade de Nacionales Unidas",
                                                                                                                                                                 notation = "symbol")
EXPORTACIONES E IMPORTACIONES ANUALES DE LOS SOCIOS COMERCIALES DE EL SALVADOR 2019-2020
year trade_flow reporter partner trade_value_usd
2019 Import El Salvador Costa Rica 306135892
2019 Export El Salvador Costa Rica 263120769
2019 Import El Salvador Guatemala 1266585767
2019 Export El Salvador Guatemala 940258686
2019 Import El Salvador Honduras 809174690
2019 Export El Salvador Honduras 938654975
2019 Import El Salvador Nicaragua 365769340
2019 Export El Salvador Nicaragua 393041332
2020 Import El Salvador Costa Rica 302681877
2020 Export El Salvador Costa Rica 232750835
2020 Import El Salvador Guatemala 1212103283
2020 Export El Salvador Guatemala 848460302
2020 Import El Salvador Honduras 667101113
2020 Export El Salvador Honduras 776704606
2020 Import El Salvador Nicaragua 403234337
2020 Export El Salvador Nicaragua 364408729
* Elaboración propia con base datos del Comtrade de Nacionales Unidas

ct_country_lookup()

Sirve para consultar las referencias de alguna variable, sea pais y/o reportes de los lugares que existen para el comercio internacional

ct_country_lookup(“pais | indicador de socio”)

ct_country_lookup("China","partner")
## [1] "China"                "China, Hong Kong SAR" "China, Macao SAR"
ct_search(
  reporters = "El Salvador",
  partners = "China, Hong Kong SAR",
  trade_direction = "all",
  start_date = 2019,
  end_date = 2020
) %>% select("year", "trade_flow", "reporter", "partner", "trade_value_usd") %>% kable(caption = "EXPORTACIONES E IMPORTACIONES ANUALES DE HONG KONG A EL SALVADOR 2019-2020",
                                                                                       align = "c",
                                                                                       digits = 2) %>% kable_material(html_font = "sans-serif") %>% add_footnote(label =
                                                                                                                                                                   "Elaboración propia con base datos del Comtrade de Nacionales Unidas",
                                                                                                                                                                 notation = "symbol")
EXPORTACIONES E IMPORTACIONES ANUALES DE HONG KONG A EL SALVADOR 2019-2020
year trade_flow reporter partner trade_value_usd
2019 Import El Salvador China, Hong Kong SAR 8894552
2019 Export El Salvador China, Hong Kong SAR 5676675
2020 Import El Salvador China, Hong Kong SAR 11641135
2020 Export El Salvador China, Hong Kong SAR 3068503
* Elaboración propia con base datos del Comtrade de Nacionales Unidas

ct_commodity_lookup()

Este comando sirve para vuscar los codigos de aquellos bienes que interesan

ct_commodity_lookup("onion")
## $onion
## [1] "0703 - Onions, shallots, garlic, leeks and other alliaceous vegetables; fresh or chilled"                                                                                             
## [2] "070310 - Vegetables, alliaceous; onions and shallots, fresh or chilled"                                                                                                               
## [3] "071110 - Vegetables; onions, provisionally preserved by sulphur dioxide gas, but unsuitable in that state for immediate consumption"                                                  
## [4] "071220 - Vegetables; onions, whole, cut, sliced, broken or in powder but not further prepared, dried"                                                                                 
## [5] "200120 - Vegetable preparations; onions, prepared or preserved by vinegar or acetic acid"                                                                                             
## [6] "200190 - Vegetable preparations; vegetables, fruit, nuts and other edible parts of plants, prepared or preserved by vinegar or acetic acid (excluding cucumbers, gherkins and onions)"
onion_codes<-ct_commodity_lookup("onion",return_code = T, return_char = T)
ct_search(
  reporters = "El Salvador",
  partners = socios,
  trade_direction = "all",
  start_date = 2019,
  end_date = 2020,
  commod_codes = "0703"
) %>% select("year", "trade_flow", "reporter", "partner", "trade_value_usd") %>% kable(caption = "EXPORTACIONES E IMPORTACIONES ANUALES DE CEBOLLAS DE LOS SOCIOS COMERCIALES A EL SALVADOR 2019-2020",
                                                                                       align = "c",
                                                                                       digits = 2) %>% kable_material(html_font = "sans-serif") %>% add_footnote(label =
                                                                                                                                                                   "Elaboración propia con base datos del Comtrade de Nacionales Unidas",
                                                                                                                                                                 notation = "symbol")
EXPORTACIONES E IMPORTACIONES ANUALES DE CEBOLLAS DE LOS SOCIOS COMERCIALES A EL SALVADOR 2019-2020
year trade_flow reporter partner trade_value_usd
2019 Import El Salvador Costa Rica 87313
2019 Import El Salvador Guatemala 5229837
2019 Import El Salvador Honduras 156106
2019 Import El Salvador Nicaragua 198567
2020 Import El Salvador Guatemala 5024150
2020 Export El Salvador Guatemala 7000
2020 Import El Salvador Honduras 242204
2020 Import El Salvador Nicaragua 27006
* Elaboración propia con base datos del Comtrade de Nacionales Unidas
dataframe <- ct_search(reporters = "China", 
                partners = c("Rep. of Korea", "USA", "Mexico"), 
                trade_direction = "exports")
library(ggplot2)

dataframe <- ct_use_pretty_cols(dataframe)

ggplot(dataframe, aes(Year, `Trade Value usd`, color = factor(`Partner Country`), 
               shape = factor(`Partner Country`))) +
  geom_point(size = 2) +
  geom_line(size = 1) +
  scale_x_continuous(limits = c(min(dataframe$Year), max(dataframe$Year)), 
                     breaks = seq.int(min(dataframe$Year), max(dataframe$Year), 2)) +
  scale_color_manual(values = c("black", "blue", "purple"), 
                     name = "Destination\nCountry") +
  scale_shape_discrete(name = "Destination\nCountry") +
  labs(title = "Valor total (USD) de las exportaciones chinas, por año") +
  theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1))

quantmod

getSymbols(“Base de datos”, scr=“google | yahoo | FRED”, from=“fecha inicial formato yyyy-mm-dd”, to=“fecha final formato yyyy-mm-dd”, periodicity=“daily, monthly, yearly”)

Este comando es el central y nos permite a ejecutar las series de datos necesarias sea de Google, Yahoo, FRED, etc.

library(quantmod)

getSymbols(
  "^DJI",
  src = "yahoo",
  from = "2010-01-01",
  to = "2020-12-30",
  periodicity = "monthly"
)
## [1] "^DJI"
DJI %>% head(10) %>% kable(caption = "USO DE QUANTMOD",
                           align = "c",
                           digits = 2) %>% kable_material(html_font = "sans-serif") %>% kable_styling(bootstrap_options = c("striped", "hover"))
USO DE QUANTMOD
DJI.Open DJI.High DJI.Low DJI.Close DJI.Volume DJI.Adjusted
10430.69 10729.89 10043.75 10067.33 4424700000 10067.33
10068.99 10438.55 9835.09 10325.26 4279660000 10325.26
10326.10 10955.48 10326.10 10856.63 4388530000 10856.63
10857.31 11258.01 10844.09 11008.61 4237550000 11008.61
11009.60 11177.67 9774.48 10136.63 5605690000 10136.63
10133.94 10594.16 9753.84 9774.02 4941680000 9774.02
9773.27 10584.99 9614.32 10465.94 4243320000 10465.94
10468.82 10719.94 9936.62 10014.72 4117550000 10014.72
10016.01 10948.88 10016.01 10788.05 3764970000 10788.05
10789.72 11247.60 10711.12 11118.49 3787250000 11118.49

chartSeries(Serie,TA=NULL)

Este comando nos permite graficar las series de datos ejecutadas, y el valor de TA es el valor del volumen en este caso NULL significa que no lo mostrara.

chartSeries(DJI,TA=NULL)

chartSeries(DJI,subset = "last 12 months")

Ejemplo de uso de la base de datos

En este ejemplo usaremos los datos de Yahoo Finance en la serie de datos BTC-USD

library(quantmod)

getSymbols(
  "BTC-USD",
  src = "yahoo",
  from = "2015-01-01",
  to = "2020-12-30",
  periodicity = "monthly"
)
## [1] "BTC-USD"
`BTC-USD` %>% head(10) %>% kable(caption = "BTC-USD 2015-2020",
                           align = "c",
                           digits = 2) %>% kable_material(html_font = "sans-serif") %>% kable_styling(bootstrap_options = c("striped", "hover"))
BTC-USD 2015-2020
BTC-USD.Open BTC-USD.High BTC-USD.Low BTC-USD.Close BTC-USD.Volume BTC-USD.Adjusted
320.435 320.435 171.510 217.464 1098811912 217.464
216.867 265.611 212.015 254.263 711518700 254.263
254.283 300.044 236.515 244.224 959098300 244.224
244.223 261.798 214.874 236.145 672338700 236.145
235.939 247.804 228.573 230.190 568122600 230.190
230.233 267.867 221.296 263.072 629780200 263.072
263.345 314.394 253.505 284.650 999892200 284.650
284.686 285.715 199.567 230.056 905192300 230.056
230.256 259.182 225.117 236.060 603623900 236.060
236.004 334.169 235.616 314.166 953279500 314.166
chartSeries(`BTC-USD`)

b. Elabore un inventario de las series disponibles en cada API

i. i. presente mediante una tabla, para cada API las series disponibles y una breve descripción de la misma.

Librería

Series más utilizadas

Descripción

Países disponibles

wbstats

SP.POP.TOTL, NY.GDP.MKTP

Estas series la primera nos permite medir los datos poblacionales de todos los países y el segundo nos permite y la segunda nos mide el PIB a precios de mercado de todos los países.

Todos los países

imfr

APDREO, BOP, CPI, DOT, IFS

Estas series son las más utilizadas la primera que se utiliza para Asia y el pacífico, la segunda es la balanza de pagos y todas sus cuentas, la tercera son los índices de precio al consumidor, la cuarta son las direcciones de estadística comercial donde tenemos las exportaciones e importaciones y por ultimo las estadísticas financieras internacionales.

Todos los países

comtradr

reporters

En esta serie de datos tenemos todas las transacciones del comercio internacional, exportaciones e importaciones, también separadas por bien, socios comerciales y fechas

Todos los países

quantmod

^GSPC, ^DJI, ^IXIC, BTC-USD

Estas series son las más utilizadas la primera vemos los índices de Standard & Poor's 500, en la segunda las medias industriales de Dow Jones, el tercero la composición NASDAQ, y el ultimo el valor del Bitcoin en relación al dólar

Estados Unidos