1

My txt table looks like this:

morče   kanár   malý pes
morče   potkan  rybičky
želva   rybičky střední pes
kočka   papoušek    želva

It is encoded in UTF-8 and stored in file mazlicci.txt. When I try

library(rio)
import("mazlicci.txt")

the character encoding is broken.

How can I control character encoding in the rio package? The encoding argument in import knows only three charsets: UTF-8, unknown, and Latin-1. The UTF-8 option does not remedy the problem. (Nor the other ones, expectedly.) I am working on Windows 7, R version 3.2.4 (2016-03-10) -- "Very Secure Dishes", Platform: i386-w64-mingw32/i386 (32-bit),Czech locale (cp1250). I experience no encoding problems with UTF-8 encoded files using the basic R importing functions.

zx8754
  • 52,746
  • 12
  • 114
  • 209
Silvie
  • 85
  • 1
  • 1
  • 8

1 Answers1

3

You can specify the encoding in the import function:

library(rio)
import("mazlicci.txt", encoding = "UTF-8")
Wolfgang
  • 574
  • 4
  • 11
  • And what happens when you import a bunch of files via lapply? Example: mylist <- lapply(excel_files_list, rio::import(encoding = "UCS-2LE")) I get an error : Error in grepl("^http.*://", file) : argument "file" is missing, with no default – useRj Jul 07 '17 at 07:52
  • Your use of lapply is wrong. it should look something like: lapply(excel_files_list, rio::import, encoding = "UCS-2LE"). Please see ?lapply for more details. – Wolfgang Jul 09 '17 at 15:13