Anatomía de la inflación

Author

Francisco Cambronero

Paquetes usados

Importar y limpiar los datos

TPM

tpm_anual %>% xtable(caption = "Tasa de Política Monetaria (TPM) Anual", digits = c(0,0,2)) %>% print(type = "latex", include.rownames = FALSE)
% latex table generated in R 4.4.1 by xtable 1.8-4 package
% Tue Nov 12 18:29:32 2024
\begin{table}[ht]
\centering
\begin{tabular}{rr}
  \hline
Año & TPM \\ 
  \hline
2009 & 10.00 \\ 
  2010 & 9.00 \\ 
  2011 & 6.50 \\ 
  2012 & 5.00 \\ 
  2013 & 5.00 \\ 
  2014 & 3.75 \\ 
  2015 & 5.25 \\ 
  2016 & 2.25 \\ 
  2017 & 1.75 \\ 
  2018 & 4.75 \\ 
  2019 & 5.25 \\ 
  2020 & 2.75 \\ 
  2021 & 0.75 \\ 
  2022 & 1.25 \\ 
  2023 & 9.00 \\ 
  2024 & 6.00 \\ 
   \hline
\end{tabular}
\caption{Tasa de Política Monetaria (TPM) Anual} 
\end{table}
# Crear el gráfico con ggplot2
(tpm_anual_plot <- tpm_anual %>% ggplot(aes(x = Año, y = TPM)) +
  geom_line() +
  labs(title = "Tasa de Política Monetaria (TPM) Anual",
       x = "Año",
       y = "TPM (%)") +
    theme_cowplot()
  # theme_minimal()
)

pdf("tpm_anual.pdf", width = 5, height = 3)
tpm_anual_plot
dev.off()
png 
  2 
# GRAFICO DE LINEA
# Crear el gráfico de líneas
tpm_long_month <- tpm_long %>% filter(day(date) == 1 & year(date) > 2013)

(tpm_por_anio <- tpm_long_month %>% ggplot(aes(x = month(date), y = tpm, color = year)) +
  geom_line(size = 1) +
  labs(x = "Mes", y = "TPM (%)", color = "Año", caption = "Fuente: Elaboración propia con datos de BCCR")+
  # scale_x_date(date_breaks = "2 year", date_labels = "%Y") +
  scale_x_discrete(limits=1:12) +
    scale_y_discrete(limits = seq(1,9,.5))+
  scale_color_viridis(discrete = TRUE, option = "H") +
  scale_fill_viridis(discrete = TRUE) +
  theme(legend.position = "right")
)

pdf("tpm_por_anio.pdf", width = 8, height = 5)
tpm_por_anio
dev.off()
png 
  2 
# ggplot(aes(x = Variable, y = Rendimiento,  fill = Variable)) +
(boxplot_tpm <- tpm_long_month %>% ggplot(aes(x = year, y = tpm, fill = year)) +
geom_boxplot(color = "darkgrey", show.legend = F)+#(outlier.shape = NA) +  
  labs(x = "Año", y = "TPM (%)", color = "Año", caption = "Fuente: Elaboración propia con datos de BCCR")+
  # labs(x = NULL, y = "Rendimiento", caption = "Fuente: Elaboración propia con datos de SUPEN.")+
  scale_x_discrete() +
  scale_y_discrete(limits = seq(1,9,.5))+
  theme(plot.caption = element_text(hjust = 0)) +
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) +
  scale_color_viridis(discrete = TRUE, option = "H") +
  scale_fill_viridis(discrete = TRUE, option = "H") +
  theme(legend.position = "right")
)

# d <- 12
# # start = c(1961, 1), frequency = 12
# data <- tpm_long_month[,3] %>% ts(frequency = d, start = c(2014,1)) #%>% diff(4)
# data %>% pacf()
# data %>% acf()
# 
# # data <- data %>% diff(4)
# # data %>% pacf()
# # data %>% acf()
# 
# data %>% auto.arima() %>% plot()
# data %>% ts.plot()
# data %>% auto.arima(d = 4) %>% forecast() %>% plot
# 
# (arima <- data %>% auto.arima(seasonal = T)) #%>% forecast() %>% plot())
# 
# arima %>% plot()
# 
# pdf("inverse_ar_roots.pdf", width = 10)
# (arima %>% plot())
# dev.off()
# 
# arima %>% forecast() %>% plot()
# 
# pdf("arima.pdf", width = 10)
# (arima %>% forecast() %>% plot())
# dev.off()
# 
# 
# 
# boxplot(
#   data[] ~ cycle(data),
#   xlab = "Mes",
#   ylab = "TPM (%)",
#   col = turbo(d))

