0

如何将包含中英文单词的数据框导出到 csv 文件?当我正常导出时,甚至当我使用UTF-8编码导出时,显示的中文单词如下所示:

(<U+6709>)<U+307F><U+3064><U+3044><U+5712>

这是我要导出的 R 脚本:

library(xlsx)
write.csv(df_final,file = "./df_final.csv",
          row.names=FALSE,
          fileEncoding = "UTF-8")
4

1 回答 1

1

一种选择是write_excel_csvreadr包中使用。它似乎比处理 UTF8 更好write.csv。这对我有用:

chinese = c("狗&quot;, "猫&quot;)
Encoding(chinese) = "UTF-8"
english = c("dog", "cat")

df_final = data.frame(chinese, english)
Encoding(df_final$chinese) = "UTF-8"

library(readr)
write_excel_csv(df_final, file = './df_final.csv')
于 2020-11-27T01:56:09.020 回答