Is it possible to define encoding in R script?
Something like that (just example):
encoding("utf-8")
I know for Reopen with encoding in RStudio, but I am not looking for this.
Is it possible to define encoding in R script?
Something like that (just example):
encoding("utf-8")
I know for Reopen with encoding in RStudio, but I am not looking for this.
## x is intended to be in latin1
x <- "fa\xE7ile"
Encoding(x)
Encoding(x) <- "latin1"
x
xx <- iconv(x, "latin1", "UTF-8")
Encoding(c(x, xx))
c(x, xx)
Encoding(xx) <- "bytes"
xx # will be encoded in hex
cat("xx = ", xx, "\n", sep = "")
http://www.inside-r.org/r-doc/base/Encoding
https://stat.ethz.ch/R-manual/R-devel/library/base/html/Encoding.html
A workaround is to write another script that has the following code:
source('C:/Script.R', encoding = 'UTF-8')
replace "C:/Script.R" with your script path & name.
Then when you call this script, it will run 'Script.R' with UTF-8 encoding.