[R] Problem with new version of R: Mutated vocals

Ivan Krylov |kry|ov @end|ng |rom d|@root@org
Fri Mar 22 22:18:13 CET 2024


В Fri, 22 Mar 2024 16:11:14 +0000
MACHO Siegfried via R-help <r-help using r-project.org> пишет:

> If I type the command:
> Dir <- "C/Users/macho/Documents/_LVn/Experimentelle _bungen"
> in the R console there is no problem. However, if I put the same
> command into a source file (e.g. Test.r) and call this file from R
> (via the source command), I get the following error message:
> 
> > source("C:\\Users\\macho\\Documents\\_LVn\\Experimentelle
> > _bungen\\R-Scripts\\R-Dokumentation\\R_scripts zur
> > R_Dokumentation\\Kapitel 4 Erstellen eines
> > Balkendiagramms\\Test.R")  
> Fehler: invalid multibyte character in parser
> (C:\Users\macho\Documents\_LVn\Experimentelle
> _bungen\R-Scripts\R-Dokumentation\R_scripts zur
> R_Dokumentation\Kapitel 4 Erstellen eines Balkendiagramms\Test.R:1:54

A few versions ago, the R developers made the change of the encoding
used by R on Windows. Instead of the ANSI encoding, R now uses UTF-8:
https://blog.r-project.org/2020/05/02/utf-8-support-on-windows/index.html

This makes it possible to represent many more characters than the
256-byte range covered by CP1252, but the byte sequences are now
different. Also, non-ASCII characters will take more than one byte to
store.

Can you save the script using the UTF-8 encoding instead of CP1252?
Alternatively, try source(..., encoding = 'CP1252').

> In addition, text files saved with an older version of R (using the
> function write.table) containing mutated vowels are not read-in
> correctly by the function read.table.

In a similar manner, try read.table(..., fileEncoding = 'CP1252').
Setting encoding = 'latin1' may also work, even if it's technically a
different encoding.

-- 
Best regards,
Ivan



More information about the R-help mailing list