Error detecting locale: Error in make.names(col.names, unique = TRUE): string multibyte inválida 3 (Using default: en_US)


rm(list=ls(all=TRUE))
library(rmarkdown)
library(ff)
library(tidytable)
library(basedosdados)
library(patchwork)
library(rgdal)
library(ggside)
library(ggridges)
library(tmap)
library(arulesViz)
library(igraph)
library(spatialreg)
library(openxlsx)
library(tseries)
library(dplyr)
library(sidrar)
library(kableExtra)
library(knitr)
library(bslib)
library(DT)
library(xtable)
library(xlsxjars)
library(readxl)
library(janitor)
library(tidyverse)
library(tidyr)
library(abjutils)
library(psych)
library(DescTools)
library(sf)
library(sp)
library(bizdays)
library(ggsn)
library(ggplot2)
library(esquisse)
library(hrbrthemes)
library(gtfstools)
library(ggspatial)
library(gridExtra)
library(readxl)
library(kableExtra)
library(htmltools)
library(ggstatsplot)
library(sjPlot)
library(plotly)
library(scales)
library(Quandl)
library(rb3)
library(dygraphs)
library(stargazer)
library(lubridate)
library(rvest)
library(curl)
library(RcppRoll)
library(GetTDData)
library(GetQuandlData)
library(GetFREData)
library(GetDFPData2)
library(GetBCBData)
library(ggthemes)
library(stringr)
library(stringi)
library(gdata)
library(skimr)
library(gtrendsR)
library(hrbrthemes)
library(syuzhet)
library(tidyRSS)
library(tidygraph)
library(ggraph)
library(ggnet)
library(GGally)
library(network)
library(sna)
library(flexdashboard)
library(shiny)
library(rsconnect)
library(tm)
#locale()
#locale(date_names = "pt")
# get local format
#Sys.localeconv()
#Sys.setlocale()
#sessionInfo()
#Sys.setlocale("LC_CTYPE", "English")
#Sys.getlocale()
#Sys.setlocale("LC_ALL","English")

today = Sys.time()

Dolar <- GetBCBData::gbcbd_get_series(
id = c("Dolar" = 1),
first.date = "2020-01-01",
last.date = Sys.Date()
)

DolarHj<- last(Dolar$value)
tail(Dolar)

Euro <- GetBCBData::gbcbd_get_series(
id = c("Euro" = 21620),
first.date = "2020-01-01",
last.date = Sys.Date()
)

EuroHj<- last(Euro$value)
tail(Euro)


Selic <- GetBCBData::gbcbd_get_series(
id = c("Selic" = 432),
first.date = "2020-01-01",
last.date = Sys.Date()
)

SelicHj<- last(Selic$value)
tail(Selic)


IPCA <- GetBCBData::gbcbd_get_series(
id = c("IPCA" = 13522),
first.date = "2020-01-01",
last.date = Sys.Date()
)

IPCAHj<- last(IPCA$value)
tail(IPCA)

Custo<- readr::read_delim("https://portaldeinformacoes.conab.gov.br/downloads/arquivos/CustoProducao.txt", locale = locale(encoding = "UTF-8")) |>
 select(-municipio, - cod_ibge, - id_produto) |>   
  filter(produto != "FAVA D'ANTA") |>
#  rename( custoha = vlr_custo_variavel_ha) 
  trim() |>  
   as_tibble() |> 
      mutate(safra =
 case_when(grepl("1ª SAFRA",safra) ~ "PRIMEIRA",
           grepl("2ª SAFRA",safra) ~ "SEGUNDA",
           grepl("3ª SAFRA",safra) ~ "TERCEIRA",
          TRUE ~ safra)) |> 
 mutate(vlr_custo_variavel_ha = as.numeric(vlr_custo_variavel_ha),
       vlr_custo_variavel_unidade = as.numeric(vlr_custo_variavel_unidade),
       vlr_custo_fixo_ha = as.numeric(vlr_custo_fixo_ha))

