将编码应用于整个数据表 [英] Apply Encoding to Entire Data.Table
问题描述
我将以下文件读入data.table中,就像这样:
I have the following file read into a data.table like so:
raw <- fread("avito_train.tsv", nrows=1000)
然后,如果我更改特定列和行的编码,例如此:
Then, if I change the encoding of a particular column and row like this:
Encoding(raw$title[2]) <- "UTF-8"
它完美地工作。
但是,如何将编码应用于所有列和所有行?
But, how can I apply the encoding to all columns, and all rows?
我检查了 fread
文档,但似乎没有任何编码选项。另外,我尝试了 Encoding(raw)
,但是这给了我一个错误(可能是字符向量参数)。
I checked the fread
documentation but there doesn't appear to be any encoding option. Also, I tried Encoding(raw)
but that gives me an error (a character vector argument expected).
编辑:本文详细介绍了Windows RStudio http://quantifyingmemory.blogspot.com/2013/01/r-and-foreign-characters.html
This article details more information on foreign text in RStudio on Windows http://quantifyingmemory.blogspot.com/2013/01/r-and-foreign-characters.html
推荐答案
我尝试过:
Encoding(raw$title) <- "UTF-8"
设置整个列的编码。现在可以正常工作。仍然对其他任何选项开放,因此它将在导入时自动执行。
Which sets the encoding for the entire column. That will work fine for now. Still open to any other options so it will do this automatically upon import.
这篇关于将编码应用于整个数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!