Inflacion

datosinflacion <- read_csv("datosinflacion.csv", 
    col_types = cols(`Subject Descriptor` = col_skip(), 
        Units = col_skip(), Scale = col_skip(), 
        `Country/Series-specific Notes` = col_skip()), 
                  locale = locale(encoding = "ISO-8859-1"))

datosinflacion <- datosinflacion %>% select(-c(`Estimates Start After`))
datosinflacion <- datosinflacion %>% t()
colnames(datosinflacion) <- datosinflacion[1,]
datosinflacion <- datosinflacion[-1,]
# datosinflacion <- datosinflacion %>% as.data.frame.numeric(check.names = T)
# Convertir la matriz en un data frame
datosinflacion <- as.data.frame(datosinflacion)

# Si los años no están incluidos como una columna y deseas añadirlos desde el nombre de las filas
datosinflacion$"Año" <- rownames(datosinflacion)

# Cambiar el orden de las columnas si es necesario para que 'Year' sea la primera columna
datosinflacion <- datosinflacion[, c(ncol(datosinflacion), 1:(ncol(datosinflacion)-1))]

datosinflacion %>% 
  select(c("Año","Costa Rica","Chile","Colombia","Mexico")) %>% 
  xtable(caption = "Inflación Anual") %>% print(type = "latex", include.rownames = FALSE)
% latex table generated in R 4.4.1 by xtable 1.8-4 package
% Tue Nov 12 18:29:34 2024
\begin{table}[ht]
\centering
\begin{tabular}{lllll}
  \hline
Año & Costa Rica & Chile & Colombia & Mexico \\ 
  \hline
2014 &  4.519 &  4.714 &  2.905 &  4.019 \\ 
  2015 &  0.802 &  4.349 &  4.991 &  2.719 \\ 
  2016 & -0.017 &  3.789 &  7.507 &  2.820 \\ 
  2017 &  1.626 &  2.183 &  4.312 &  6.042 \\ 
  2018 &  2.221 &  2.317 &  3.241 &  4.898 \\ 
  2019 &  2.096 &  2.249 &  3.524 &  3.635 \\ 
  2020 &  0.725 &  3.043 &  2.525 &  3.398 \\ 
  2021 &  1.727 &  4.524 &  3.505 &  5.693 \\ 
  2022 &  8.275 & 11.645 & 10.183 &  7.898 \\ 
  2023 &  0.525 &  7.583 & 11.729 &  5.525 \\ 
  2024 &  0.286 &  3.180 &  6.390 &  4.020 \\ 
  2025 &  2.917 &  3.000 &  3.597 &  3.289 \\ 
  2026 &  3.000 &  3.000 &  3.044 &  3.003 \\ 
  2027 &  3.000 &  3.000 &  2.956 &  3.000 \\ 
  2028 &  3.000 &  3.000 &  3.003 &  3.000 \\ 
  2029 &  3.000 &  3.000 &  2.999 &  3.000 \\ 
   \hline
\end{tabular}
\caption{Inflación Anual} 
\end{table}
# Instalar el paquete writexl si aún no lo tienes
# install.packages("writexl")

# Cargar el paquete
library(writexl)

# Exportar el DataFrame a un archivo Excel
datosinflacion %>% 
  select(c("Año","Costa Rica","Chile","Colombia","Mexico")) %>% 
  write_xlsx("display_datosinflacion.xlsx")
# Costa Rica, Chile, Colombia y México
inflacion_long <- datosinflacion %>% 
  select(c("Año","Costa Rica","Chile","Colombia","Mexico")) %>%
  pivot_longer(
    cols = -1,  
    names_to = "País",
    values_to = "Inflación"
  )

inflacion_long <- inflacion_long %>% 
  mutate(
    País = as.factor(País),
    Inflación = as.numeric(Inflación),
    Año = as.numeric(Año))