CustoCana <- readr::read_csv2("Custo_Producao_CANA.csv") |>
select(-municipio, - cod_ibge, - id_produto) |>
trim() |>
   as_tibble() |>
      mutate(safra =
 case_when(grepl("1ª SAFRA",safra) ~ "PRIMEIRA",
           grepl("2ª SAFRA",safra) ~ "SEGUNDA",
           grepl("3ª SAFRA",safra) ~ "TERCEIRA",
          TRUE ~ safra)) |> 
   mutate(vlr_custo_variavel_ha = as.numeric(vlr_custo_variavel_ha),
       vlr_custo_variavel_unidade = as.numeric(vlr_custo_variavel_unidade),
       vlr_custo_fixo_ha = as.numeric(vlr_custo_fixo_ha))

Levantamento <- readr::read_delim('https://portaldeinformacoes.conab.gov.br/downloads/arquivos/LevantamentoGraos.txt',  locale = locale(encoding = "UTF-8")) |> 
  trim() |> 
  as_tibble() |>
   mutate(id_levantamento = as.numeric(id_levantamento), 
   across(where(is.numeric),replace_na, 0), 
dsc_levantamento =
case_when(grepl("1\u00ba LEV",dsc_levantamento) ~ "PRIMEIRO",
           grepl("2\u00ba LEV",dsc_levantamento) ~ "SEGUNDO",
           grepl("3\u00ba LEV",dsc_levantamento) ~ "TERCEIRO",
           grepl("4\u00ba LEV",dsc_levantamento) ~ "QUARTO",
           grepl("5\u00ba LEV",dsc_levantamento) ~ "QUINTO",
           grepl("6\u00ba LEV",dsc_levantamento) ~ "SEXTO",
           grepl("7\u00ba LEV",dsc_levantamento) ~ "SETIMO",
           grepl("8\u00ba LEV",dsc_levantamento) ~ "OITAVO",
           grepl("9\u00ba LEV",dsc_levantamento) ~ "NONO",
           grepl("10\u00ba LEV",dsc_levantamento) ~ "DECIMO",
           grepl("11\u00ba LEV",dsc_levantamento) ~ "DECIMO_PRIMEIRO",
           grepl("12\u00ba LEV",dsc_levantamento) ~ "DECIMO_SEGUNDO",
TRUE ~ dsc_levantamento))

LevantamentoCana<- readr::read_delim("https://portaldeinformacoes.conab.gov.br/downloads/arquivos/LevantamentoCana.txt",  locale = locale(encoding = "UTF-8")) |> 
  trim() |> 
  as_tibble() |> 
  mutate(id_levantamento = as.numeric(id_levantamento))|> 
   mutate(across(where(is.numeric),replace_na, 0), 
dsc_levantamento =
case_when(grepl("1\u00ba LEV",dsc_levantamento) ~ "PRIMEIRO",
           grepl("2\u00ba LEV",dsc_levantamento) ~ "SEGUNDO",
           grepl("3\u00ba LEV",dsc_levantamento) ~ "TERCEIRO",
           grepl("4\u00ba LEV",dsc_levantamento) ~ "QUARTO",
           grepl("5\u00ba LEV",dsc_levantamento) ~ "QUINTO",
           grepl("6\u00ba LEV",dsc_levantamento) ~ "SEXTO",
           grepl("7\u00ba LEV",dsc_levantamento) ~ "SETIMO",
           grepl("8\u00ba LEV",dsc_levantamento) ~ "OITAVO",
           grepl("9\u00ba LEV",dsc_levantamento) ~ "NONO",
           grepl("10\u00ba LEV",dsc_levantamento) ~ "DECIMO",
           grepl("11\u00ba LEV",dsc_levantamento) ~ "DECIMO_PRIMEIRO",
           grepl("12\u00ba LEV",dsc_levantamento) ~ "DECIMO_SEGUNDO",
TRUE ~ dsc_levantamento))

