Vou refazer todas as figuras do artigo em espanhol. Aí já vou aproveitar e colocar este arquivo no site para o caso de alguma pessoa interessada em replicar o artigo.
Estou falando do artigo INFLAÇÃO DE ALIMENTOS NO BRASIL: O PAPEL DOS PREÇOS INTERNACIONAIS (com José Eustáquio Ribeiro Vieira Filho).
Os dados para gerar as figuras estão aqui.
Nem todos os pacotes são usados. Então, se algum der muito trabalho para carregar, tira ele e olha se o código continua funcionando sem problemas.
library(loadinstall)
packages <- c(
"zoo", "readr", "ggplot2", "methods", "ggthemes", "directlabels", "ggrepel",
"readxl", "haven", "dplyr", "knitr", "owidR", "readxl", "sidrar", "reshape",
"scales", "basedosdados", "DBI", "bigrquery", "tidyr", "corrplot",
"modelsummary", "wesanderson", "urca", "vars", "mFilter", "tseries",
"TSstudio", "forecast", "tidyverse", "data.table", "stats"
)
lapply(packages, dynamic_require)
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
## Warning: package 'owidR' was built under R version 4.3.3
##
## Attaching package: 'reshape'
## The following object is masked from 'package:dplyr':
##
## rename
## The following object is masked from 'package:directlabels':
##
## merge_recurse
##
## Attaching package: 'scales'
## The following object is masked from 'package:readr':
##
## col_factor
##
## Attaching package: 'tidyr'
## The following objects are masked from 'package:reshape':
##
## expand, smiths
## corrplot 0.92 loaded
## Warning: package 'wesanderson' was built under R version 4.3.3
## Warning: package 'urca' was built under R version 4.3.3
## Warning: package 'vars' was built under R version 4.3.3
## Carregando pacotes exigidos: MASS
##
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
##
## select
## Carregando pacotes exigidos: strucchange
## Warning: package 'strucchange' was built under R version 4.3.3
## Carregando pacotes exigidos: sandwich
## Carregando pacotes exigidos: lmtest
## Warning: package 'mFilter' was built under R version 4.3.3
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
## Warning: package 'tseries' was built under R version 4.3.3
## Warning: package 'TSstudio' was built under R version 4.3.3
## Warning: package 'forecast' was built under R version 4.3.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ lubridate 1.9.3 ✔ tibble 3.2.1
## ✔ purrr 1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ stringr::boundary() masks strucchange::boundary()
## ✖ scales::col_factor() masks readr::col_factor()
## ✖ purrr::discard() masks scales::discard()
## ✖ tidyr::expand() masks reshape::expand()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ✖ reshape::rename() masks dplyr::rename()
## ✖ MASS::select() masks dplyr::select()
## ✖ lubridate::stamp() masks reshape::stamp()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
##
## Attaching package: 'data.table'
##
##
## The following objects are masked from 'package:lubridate':
##
## hour, isoweek, mday, minute, month, quarter, second, wday, week,
## yday, year
##
##
## The following object is masked from 'package:purrr':
##
## transpose
##
##
## The following object is masked from 'package:reshape':
##
## melt
##
##
## The following objects are masked from 'package:dplyr':
##
## between, first, last
##
##
## The following objects are masked from 'package:zoo':
##
## yearmon, yearqtr
## [[1]]
## [1] "zoo" "loadinstall" "stats" "graphics" "grDevices"
## [6] "utils" "datasets" "methods" "base"
##
## [[2]]
## [1] "readr" "zoo" "loadinstall" "stats" "graphics"
## [6] "grDevices" "utils" "datasets" "methods" "base"
##
## [[3]]
## [1] "ggplot2" "readr" "zoo" "loadinstall" "stats"
## [6] "graphics" "grDevices" "utils" "datasets" "methods"
## [11] "base"
##
## [[4]]
## [1] "ggplot2" "readr" "zoo" "loadinstall" "stats"
## [6] "graphics" "grDevices" "utils" "datasets" "methods"
## [11] "base"
##
## [[5]]
## [1] "ggthemes" "ggplot2" "readr" "zoo" "loadinstall"
## [6] "stats" "graphics" "grDevices" "utils" "datasets"
## [11] "methods" "base"
##
## [[6]]
## [1] "directlabels" "ggthemes" "ggplot2" "readr" "zoo"
## [6] "loadinstall" "stats" "graphics" "grDevices" "utils"
## [11] "datasets" "methods" "base"
##
## [[7]]
## [1] "ggrepel" "directlabels" "ggthemes" "ggplot2" "readr"
## [6] "zoo" "loadinstall" "stats" "graphics" "grDevices"
## [11] "utils" "datasets" "methods" "base"
##
## [[8]]
## [1] "readxl" "ggrepel" "directlabels" "ggthemes" "ggplot2"
## [6] "readr" "zoo" "loadinstall" "stats" "graphics"
## [11] "grDevices" "utils" "datasets" "methods" "base"
##
## [[9]]
## [1] "haven" "readxl" "ggrepel" "directlabels" "ggthemes"
## [6] "ggplot2" "readr" "zoo" "loadinstall" "stats"
## [11] "graphics" "grDevices" "utils" "datasets" "methods"
## [16] "base"
##
## [[10]]
## [1] "dplyr" "haven" "readxl" "ggrepel" "directlabels"
## [6] "ggthemes" "ggplot2" "readr" "zoo" "loadinstall"
## [11] "stats" "graphics" "grDevices" "utils" "datasets"
## [16] "methods" "base"
##
## [[11]]
## [1] "knitr" "dplyr" "haven" "readxl" "ggrepel"
## [6] "directlabels" "ggthemes" "ggplot2" "readr" "zoo"
## [11] "loadinstall" "stats" "graphics" "grDevices" "utils"
## [16] "datasets" "methods" "base"
##
## [[12]]
## [1] "owidR" "knitr" "dplyr" "haven" "readxl"
## [6] "ggrepel" "directlabels" "ggthemes" "ggplot2" "readr"
## [11] "zoo" "loadinstall" "stats" "graphics" "grDevices"
## [16] "utils" "datasets" "methods" "base"
##
## [[13]]
## [1] "owidR" "knitr" "dplyr" "haven" "readxl"
## [6] "ggrepel" "directlabels" "ggthemes" "ggplot2" "readr"
## [11] "zoo" "loadinstall" "stats" "graphics" "grDevices"
## [16] "utils" "datasets" "methods" "base"
##
## [[14]]
## [1] "sidrar" "owidR" "knitr" "dplyr" "haven"
## [6] "readxl" "ggrepel" "directlabels" "ggthemes" "ggplot2"
## [11] "readr" "zoo" "loadinstall" "stats" "graphics"
## [16] "grDevices" "utils" "datasets" "methods" "base"
##
## [[15]]
## [1] "reshape" "sidrar" "owidR" "knitr" "dplyr"
## [6] "haven" "readxl" "ggrepel" "directlabels" "ggthemes"
## [11] "ggplot2" "readr" "zoo" "loadinstall" "stats"
## [16] "graphics" "grDevices" "utils" "datasets" "methods"
## [21] "base"
##
## [[16]]
## [1] "scales" "reshape" "sidrar" "owidR" "knitr"
## [6] "dplyr" "haven" "readxl" "ggrepel" "directlabels"
## [11] "ggthemes" "ggplot2" "readr" "zoo" "loadinstall"
## [16] "stats" "graphics" "grDevices" "utils" "datasets"
## [21] "methods" "base"
##
## [[17]]
## [1] "basedosdados" "scales" "reshape" "sidrar" "owidR"
## [6] "knitr" "dplyr" "haven" "readxl" "ggrepel"
## [11] "directlabels" "ggthemes" "ggplot2" "readr" "zoo"
## [16] "loadinstall" "stats" "graphics" "grDevices" "utils"
## [21] "datasets" "methods" "base"
##
## [[18]]
## [1] "DBI" "basedosdados" "scales" "reshape" "sidrar"
## [6] "owidR" "knitr" "dplyr" "haven" "readxl"
## [11] "ggrepel" "directlabels" "ggthemes" "ggplot2" "readr"
## [16] "zoo" "loadinstall" "stats" "graphics" "grDevices"
## [21] "utils" "datasets" "methods" "base"
##
## [[19]]
## [1] "bigrquery" "DBI" "basedosdados" "scales" "reshape"
## [6] "sidrar" "owidR" "knitr" "dplyr" "haven"
## [11] "readxl" "ggrepel" "directlabels" "ggthemes" "ggplot2"
## [16] "readr" "zoo" "loadinstall" "stats" "graphics"
## [21] "grDevices" "utils" "datasets" "methods" "base"
##
## [[20]]
## [1] "tidyr" "bigrquery" "DBI" "basedosdados" "scales"
## [6] "reshape" "sidrar" "owidR" "knitr" "dplyr"
## [11] "haven" "readxl" "ggrepel" "directlabels" "ggthemes"
## [16] "ggplot2" "readr" "zoo" "loadinstall" "stats"
## [21] "graphics" "grDevices" "utils" "datasets" "methods"
## [26] "base"
##
## [[21]]
## [1] "corrplot" "tidyr" "bigrquery" "DBI" "basedosdados"
## [6] "scales" "reshape" "sidrar" "owidR" "knitr"
## [11] "dplyr" "haven" "readxl" "ggrepel" "directlabels"
## [16] "ggthemes" "ggplot2" "readr" "zoo" "loadinstall"
## [21] "stats" "graphics" "grDevices" "utils" "datasets"
## [26] "methods" "base"
##
## [[22]]
## [1] "modelsummary" "corrplot" "tidyr" "bigrquery" "DBI"
## [6] "basedosdados" "scales" "reshape" "sidrar" "owidR"
## [11] "knitr" "dplyr" "haven" "readxl" "ggrepel"
## [16] "directlabels" "ggthemes" "ggplot2" "readr" "zoo"
## [21] "loadinstall" "stats" "graphics" "grDevices" "utils"
## [26] "datasets" "methods" "base"
##
## [[23]]
## [1] "wesanderson" "modelsummary" "corrplot" "tidyr" "bigrquery"
## [6] "DBI" "basedosdados" "scales" "reshape" "sidrar"
## [11] "owidR" "knitr" "dplyr" "haven" "readxl"
## [16] "ggrepel" "directlabels" "ggthemes" "ggplot2" "readr"
## [21] "zoo" "loadinstall" "stats" "graphics" "grDevices"
## [26] "utils" "datasets" "methods" "base"
##
## [[24]]
## [1] "urca" "wesanderson" "modelsummary" "corrplot" "tidyr"
## [6] "bigrquery" "DBI" "basedosdados" "scales" "reshape"
## [11] "sidrar" "owidR" "knitr" "dplyr" "haven"
## [16] "readxl" "ggrepel" "directlabels" "ggthemes" "ggplot2"
## [21] "readr" "zoo" "loadinstall" "stats" "graphics"
## [26] "grDevices" "utils" "datasets" "methods" "base"
##
## [[25]]
## [1] "vars" "lmtest" "strucchange" "sandwich" "MASS"
## [6] "urca" "wesanderson" "modelsummary" "corrplot" "tidyr"
## [11] "bigrquery" "DBI" "basedosdados" "scales" "reshape"
## [16] "sidrar" "owidR" "knitr" "dplyr" "haven"
## [21] "readxl" "ggrepel" "directlabels" "ggthemes" "ggplot2"
## [26] "readr" "zoo" "loadinstall" "stats" "graphics"
## [31] "grDevices" "utils" "datasets" "methods" "base"
##
## [[26]]
## [1] "mFilter" "vars" "lmtest" "strucchange" "sandwich"
## [6] "MASS" "urca" "wesanderson" "modelsummary" "corrplot"
## [11] "tidyr" "bigrquery" "DBI" "basedosdados" "scales"
## [16] "reshape" "sidrar" "owidR" "knitr" "dplyr"
## [21] "haven" "readxl" "ggrepel" "directlabels" "ggthemes"
## [26] "ggplot2" "readr" "zoo" "loadinstall" "stats"
## [31] "graphics" "grDevices" "utils" "datasets" "methods"
## [36] "base"
##
## [[27]]
## [1] "tseries" "mFilter" "vars" "lmtest" "strucchange"
## [6] "sandwich" "MASS" "urca" "wesanderson" "modelsummary"
## [11] "corrplot" "tidyr" "bigrquery" "DBI" "basedosdados"
## [16] "scales" "reshape" "sidrar" "owidR" "knitr"
## [21] "dplyr" "haven" "readxl" "ggrepel" "directlabels"
## [26] "ggthemes" "ggplot2" "readr" "zoo" "loadinstall"
## [31] "stats" "graphics" "grDevices" "utils" "datasets"
## [36] "methods" "base"
##
## [[28]]
## [1] "TSstudio" "tseries" "mFilter" "vars" "lmtest"
## [6] "strucchange" "sandwich" "MASS" "urca" "wesanderson"
## [11] "modelsummary" "corrplot" "tidyr" "bigrquery" "DBI"
## [16] "basedosdados" "scales" "reshape" "sidrar" "owidR"
## [21] "knitr" "dplyr" "haven" "readxl" "ggrepel"
## [26] "directlabels" "ggthemes" "ggplot2" "readr" "zoo"
## [31] "loadinstall" "stats" "graphics" "grDevices" "utils"
## [36] "datasets" "methods" "base"
##
## [[29]]
## [1] "forecast" "TSstudio" "tseries" "mFilter" "vars"
## [6] "lmtest" "strucchange" "sandwich" "MASS" "urca"
## [11] "wesanderson" "modelsummary" "corrplot" "tidyr" "bigrquery"
## [16] "DBI" "basedosdados" "scales" "reshape" "sidrar"
## [21] "owidR" "knitr" "dplyr" "haven" "readxl"
## [26] "ggrepel" "directlabels" "ggthemes" "ggplot2" "readr"
## [31] "zoo" "loadinstall" "stats" "graphics" "grDevices"
## [36] "utils" "datasets" "methods" "base"
##
## [[30]]
## [1] "lubridate" "forcats" "stringr" "purrr" "tibble"
## [6] "tidyverse" "forecast" "TSstudio" "tseries" "mFilter"
## [11] "vars" "lmtest" "strucchange" "sandwich" "MASS"
## [16] "urca" "wesanderson" "modelsummary" "corrplot" "tidyr"
## [21] "bigrquery" "DBI" "basedosdados" "scales" "reshape"
## [26] "sidrar" "owidR" "knitr" "dplyr" "haven"
## [31] "readxl" "ggrepel" "directlabels" "ggthemes" "ggplot2"
## [36] "readr" "zoo" "loadinstall" "stats" "graphics"
## [41] "grDevices" "utils" "datasets" "methods" "base"
##
## [[31]]
## [1] "data.table" "lubridate" "forcats" "stringr" "purrr"
## [6] "tibble" "tidyverse" "forecast" "TSstudio" "tseries"
## [11] "mFilter" "vars" "lmtest" "strucchange" "sandwich"
## [16] "MASS" "urca" "wesanderson" "modelsummary" "corrplot"
## [21] "tidyr" "bigrquery" "DBI" "basedosdados" "scales"
## [26] "reshape" "sidrar" "owidR" "knitr" "dplyr"
## [31] "haven" "readxl" "ggrepel" "directlabels" "ggthemes"
## [36] "ggplot2" "readr" "zoo" "loadinstall" "stats"
## [41] "graphics" "grDevices" "utils" "datasets" "methods"
## [46] "base"
##
## [[32]]
## [1] "data.table" "lubridate" "forcats" "stringr" "purrr"
## [6] "tibble" "tidyverse" "forecast" "TSstudio" "tseries"
## [11] "mFilter" "vars" "lmtest" "strucchange" "sandwich"
## [16] "MASS" "urca" "wesanderson" "modelsummary" "corrplot"
## [21] "tidyr" "bigrquery" "DBI" "basedosdados" "scales"
## [26] "reshape" "sidrar" "owidR" "knitr" "dplyr"
## [31] "haven" "readxl" "ggrepel" "directlabels" "ggthemes"
## [36] "ggplot2" "readr" "zoo" "loadinstall" "stats"
## [41] "graphics" "grDevices" "utils" "datasets" "methods"
## [46] "base"
Esta parte é para que eu me ache no futuro, para saber de onde saiu cada base de dados
Carregando as bases
load("figuras_cepal_ipea.RData")
p3 <- ggplot(data = pub, aes(x = pub$Ano, y =100*pub$Food_Prices/pub$Economia)) +
geom_line() +
geom_point()+
labs(title = "",
y = "Publicaciones con el término (% Economía)",
x = "")+
theme_clean()+
theme(legend.position = "none")+
annotate(geom="text",x=2019,
y=11.3,label="Food Prices", colour = "black")
ggsave(file = "espanhol_f1.png", plot = p3, width = 4.8, height = 3.6, dpi = 300)
## Warning: Use of `pub$Ano` is discouraged.
## ℹ Use `Ano` instead.
## Warning: Use of `pub$Food_Prices` is discouraged.
## ℹ Use `Food_Prices` instead.
## Warning: Use of `pub$Economia` is discouraged.
## ℹ Use `Economia` instead.
## Warning: Use of `pub$Ano` is discouraged.
## ℹ Use `Ano` instead.
## Warning: Use of `pub$Food_Prices` is discouraged.
## ℹ Use `Food_Prices` instead.
## Warning: Use of `pub$Economia` is discouraged.
## ℹ Use `Economia` instead.
p3
## Warning: Use of `pub$Ano` is discouraged.
## ℹ Use `Ano` instead.
## Warning: Use of `pub$Food_Prices` is discouraged.
## ℹ Use `Food_Prices` instead.
## Warning: Use of `pub$Economia` is discouraged.
## ℹ Use `Economia` instead.
## Warning: Use of `pub$Ano` is discouraged.
## ℹ Use `Ano` instead.
## Warning: Use of `pub$Food_Prices` is discouraged.
## ℹ Use `Food_Prices` instead.
## Warning: Use of `pub$Economia` is discouraged.
## ℹ Use `Economia` instead.
f2 <- ggplot(data = fao, aes(x = fao$Year, y =fao$`Food Price Index`)) +
geom_line() +
geom_point()+
labs(title = "",
y = "Precio mundial de los alimentos (index, FAO, año)",
x = "")+
theme_clean()+
theme(legend.position = "none")+
annotate("rect", xmin = 2006, xmax = 2008, ymin = -Inf, ymax = 140,
alpha = .2)+
annotate(geom="text",x=2007,
y=143,label="+41%", colour = "black")+
annotate("rect", xmin = 2020, xmax = 2022, ymin = -Inf, ymax = 140,
alpha = .2)+
annotate(geom="text",x=2021,
y=143,label="+41%", colour = "black")
print(f2)
## Warning: Use of `fao$Year` is discouraged.
## ℹ Use `Year` instead.
## Warning: Use of `` fao$`Food Price Index` `` is discouraged.
## ℹ Use `Food Price Index` instead.
## Warning: Use of `fao$Year` is discouraged.
## ℹ Use `Year` instead.
## Warning: Use of `` fao$`Food Price Index` `` is discouraged.
## ℹ Use `Food Price Index` instead.
ggsave(file="espanholf2.png", plot=f2, width = 4.8, height = 3.6, dpi = 300)
## Warning: Use of `fao$Year` is discouraged.
## ℹ Use `Year` instead.
## Use of `` fao$`Food Price Index` `` is discouraged.
## ℹ Use `Food Price Index` instead.
## Warning: Use of `fao$Year` is discouraged.
## ℹ Use `Year` instead.
## Warning: Use of `` fao$`Food Price Index` `` is discouraged.
## ℹ Use `Food Price Index` instead.
p12 <- ggplot() +
geom_line(data = merge12, aes(x = time, y = alimentos), color="darkred") +
geom_line(data = merge12, aes(x = time, y = geral), color="black") +
geom_line(data = merge12, aes(x = time, y = fao_nominal), color="blue") +
labs(title = "",
y = "Índice de precios (base=2014-2016)",
x = "") +
theme_clean()+
annotate("rect", xmin = as.Date('2020-01-01'), xmax = as.Date('2023-02-01'), ymin = -Inf, ymax = 170, alpha = .1, fill = "red")+
annotate(geom="text",x= as.Date("2006-06-01"),y=100,label="FAO", colour = "blue")+
annotate(geom="text",x= as.Date("2000-01-01"),y=45,label="General", colour = "black")+
annotate(geom="text",x= as.Date("2003-01-01"),y=30,label="Alimentos", colour = "darkred")+
annotate(geom="text",x= as.Date("2020-03-01"),y=175,label="Alimentos(BRA)=+38%", colour = "darkred")+
annotate(geom="text",x= as.Date("2021-06-01"),y=182,label="IPCA=+22% ", colour = "black")+
annotate(geom="text",x= as.Date("2021-06-01"),y=189,label="FAO=+29%", colour = "blue")+
scale_x_date(date_breaks = "2 year", date_labels = "%Y")+
scale_x_date(date_breaks = "2 year", date_labels = "%Y")+
scale_y_continuous(breaks = scales::pretty_breaks(n = 7))
## Scale for x is already present.
## Adding another scale for x, which will replace the existing scale.
p12
ggsave(file="espanholf3p12.png", plot=p12, width = 4.8, height = 3.6, dpi = 300)
g24 <- ggplot() +
geom_line(data=acu24, aes(x = time, y = alimentosacu24), color="darkred") +
geom_line(data=acu24, aes(x = time, y = faoacu24), color="blue", linetype=1) +
labs(title = "",
y = "Variación acumulada, alimentos, 24 meses (%)",
x = "") +
theme_clean()+
scale_x_date(date_breaks = "2 year", date_labels = "%Y")+
scale_y_continuous(breaks = scales::pretty_breaks(n = 7))+
annotate(geom="text",x= as.Date("1998-01-01"),y=20,label="Brasil (IPCA-IBGE)", colour = "darkred")+
annotate(geom="text",x= as.Date("2015-01-01"),y=50,label="Internacional (FAO)", colour = "blue")
g24
## Warning: Removed 24 rows containing missing values (`geom_line()`).
## Removed 24 rows containing missing values (`geom_line()`).
ggsave(file="espanholf4.png", plot=g24, width=6.72, height=5.04, dpi = 300)
## Warning: Removed 24 rows containing missing values (`geom_line()`).
## Removed 24 rows containing missing values (`geom_line()`).
colnames(br5)<-c("FAO(real)", "FAO(nominal)", "Cereales", "Harinas", "Tubérculos", "Azúcares", "Hortalizas", "Frutas", "Carnes", "Pescado", "Carnes y pescados (ind)", "Aves y huevos", "Leches y derivados", "Productos de panadería", "Aceites", "Bebidas", "Enlatado", "Especias", "Ali. Fuera de casa", "Ali. Hechos")
M<-cor(na.omit(br5))
head(round(M,2))
## FAO(real) FAO(nominal) Cereales Harinas Tubérculos Azúcares
## FAO(real) 1.00 0.92 0.72 0.79 0.07 0.74
## FAO(nominal) 0.92 1.00 0.63 0.76 0.13 0.76
## Cereales 0.72 0.63 1.00 0.97 0.17 0.79
## Harinas 0.79 0.76 0.97 1.00 0.20 0.87
## Tubérculos 0.07 0.13 0.17 0.20 1.00 0.24
## Azúcares 0.74 0.76 0.79 0.87 0.24 1.00
## Hortalizas Frutas Carnes Pescado Carnes y pescados (ind)
## FAO(real) 0.57 -0.82 0.86 0.86 0.86
## FAO(nominal) 0.67 -0.83 0.86 0.90 0.90
## Cereales 0.61 -0.61 0.88 0.80 0.86
## Harinas 0.70 -0.72 0.95 0.89 0.94
## Tubérculos 0.60 -0.08 0.16 0.27 0.20
## Azúcares 0.77 -0.75 0.89 0.91 0.89
## Aves y huevos Leches y derivados Productos de panadería Aceites
## FAO(real) 0.82 0.84 0.82 0.72
## FAO(nominal) 0.79 0.87 0.81 0.66
## Cereales 0.91 0.84 0.92 0.97
## Harinas 0.96 0.93 0.98 0.98
## Tubérculos 0.22 0.26 0.20 0.21
## Azúcares 0.86 0.89 0.92 0.79
## Bebidas Enlatado Especias Ali. Fuera de casa Ali. Hechos
## FAO(real) 0.86 0.86 0.84 0.88 0.83
## FAO(nominal) 0.94 0.91 0.89 0.93 0.89
## Cereales 0.76 0.82 0.84 0.77 0.85
## Harinas 0.89 0.92 0.93 0.88 0.94
## Tubérculos 0.18 0.20 0.20 0.17 0.19
## Azúcares 0.90 0.90 0.90 0.90 0.90
corrplot(M, method = "color", tl.cex = 1, tl.col = "black", diag = TRUE, type = "upper")
png("espanholfig5.png", width = 6.72, height = 5.04, units = "in", res = 300)
corrplot(M, method = "color", tl.cex = 1, tl.col = "black", diag = TRUE, type = "upper")
dev.off()
## png
## 2
Para gerar este gráfico é necessário fazer as estimativas. Elas estão no final deste documento como “Estimativas para a figura 6”.
fig_artigo_1 <- ggplot(data=city_results) +
geom_line(aes(y=irf_dol_y1, x=time, colour = "c1", linetype = "c1")) +
geom_line(aes(y=irf_fao_y1, x=time, colour = "c2", linetype = "c2")) +
geom_line(aes(y=irf_pib_y1, x=time, colour = "c3", linetype = "c3")) +
geom_line(aes(y=irf_oil_y1, x=time, colour = "c4", linetype = "c4")) +
labs(title = "",
y = "Precios domésticos de alimentos",
x = "Meses",
colour = "") +
theme_minimal() +
scale_color_manual(values = c("c1" = "red", "c2" = "darkgreen", "c3" = "blue", "c4" = "black")) +
scale_linetype_manual(values = c("c1" = "solid", "c2" = "dashed", "c3" = "solid", "c4" = "solid")) +
geom_ribbon(aes(ymin=lower_dol_y1, ymax=upper_dol_y1, x=time, fill = "b1"), alpha = 0.1) +
geom_ribbon(aes(ymin=lower_fao_y1, ymax=upper_fao_y1, x=time, fill = "b2"), alpha = 0.1) +
geom_ribbon(aes(ymin=lower_pib_y1, ymax=upper_pib_y1, x=time, fill = "b3"), alpha = 0.07) +
geom_ribbon(aes(ymin=lower_oil_y1, ymax=upper_oil_y1, x=time, fill = "b4"), alpha = 0.15) +
scale_fill_manual(values = c("b1" = "red", "b2" = "lightgreen", "b3" = "blue", "b4" = "gray")) +
xlim(1, 13) + guides(fill = FALSE, linetype = FALSE, colour = FALSE) +
scale_y_continuous(labels = function(x) format(x, big.mark = ".", decimal.mark = ","))+
annotate("text", x = 12.4, y = max(city_results$irf_dol_y1), label = "Dólar", color = "red") +
annotate("text", x = 12.4, y = max(city_results$irf_fao_y1), label = "FAO", color = "darkgreen") +
annotate("text", x = 12.4, y = -0.08, label = "PIB", color = "blue") +
annotate("text", x = 12.6, y = 0.06, label = "Petróleo", color = "black")+
theme(text = element_text(size = 12))
## Warning: The `<scale>` argument of `guides()` cannot be `FALSE`. Use "none" instead as
## of ggplot2 3.3.4.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
fig_artigo_1
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Removed 1 row containing missing values (`geom_line()`).
## Removed 1 row containing missing values (`geom_line()`).
ggsave(file="espanholf5.png", plot=fig_artigo_1, width=6.72, height=5.04, dpi = 300)
## Warning: Removed 1 row containing missing values (`geom_line()`).
## Removed 1 row containing missing values (`geom_line()`).
## Removed 1 row containing missing values (`geom_line()`).
## Removed 1 row containing missing values (`geom_line()`).
time_mapping <- c(
y2 = "Belém",
y3 = "Fortaleza",
y4 = "Recife",
y5 = "Salvador",
y6 = "Belo Horizonte",
y7 = "Rio de Janeiro",
y8 = "São Paulo",
y9 = "Curitiba",
y10 = "Porto Alegre"
)
serie_labels <- c(
dol = "Dólar",
fao = "FAO",
oil = "Petróleo",
pib = "PIB"
)
# Criar o gráfico ggplot com rótulos do eixo x girados em 90 graus
g20<-ggplot(test_collapsed, aes(x = factor(time, levels = names(time_mapping)), y = irf, group = serie, color = serie)) +
geom_point(position = position_dodge(width = 0.4)) +
geom_errorbar(
aes(ymin = lower, ymax = upper),
position = position_dodge(width = 0.4),
width = 0.1
) +
labs(title = "",
x = "",
y = "Precios domésticos de alimentos", colour="") +
scale_x_discrete(labels = time_mapping) + # Mapear rótulos de "time"
scale_color_manual(values = c("dol" = "blue", "fao" = "darkorange", "oil" = "black", "pib" = "gray"), labels = serie_labels) + # Rótulos personalizados para "serie"
theme_minimal() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
scale_y_continuous(labels = function(x) format(x, big.mark = ".", decimal.mark = ","))
ggsave(file="espanholf6.png", plot=g20, width=6.72, height=5.04, dpi = 300)
g20
## mudando os nomes
load("r6.Rda")
traducoes_espanhol <- c("Cereales", "Harinas + Pastas", "Tub. + Raíces + Leg.", "Azúcares y derivados",
"Hortalizas y verduras", "Frutas", "Carnes", "Pescado", "Carnes y pescados (ind)",
"Aves y huevos", "Leches y derivados", "Productos de panadería", "Aceites y grasas",
"Bebidas", "Enlatado", "Sal y especias", "Ali. Fuera de casa")
# Adicionando a variável 'traducao_espanhol' ao dataframe 'r6'
r6 <- cbind(r6, traducoes_espanhol)
g21 <- ggplot(r6, aes(x = traducoes_espanhol, group = traducoes_espanhol)) +
geom_pointrange(aes(y = dol_irf, ymin = dol_lower, ymax = dol_upper, color = "Dólar"), position = position_dodge(width = 0.5)) +
geom_pointrange(aes(y = fao_irf, ymin = fao_lower, ymax = fao_upper, color = "FAO"), position = position_dodge(width = 0.5)) +
geom_pointrange(aes(y = oil_irf, ymin = oil_lower, ymax = oil_upper, color = "Petróleo"), position = position_dodge(width = 0.5)) +
geom_pointrange(aes(y = pib_irf, ymin = pib_lower, ymax = pib_upper, color = "PIB"), position = position_dodge(width = 0.5)) +
labs(
title = "",
x = "",
y = "Precios domésticos de alimentos",
color = ""
) +
theme_minimal() +
theme(
axis.text.x = element_text(angle = 90, hjust = 1),
legend.position = "bottom", # Move legend to the bottom
legend.direction = "horizontal", # Display legend items horizontally
legend.text = element_text(angle = 0) # Set legend text angle to 0 (horizontal)
) +
scale_color_manual(
values = c("blue", "darkorange", "black", "gray"),
labels = c("Dólar", "FAO", "Petróleo", "PIB")
)
ggsave(file="espanholf8.png", plot=g21, width=6.72, height=5.04, dpi=300)
g21
dados <- data.frame(
nomeportugues = c("Alimentação e bebidas", "Habitação", "Artigos de residência", "Vestuário",
"Transportes", "Saúde e cuidados pessoais", "Despesas pessoais", "Educação",
"Comunicação"),
valor = c(35.45, 23.19, 25.43, 28.05, 26.42, 23.91, 19.35, 24.89, 8.13),
nomespanhol = c("1 – Alimentos y bebidas", "2 – Habitación", "3 – Artículos de residencia",
"4 – Vestuario", "5 – Transporte", "6 – Salud y cuidados personales",
"7 – Gastos personales", "8 – Educación", "9 – Comunicación"),
stringsAsFactors = FALSE
)
# Visualizar o dataframe
print(dados)
## nomeportugues valor nomespanhol
## 1 Alimentação e bebidas 35.45 1 – Alimentos y bebidas
## 2 Habitação 23.19 2 – Habitación
## 3 Artigos de residência 25.43 3 – Artículos de residencia
## 4 Vestuário 28.05 4 – Vestuario
## 5 Transportes 26.42 5 – Transporte
## 6 Saúde e cuidados pessoais 23.91 6 – Salud y cuidados personales
## 7 Despesas pessoais 19.35 7 – Gastos personales
## 8 Educação 24.89 8 – Educación
## 9 Comunicação 8.13 9 – Comunicación
ali3<-ggplot(dados, aes(valor, nomespanhol, fill=nomespanhol)) +
geom_col()+ labs(title = "",
y = "",
x = "Inflación acumulada entre Ene-2020 y Feb-2023, %")+
theme_clean()+
scale_fill_manual(values=c("steelblue", "grey50", "grey50", "grey50", "grey50","grey50","grey50","grey50","grey50"))+
theme(legend.position = "none")
ggsave(file="espanholf9.png", plot=ali3, width=6.72, height=5.04, dpi=300)
ali3