# GRAFICO DE LINEA
# Crear el gráfico de líneas
(infPlot2 <- inflacion_long %>% ggplot(aes(x = Año, y = Inflación, color = País)) +
  geom_line(size = 1) +
  labs(x = "Año", y = "Inflacion (%)", color = "Pais", caption = "Fuente: Elaboración propia con datos de Fondo Monetario Internacional")+
  scale_x_discrete(limits= seq(2014, 2029, 2)) +
    scale_y_discrete(limits = seq(round(min(inflacion_long$Inflación)),round(max(inflacion_long$Inflación)),2))+
  # scale_color_viridis(discrete = TRUE, option = "H") +
  # scale_fill_viridis(discrete = TRUE) +
  scale_color_brewer(palette = "Spectral")+
  theme(legend.position = "right")+ labs(title = "Inflación anual")
)

# png("infPlot2.png", width = 800, height = 500)
# infPlot2 
# dev.off()
ggsave("infPlot2.png",plot = infPlot2, width = 8, height = 5)

TPM2

# Cargar datos de Colombia
tpm_colombia <- read_excel("TPM_Colombia.xlsx", 
    skip = 7)

# Cargar datos de Chile
tpm_chile  <- read_excel("TPM_Chile.xlsx")

# Cargar datos de Costa Rica
tpm_costa_rica <- tpm_anual

# Cargar datos de México
tpm_mexico <- read_excel("TPM_Mexico.xlsx")
tpm_colombia <- rename(tpm_colombia, Año = `Fecha (dd/mm/aaaa)`, TPM = `Tasa de intervención de política monetaria (%)`)
tpm_chile <- rename(tpm_chile, Año = `Período`, TPM = `Valor (Porcentaje)`)
tpm_costa_rica <- rename(tpm_costa_rica, Año = `Año`, TPM = `TPM`)
tpm_mexico <- rename(tpm_mexico, Año = `Fecha`, TPM = `Valor (Porcentaje)`)
# Limpiar datos de México
tpm_mexico$TPM <- gsub("%", "", tpm_mexico$TPM)  # Eliminar el signo de porcentaje
tpm_mexico$TPM <- gsub(",", ".", tpm_mexico$TPM) # Cambiar comas por puntos
tpm_mexico$TPM <- as.numeric(tpm_mexico$TPM)    # Convertir a numérico

# Limpiar datos de Chile
tpm_chile$TPM <- gsub(",", ".", tpm_chile$TPM)  # Cambiar comas por puntos
tpm_chile$TPM <- as.numeric(tpm_chile$TPM)     # Convertir a numérico


tpm_colombia$País <- "Colombia"
tpm_chile$País <- "Chile"
tpm_costa_rica$País <- "Costa Rica"
tpm_mexico$País <- "México"

# Convertir la columna TPM a numérico en todos los DataFrames
tpm_colombia$TPM <- as.numeric(tpm_colombia$TPM)
tpm_chile$TPM <- as.numeric(tpm_chile$TPM)
tpm_costa_rica$TPM <- as.numeric(tpm_costa_rica$TPM)
tpm_mexico$TPM <- as.numeric(tpm_mexico$TPM)

tpm_colombia <- tpm_colombia %>% dplyr::select("Año", "TPM")
tpm_chile <- tpm_chile %>% dplyr::select("Año", "TPM")
tpm_costa_rica <- tpm_costa_rica %>% dplyr::select("Año", "TPM")
tpm_mexico <- tpm_mexico %>% dplyr::select("Año", "TPM")
# Función para calcular el promedio anual de TPM
calcular_promedio_anual_tpm <- function(data_frame) {
  data_frame %>%
    mutate(Año = year(Año),  # Asegúrate de que Año es una fecha y conviértelo al año
           TPM = as.numeric(TPM)) %>%  # Convierte TPM a numérico si aún no lo está
    group_by(Año) %>%
    summarise(TPM = mean(TPM, na.rm = TRUE))  # Calcula el promedio, ignorando NA
}

tpm_colombia <- tpm_colombia %>% calcular_promedio_anual_tpm() %>% arrange()
tpm_chile <- tpm_chile %>% calcular_promedio_anual_tpm() %>% arrange()
# tpm_costa_rica <- tpm_costa_rica %>% calcular_promedio_anual_tpm()
tpm_mexico <- tpm_mexico %>% calcular_promedio_anual_tpm() %>% arrange()
tpm_colombia$País <- "Colombia"
tpm_chile$País <- "Chile"
tpm_costa_rica$País <- "Costa Rica"
tpm_mexico$País <- "México"
tpm_total <- bind_rows(tpm_colombia, tpm_chile, tpm_costa_rica, tpm_mexico)
tpm_total <- tpm_total %>%
  arrange(País, Año) %>% na.omit()