LevantamentoJoin <- dplyr::full_join(LevantamentoCana, Levantamento) |> 
   mutate(across(where(is.numeric),replace_na, 0))
          
Produtividade <- readr::read_delim('https://portaldeinformacoes.conab.gov.br/downloads/arquivos/SerieHistoricaGraos.txt',  locale = locale(encoding = "UTF-8"))|>  
  trim() |> 
  as_tibble() |>
   mutate(area_plantada_mil_ha = as.numeric(area_plantada_mil_ha),
          dsc_safra_previsao = case_when(grepl("1ª SAFRA", dsc_safra_previsao) ~ "PRIMEIRA",
           grepl("2ª SAFRA",dsc_safra_previsao) ~ "SEGUNDA",
           grepl("3ª SAFRA",dsc_safra_previsao) ~ "TERCEIRA",
TRUE ~ dsc_safra_previsao))  

ProdutividadeCana <- readr::read_delim('https://portaldeinformacoes.conab.gov.br/downloads/arquivos/SerieHistoricaCana.txt',  locale = locale(encoding = "UTF-8"))|>  
  trim() |> 
  as_tibble() |>
  mutate(area_plantada_mil_ha = as.numeric(area_plantada_mil_ha),
         dsc_safra_previsao = case_when(grepl("1ª SAFRA", dsc_safra_previsao) ~ "PRIMEIRA",
           grepl("2ª SAFRA",dsc_safra_previsao) ~ "SEGUNDA",
           grepl("3ª SAFRA",dsc_safra_previsao) ~ "TERCEIRA",
TRUE ~ dsc_safra_previsao))  

ProdutividadeJoin <- dplyr::full_join(ProdutividadeCana, Produtividade)|> 
   mutate(across(where(is.numeric),replace_na, 0))

Preco_Agropec_Sem <- readr::read_delim("https://portaldeinformacoes.conab.gov.br/downloads/arquivos/PrecosSemanalUF.txt", locale = locale(encoding = "UTF-8")) |> 
  trim() |>
  filter(dsc_nivel_comercializacao == "PRECO RECEBIDO P/ PR",
         produto != "FAVA D'ANTA") |> 
 as_tibble()

Preco_Agropec_Sem$dsc_nivel_comercializacao <-  chartr("ÂÃÁÊÉÍÔÕÓÚÇ", "AAAEEIOOOUC", Preco_Agropec_Sem$dsc_nivel_comercializacao)

Preco_Agropec_Sem$classificao_produto<-  chartr("ÂÃÁÊÉÍÔÕÓÚÇ", "AAAEEIOOOUC", Preco_Agropec_Sem$classificao_produto)

Preparing to deploy document...DONE
Uploading bundle for document: 7944101...Detecting system locale ... DONE
Deploying bundle: 6676740 for document: 7944101 ...
Waiting for task: 1260126870
building: Parsing manifest
building: Building image: 7871477
building: Installing system dependencies
building: Fetching packages
building: Installing packages
building: Installing files
building: Pushing image: 7871477
deploying: Starting instances
rollforward: Activating new instances
terminating: Stopping old instances
Document successfully deployed to https://evertontlima.shinyapps.io/Dados_Agropecuario/
Deployment completed: https://evertontlima.shinyapps.io/Dados_Agropecuario/
Warning message:
Error detecting locale: Error in make.names(col.names, unique = TRUE): string multibyte inválida 3
(Using default: en_US)

R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=Portuguese_Brazil.utf8
[2] LC_CTYPE=C
[3] LC_MONETARY=Portuguese_Brazil.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.utf8
system code page: 65001

attached base packages:
[1] grid stats graphics grDevices utils
[6] datasets methods base

