R在Windows平台Rstudio上的data.frames中打印UTF-8代码 [英] R print UTF-8 code in data.frames on Windows platform Rstudio

查看:150
本文介绍了R在Windows平台Rstudio上的data.frames中打印UTF-8代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当数据框中包含UTF-8字符时,它将无法正确显示.

When there are UTF-8 characters in the data frame, it won't be displayed properly.

例如,以下是正确的:

> "\U6731"
[1] "朱"

但是当我将其放入数据框中并打印时,它是:

But when I put that in a data frame and have it printed, here it is:

> data.frame(x="\U6731")
         x
1 <U+6731>

因此,我认为这与编码问题无关.

Hence I believe this has nothing to do with encoding issues.

是否可以直接打印而不是<U+6731>.

Is there any direct way to print instead of <U+6731>.

我必须在公司中使用Windows,所以对我来说使用Linux可能不可行.

I have to use Windows in company so using Linux might not be feasible for me.

推荐答案

语料库库针对此错误提供了一种解决方法.要么这样做:

The corpus library has a work-around for this bug. Either do this:

library(corpus)
df <- data.frame(x = "\U6731")
print.corpus_frame(df)

否则请执行以下操作:

class(df) <- c("corpus_frame", "data.frame")
df

这篇关于R在Windows平台Rstudio上的data.frames中打印UTF-8代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