# Imprimir los primeros registros para verificar
head(tpm_total)
# A tibble: 6 × 3
    Año   TPM País 
  <dbl> <dbl> <chr>
1  2012  5.01 Chile
2  2013  4.92 Chile
3  2014  3.76 Chile
4  2015  3.06 Chile
5  2016  3.5  Chile
6  2017  2.74 Chile
# tpm_total$Año <- as.numeric(as.character(tpm_total$Año))
tpm_total$TPM <- as.numeric(as.character(tpm_total$TPM))
# Usando ggplot2 para graficar
library(ggplot2)

(tpmPlot <- ggplot(tpm_total[tpm_total$Año > 2007, ], aes(x = Año, y = TPM, color = País, group = País)) +
  geom_line(size = 1) +
  labs(#title = "TPM Anual por País",
       x = "Año", y = "TPM (%)") +
  scale_x_discrete(limits= seq(2008, 2024, 2)) +
  # scale_y_continuous(limits = c(0, 18.5))+
  # scale_y_continuous(limits = c(0, 18.5), breaks = seq(0, 18.5, by = 4)) +
  # scale_y_discrete(limits= seq(0, 18, 3)) +
  # scale_y_continuous(breaks = seq(min(tpm_total$TPM), max(tpm_total$TPM), by = 0.5))+
  scale_color_brewer(palette = "Spectral")+
  # scale_color_viridis(discrete = TRUE, option = "H")+
  theme_cowplot()
)

ggsave("tpmPlot.png",plot = tpmPlot, width = 8, height = 5)
inflacion_filtrada <- inflacion_long[inflacion_long$Año >= 2014,]
tpm_filtrada <- tpm_total[tpm_total$Año >= 2014,]

inflacion_filtrada <- inflacion_filtrada[inflacion_filtrada$Año <= 2024,]
tpm_filtrada <- tpm_filtrada[tpm_filtrada$Año <= 2024,]
# Crear los gráficos para cada país como subgráficos
p1 <- ggplot(data = inflacion_filtrada[inflacion_filtrada$País == "Chile",], aes(x = Año, y = Inflación, group = 1)) +
  geom_line(linetype = "solid", size = 1, color = "red", alpha = .5) +
  geom_line(data = tpm_filtrada[tpm_filtrada$País == "Chile",], aes(y = TPM), linetype = "dotted", size = 1, color = "blue", alpha = .5) +
  labs(title = "Chile", x = "Año", y = "%") +
  scale_x_discrete(limits= seq(2014, 2024, 2)) +
  theme_cowplot()

p3 <- ggplot(data = inflacion_filtrada[inflacion_filtrada$País == "Colombia",], aes(x = Año, y = Inflación, group = 1)) +
  geom_line(linetype = "solid", size = 1, color = "red", alpha = .5) +
  geom_line(data = tpm_filtrada[tpm_filtrada$País == "Colombia",], aes(y = TPM), linetype = "dotted", size = 1, color = "blue", alpha = .5) +
  labs(title = "Colombia", x = "Año", y = "%") +
  scale_x_discrete(limits= seq(2014, 2024, 2)) +
  theme_cowplot()

p2 <- ggplot(data = inflacion_filtrada[inflacion_filtrada$País == "Costa Rica",], aes(x = Año, y = Inflación, group = 1)) +
  geom_line(linetype = "solid", size = 1, color = "red", alpha = .5) +
  geom_line(data = tpm_filtrada[tpm_filtrada$País == "Costa Rica",], aes(y = TPM), linetype = "dotted", size = 1, color = "blue", alpha = .5) +
  labs(title = "Costa Rica", x = "Año", y = "%") +
  scale_x_discrete(limits= seq(2014, 2024, 2)) +
  theme_cowplot()

p4 <- ggplot(data = inflacion_filtrada[inflacion_filtrada$País == "Mexico",], aes(x = Año, y = Inflación, group = 1)) +
  geom_line(linetype = "solid", size = 1, color = "red", alpha = .5) +
  geom_line(data = tpm_filtrada[tpm_filtrada$País == "México",], aes(y = TPM), linetype = "dotted", size = 1, color = "blue", alpha = .5) +
  labs(title = "México", x = "Año", y = "%") +
  scale_x_discrete(limits= seq(2014, 2024, 2)) +
  theme_cowplot()