other attached packages:
[1] tm_0.7-10 NLP_0.2-1
[3] rsconnect_0.8.28 shiny_1.7.4
[5] flexdashboard_0.6.0 sna_2.7
[7] statnet.common_4.7.0 network_1.18.0
[9] GGally_2.1.2 ggnet_0.1.0
[11] ggraph_2.1.0 tidygraph_1.2.2
[13] tidyRSS_2.0.6 syuzhet_1.0.6
[15] gtrendsR_1.5.1 skimr_2.1.5
[17] gdata_2.18.0.1 stringi_1.7.8
[19] ggthemes_4.2.4 GetBCBData_0.7.0
[21] GetDFPData2_0.6.2 GetFREData_0.8.1
[23] GetQuandlData_0.1.0 GetTDData_1.5.1
[25] RcppRoll_0.3.0 curl_4.3.3
[27] rvest_1.0.3 lubridate_1.9.0
[29] timechange_0.1.1 tidyipea_0.0.0.9000
[31] stargazer_5.2.3 dygraphs_1.1.1.6
[33] rb3_0.0.7 Quandl_2.11.0
[35] xts_0.12.2 zoo_1.8-11
[37] scales_1.2.1 plotly_4.10.1
[39] sjPlot_2.8.12 ggstatsplot_0.10.0
[41] htmltools_0.5.4 gridExtra_2.3
[43] ggspatial_1.1.7 gtfstools_1.2.0
[45] hrbrthemes_0.8.0 esquisse_1.1.2
[47] ggsn_0.5.0 bizdays_1.0.12
[49] DescTools_0.99.47 psych_2.2.9
[51] abjutils_0.3.2 forcats_0.5.2
[53] stringr_1.5.0 purrr_1.0.0
[55] readr_2.1.3 tidyr_1.2.1
[57] tibble_3.1.8 tidyverse_1.3.2
[59] janitor_2.1.0 readxl_1.4.1
[61] xlsxjars_0.6.1 rJava_1.0-6
[63] xtable_1.8-4 DT_0.26
[65] bslib_0.4.2 knitr_1.41
[67] kableExtra_1.3.4 sidrar_0.2.9
[69] dplyr_1.0.10 tseries_0.10-52
[71] openxlsx_4.2.5.1 spatialreg_1.2-6
[73] sf_1.0-9 spData_2.2.1
[75] igraph_1.3.5 arulesViz_1.5-1
[77] arules_1.7-5 Matrix_1.5-3
[79] tmap_3.3-3 ggridges_0.5.4
[81] ggside_0.2.2 ggplot2_3.4.0
[83] rgdal_1.6-3 sp_1.5-1
[85] patchwork_1.1.2 basedosdados_0.2.1
[87] tidytable_0.9.1 ff_4.0.7
[89] bit_4.0.5 rmarkdown_2.19

