本文介绍了如何在readr/tidyverse中设置encoding/fileEncoding选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个旧光谱仪的文本文件.它以"UTF-16LE"编码(我通过 readr:guess_encoding()函数发现了这一点).我设法在base-r中使用:

i have a textfile of an old spectrometer. It is encoded in "UTF-16LE" (I found this out with the readr:guess_encoding() function). I managed to read it in in base-r with:

spectra_gr2 <-  read.csv("~/some/path/spectra.csv", header = F, encoding = "UTF-16LE", fileEncoding = "UTF-16LE",  skipNul = T)

这工作正常,但我想使用tidyverse/readr来做!有谁知道我如何在示例的 read_delim()中设置encoding/fileEncoding这两个选项?

This works fine, but i want to do it using tidyverse/readr!Does anyone know how i set the two options encoding/fileEncoding in read_delim() for Example?

推荐答案

语言环境

readr::read_delim("~/some/path/spectra.csv", delim = ",",
       locale = locale(encoding = "UTF-16LE"), col_names = FALSE)

这篇关于如何在readr/tidyverse中设置encoding/fileEncoding选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 03:22