# Combinar los gráficos en una matriz 2x2
(infTpmInternacional <- grid.arrange(p1, p2, p3, p4, nrow = 2, ncol = 2,
                                     top = "Inflación y tasa de política monetaria anual",
                                     bottom = "Inflación en rojo, TPM en azul")
  )

TableGrob (4 x 2) "arrange": 6 grobs
  z     cells    name                grob
1 1 (2-2,1-1) arrange      gtable[layout]
2 2 (2-2,2-2) arrange      gtable[layout]
3 3 (3-3,1-1) arrange      gtable[layout]
4 4 (3-3,2-2) arrange      gtable[layout]
5 5 (1-1,1-2) arrange text[GRID.text.715]
6 6 (4-4,1-2) arrange text[GRID.text.716]
ggsave("infTpmInternacional.png",plot = infTpmInternacional, width = 8, height = 5)
(infTpmCR <- grid.arrange(p2, nrow = 1, ncol = 1,
                                     top = "Inflación y tasa de política monetaria anual",
                                     bottom = "Inflación en rojo, TPM en azul")
  )

TableGrob (3 x 1) "arrange": 3 grobs
  z     cells    name                grob
1 1 (2-2,1-1) arrange      gtable[layout]
2 2 (1-1,1-1) arrange text[GRID.text.750]
3 3 (3-3,1-1) arrange text[GRID.text.751]
ggsave("infTpmCR.png",plot = infTpmCR, width = 8, height = 5)

Otros indicadores

datosvariados <- read_csv("datosvariados.csv", 
                          col_types = cols(#`Subject Descriptor` = col_skip(), 
                            ISO = col_skip(),Units = col_skip(), 
                            Scale = col_skip(), `Estimates Start After` = col_skip(),
                            `Country/Series-specific Notes` = col_skip()), 
                          locale = locale(encoding = "ISO-8859-1")) #%>% clean_names()
# Gross domestic product based on purchasing-power-parity (PPP) share of world total
# Gross domestic product, constant prices           
# Current account balance           

datospib <- datosvariados %>% filter(str_detect(`Subject Descriptor`, "Gross domestic product, constant prices"))

datospib <- datospib %>% t()
colnames(datospib) <- datospib[1,]
datospib <- datospib[-1,]
# datosinflacion <- datosinflacion %>% as.data.frame.numeric(check.names = T)
# Convertir la matriz en un data frame
datospib <- as.data.frame(datospib)

# Si los años no están incluidos como una columna y deseas añadirlos desde el nombre de las filas
datospib$"Año" <- rownames(datospib)

# Cambiar el orden de las columnas si es necesario para que 'Year' sea la primera columna
datospib <- datospib[-1, c(ncol(datospib), 1:(ncol(datospib)-1))]

# datospib %>% 
#   select(c("Año","Costa Rica","Chile","Colombia","Mexico")) %>% 
#   xtable(caption = "Inflación Anual") %>% print(type = "latex", include.rownames = FALSE)

# Exportar el DataFrame a un archivo Excel
datospib %>% write_xlsx("display_PIB_PPP.xlsx")

Visualizar el PIB

# Costa Rica, Chile, Colombia y México
pib_long <- datospib %>% 
  select(c("Año","Costa Rica","Chile","Colombia","Mexico")) %>%
  pivot_longer(
    cols = -1,  
    names_to = "País",
    values_to = "PIB"
  )

pib_long <- pib_long %>% 
  mutate(
    País = as.factor(País),
    PIB = as.numeric(PIB),
    Año = as.numeric(Año))
# GRAFICO DE LINEA
# Crear el gráfico de líneas
(pibPlot <- pib_long %>% ggplot(aes(x = Año, y = PIB, color = País)) +
  geom_line(size = 1) +
  labs(x = "Año", y = "PIB", color = "Pais", caption = "Fuente: Elaboración propia con datos de Fondo Monetario Internacional")+
  scale_x_discrete(limits= seq(2014, 2029, 2)) +
    scale_y_discrete(limits = seq(round(min(pib_long$PIB)),round(max(pib_long$PIB)),2))+
  # scale_color_viridis(discrete = TRUE, option = "H") +
  # scale_fill_viridis(discrete = TRUE) +
  scale_color_brewer(palette = "Spectral")+
  theme(legend.position = "right")+ labs(title = "PIB anual")
)

