I wasted a lot of time for reading about R encoding hell, but unfortunately didnt find decision.
I need in R to assign character var with "ñ" symbol
utm <- "españa"
And after this pass this var as argument to google api function
pvs <- google_analytics_4(id,
date_range = c(date - 7, date - 1),
metrics = "pageviews",
dimensions = "countryIsoCode",
dim_filters = filter_clause_ga4(list(dim_filter("source", "EXACT", utm))))
But R/R Studio/Windows (I dont know what) read "españa" as "espana" and pass it to google_analytics_4() argument and as result GoogleAPI dont return any data, because "espana" utm-tag doesnt use. I read about set Sys.getlocale and Sys.setlocale and anothers things, but dont find how fix it.
So what is the easiest way to pass exactly "españa" rather "espana".
P.S.
> sessionInfo()
R version 3.4.0 (2017-04-21) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale: [1] LC_COLLATE=Russian_Russia.1251 LC_CTYPE=Russian_Russia.1251 LC_MONETARY=Russian_Russia.1251 LC_NUMERIC=C LC_TIME=Russian_Russia.1251
attached base packages: [1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached): [1] compiler_3.4.0 tools_3.4.0
sessionInfo()
here to understand your current settings. And what doesutm
print on the console (in my case:[1] "españa"
- as expected). Please help us to understand your problem by posting a self-contained example so that we can reproduce you problem (e. g. I do not know the functionsfilter_clause_ga4()
anddim_filter()
where the source of your problem could be hidden)... – R Yoda