Specifying encoding

  • {readr} uses UTF-8 unless you tell it otherwise
# \xf1 is the Latin1 encoding of ñ
x <- "text\nEl Ni\xf1o was particularly bad this year"
read_csv(charToRaw(x), locale = locale(encoding = "Latin1"))$text
## [1] "El Niño was particularly bad this year"