# png("infPlot2.png", width = 800, height = 500)
# infPlot2 
# dev.off()
ggsave("pibPlot.png",plot = pibPlot, width = 8, height = 5)
PIB_filtrado <- pib_long[pib_long$Año >= 2014,]
PIB_filtrado <- PIB_filtrado[PIB_filtrado$Año <= 2024,]
# Crear los gráficos para cada país como subgráficos
p1 <- ggplot(data = inflacion_filtrada[inflacion_filtrada$País == "Chile",], aes(x = Año, y = Inflación, group = 1)) +
  geom_line(linetype = "solid", size = 1, color = "red", alpha = .5) +
  geom_line(data = PIB_filtrado[PIB_filtrado$País == "Chile" ,], aes(y = PIB), linetype = "dotted", size = 1, color = "blue", alpha = .5) +
  labs(title = "Chile", x = "Año", y = "%") +
  scale_x_discrete(limits= seq(2014, 2024, 2)) +
  theme_cowplot()

p3 <- ggplot(data = inflacion_filtrada[inflacion_filtrada$País == "Colombia",], aes(x = Año, y = Inflación, group = 1)) +
  geom_line(linetype = "solid", size = 1, color = "red", alpha = .5) +
  geom_line(data = PIB_filtrado[PIB_filtrado$País == "Colombia",], aes(y = PIB), linetype = "dotted", size = 1, color = "blue", alpha = .5) +
  labs(title = "Colombia", x = "Año", y = "%") +
  scale_x_discrete(limits= seq(2014, 2024, 2)) +
  theme_cowplot()

p2 <- ggplot(data = inflacion_filtrada[inflacion_filtrada$País == "Costa Rica",], aes(x = Año, y = Inflación, group = 1)) +
  geom_line(linetype = "solid", size = 1, color = "red", alpha = .5) +
  geom_line(data = PIB_filtrado[PIB_filtrado$País == "Costa Rica",], aes(y = PIB), linetype = "dotted", size = 1, color = "blue", alpha = .5) +
  labs(title = "Costa Rica", x = "Año", y = "%") +
  scale_x_discrete(limits= seq(2014, 2024, 2)) +
  theme_cowplot()

p4 <- ggplot(data = inflacion_filtrada[inflacion_filtrada$País == "Mexico",], aes(x = Año, y = Inflación, group = 1)) +
  geom_line(linetype = "solid", size = 1, color = "red", alpha = .5) +
  geom_line(data = PIB_filtrado[PIB_filtrado$País == "Mexico",], aes(y = PIB), linetype = "dotted", size = 1, color = "blue", alpha = .5) +
  labs(title = "México", x = "Año", y = "%") +
  scale_x_discrete(limits= seq(2014, 2024, 2)) +
  theme_cowplot()

# Combinar los gráficos en una matriz 2x2
(infPIBInternacional <- grid.arrange(p1, p2, p3, p4, nrow = 2, ncol = 2,
                                     top = "Inflación y PIB anual",
                                     bottom = "Inflación en rojo, PIB en azul")
  )

TableGrob (4 x 2) "arrange": 6 grobs
  z     cells    name                grob
1 1 (2-2,1-1) arrange      gtable[layout]
2 2 (2-2,2-2) arrange      gtable[layout]
3 3 (3-3,1-1) arrange      gtable[layout]
4 4 (3-3,2-2) arrange      gtable[layout]
5 5 (1-1,1-2) arrange text[GRID.text.992]
6 6 (4-4,1-2) arrange text[GRID.text.993]
# ggsave("infPIBInternacional.png",plot = infPIBInternacional, width = 8, height = 5)
ggsave("infPIBInternacional.png",plot = infPIBInternacional, width = 8, height = 5)
(infPIBCR <- grid.arrange(p2, nrow = 1, ncol = 1,
                                     top = "Inflación y PIB anual",
                                     bottom = "Inflación en rojo, PIB en azul")
  )

TableGrob (3 x 1) "arrange": 3 grobs
  z     cells    name                 grob
1 1 (2-2,1-1) arrange       gtable[layout]
2 2 (1-1,1-1) arrange text[GRID.text.1027]
3 3 (3-3,1-1) arrange text[GRID.text.1028]
ggsave("infPIBCR.png",plot = infPIBCR, width = 8, height = 5)