I want to open R with input encoding UTF-8 for plots, and I can’t seem to get it to work.
This is my (short) program in plot.R
plot(1:5, xlab="ř")
And this is what I get (I, sadly, have to use old version of R)
~/$ R <plot.R --no-save --encoding="utf-8"
R version 2.8.0 (2008-10-20)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> plot(1:5, xlab="ř")
Warning messages:
1: In title(...) :
conversion failure on 'ř' in 'mbcsToSbcs': dot substituted for <c5>
2: In title(...) :
conversion failure on 'ř' in 'mbcsToSbcs': dot substituted for <99>
3: In title(...) :
conversion failure on 'ř' in 'mbcsToSbcs': dot substituted for <c5>
4: In title(...) :
conversion failure on 'ř' in 'mbcsToSbcs': dot substituted for <99>
>
Googling anything R-related is a daunting task, so I am asking here. Am I doing something wrong? Or is it just the old R version?
edit: it seems like the error is not in input encoding, but in something else – when I write the letter as \u0159, it does the same thing. So it is probably something with PDF fonts, I guess.
To reply to Joran: I don’t really know the intricacies of R output devices; my R outputs by default into PDF. I have to use Fedora, release 8. (again, ancient, as well as the R version)
I forced my admin to upgrade R and it works, but I needed to set up
Sys.setlocalefirst.That about answers my question.