I want to import data to Power BI using R script (via Get Data -> Other-> R script
).
However, the final imported dataset have wrong encoding for character (string) type of columns.
For example, if I use the following sample R script:
library(data.table)
dt<-data.table(str=c("Весна","Лето","Осень","Зима","И снова весна"),num=seq(1,5))
Imported dataset:
If I try to add Encoding(dt$str)<-"UTF-8"
to the R script code, I get this error:
"Unable to translate bytes [C2] at index -1 from specified code page to Unicode."
I want to use R script because I need to do some calculations and merge several big datasets and use the merged outcome in Power BI visualization afterwards. (just pure visualization purpose only)
With other symbols it's even worse. For instance, let's try out this
dt<-data.frame(str=c("Көктем","Жаз","Күз","Қыс","Алақай, көктем келді!"),num=seq(1,5))
It even does not import anything, just throws error:
ADO.NET: R script error
rScriptWrapper_options = getOption('save.image.defaults') save(list = rScriptWrapper_dataFrames, file = "globalEnv.rdata
However, I don't get such errors neither in RStudio nor in R GUI, so I doubt the problem lays in R.
Is there any way to change encoding in such cases?