R does not open with UTF-8

I want to open R with UTF-8 input encoding for graphs, and I cannot get it to work.

This is my (short) program in plot.R

plot(1:5, xlab="ř") 

And this is what I get (I, unfortunately, have to use the 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 everything related to R is challenging, so I ask here. Am I doing something wrong? Or is it just an old version of R?

edit: it seems that the error is not in the input encoding, but in something else - when I write a letter like \u0159 , it does the same. This is probably something with PDF fonts, I think.

To answer Joran: I really don't know the intricacies of R output devices; my R default outputs in PDF. I have to use Fedora release 8. (again, ancient as well as R version)

+2
source share
2 answers

I got my administrator to update R and it works, but I need to configure Sys.setlocale .

As for the answers to my question.

+1
source

In R, you usually need to write things with the correct upper and lower case letters for each character, so you should try: "UTF-8"

Also, I think UTF-8 is the default encoding for most European and North American systems, so why are you changing the default? I do not receive any warnings with this code and a symbol that looks like a lowercase with a cup of “hat” on my system.

And R 2.8 is really ancient.

Search: use a CRAN or r-project or language: r to restrict your search a bit, or go to RSiteSearch or RSeek . (I use different default values ​​for the baron search site .)

+3
source

Source: https://habr.com/ru/post/1498439/


All Articles