loaded via a namespace (and not attached):
[1] svglite_2.1.0 class_7.3-20
[3] rprojroot_2.0.3 crayon_1.5.2
[5] typed_0.0.1 MASS_7.3-58.1
[7] shinybusy_0.3.1 nlme_3.1-161
[9] backports_1.4.1 reprex_2.0.2
[11] rlang_1.0.6 performance_0.10.1
[13] nloptr_2.0.3 extrafontdb_1.0
[15] proto_1.0.0 extrafont_0.18
[17] ggmap_3.0.1 bit64_4.0.5
[19] glue_1.6.2 parallel_4.2.2
[21] classInt_0.4-8 haven_2.5.1
[23] tidyselect_1.2.0 rio_0.5.29
[25] XML_3.99-0.13 sjmisc_2.8.9
[27] magrittr_2.0.3 evaluate_0.19
[29] quantmod_0.4.20 gdtools_0.2.4
[31] RgoogleMaps_1.4.5.3 cli_3.5.0
[33] rstudioapi_0.14 ascii_2.4
[35] sjlabelled_1.2.0 leafem_0.2.0
[37] xfun_0.36 askpass_1.1
[39] parameters_0.20.0 tmaptools_3.1-1
[41] expm_0.999-6 ggrepel_0.9.2
[43] reshape_0.8.9 shinyWidgets_0.7.5
[45] png_0.1-8 zeallot_0.1.0
[47] withr_2.5.0 slam_0.1-50
[49] bitops_1.0-7 ggforce_0.4.1
[51] plyr_1.8.8 cellranger_1.1.0
[53] e1071_1.7-12 coda_0.19-4
[55] pillar_1.8.1 cachem_1.0.6
[57] fs_1.5.2 raster_3.6-11
[59] TTR_0.24.3 paletteer_1.5.0
[61] vctrs_0.5.1 ellipsis_0.3.2
[63] generics_0.1.3 tools_4.2.2
[65] foreign_0.8-84 munsell_0.5.0
[67] tweenr_2.0.2 anytime_0.3.9
[69] emmeans_1.8.3 proxy_0.4-27
[71] fastmap_1.1.0 compiler_4.2.2
[73] abind_1.4-5 httpuv_1.6.7
[75] stars_0.6-0 rbcb_0.1.10
[77] lattice_0.20-45 deldir_1.0-6
[79] utf8_1.2.2 later_1.3.0
[81] wk_0.7.1 jsonlite_1.8.4
[83] bigrquery_1.4.1 gld_2.6.6
[85] estimability_1.4.1 lazyeval_0.2.2
[87] LearnBayes_2.15.1 promises_1.2.0.1
[89] webshot_0.5.4 dichromat_2.0-0.1
[91] survival_3.4-0 yaml_2.3.6
[93] systemfonts_1.0.4 memoise_2.0.1
[95] graphlayouts_0.8.4 quadprog_1.5-8
[97] here_1.0.1 viridisLite_0.4.1
[99] digest_0.6.31 assertthat_0.2.1
[101] mime_0.12 repr_1.1.4
[103] Rttf2pt1_1.3.11 lwgeom_0.2-10
[105] bayestestR_0.13.0 units_0.8-1
[107] Exact_3.2 data.table_1.14.6
[109] splines_4.2.2 rematch2_2.1.2
[111] reactable_0.4.1 googledrive_2.0.0
[113] broom_1.0.2 hms_1.1.2
[115] modelr_0.1.10 colorspace_2.0-3
[117] base64enc_0.1-3 mnormt_2.1.1
[119] sass_0.4.4 Rcpp_1.0.9
[121] mvtnorm_1.1-3 fansi_1.0.3
[123] tzdb_0.3.0 R6_2.5.1
[125] lifecycle_1.0.3 rootSolve_1.8.2.3
[127] statsExpressions_1.3.6 zip_2.2.2
[129] writexl_1.4.1 datawizard_0.6.5
[131] googlesheets4_1.0.1 minqa_1.2.5
[133] jquerylib_0.1.4 leaflet_2.1.1
[135] snakecase_0.11.0 RColorBrewer_1.1-3
[137] htmlwidgets_1.6.0 polyclip_1.10-4
[139] crosstalk_1.2.0 terra_1.6-47
[141] openssl_2.0.5 insight_0.18.8
[143] lmom_2.9 codetools_0.2-18
[145] leaflet.providers_1.9.0 gtools_3.9.4
[147] dbplyr_2.2.1 correlation_0.8.3
[149] gtable_0.3.1 phosphoricons_0.1.2
[151] DBI_1.1.3 datamods_1.4.0
[153] httr_1.4.4 KernSmooth_2.23-20
[155] vroom_1.6.0 farver_2.1.1
[157] spdep_1.2-7 leafsync_0.1.0
[159] viridis_0.6.2 xml2_1.3.3
[161] boot_1.3-28.1 ggeffects_1.1.4
[163] lme4_1.1-31 s2_1.1.1
[165] sjstats_0.18.2 jpeg_0.1-10
[167] pkgconfig_2.0.3 gargle_1.2.1
[169] maptools_1.1-6

Hi, did you manage to solve this issue? I have the same one (my files are also in Brazilian Portuguese).