繁体   English   中英

如何将带有希伯来语字段的RData文件加载到Tableau

[英]How to load an RData file with hebrew fields to tableau

我正在尝试将包含希伯来语字段的RData文件加载到tableau。

下面的代码向虹膜添加一个包含希伯来字母的字段,并将数据帧保存到RData文件。

尝试将文件加载到Tableau时-出现以下错误消息:

“无法完成操作错误读取文件iris heb.RData:错误代码= -2编码错误的数量超出用户定义的限制,将停止执行”

解决此问题的最佳方法是什么?

iris_heb <- data.frame(iris, Heb_word = c("יום ראשון",
                               "יום שני",
                               "יום שלישי",
                               "יום רביעי",
                               "יום חמישי"))


head(iris_heb)

  Sepal.Length Sepal.Width Petal.Length Petal.Width Species                                                          Heb_word
1          5.1         3.5          1.4         0.2  setosa <U+05D9><U+05D5><U+05DD> <U+05E8><U+05D0><U+05E9><U+05D5><U+05DF>
2          4.9         3.0          1.4         0.2  setosa                 <U+05D9><U+05D5><U+05DD> <U+05E9><U+05E0><U+05D9>
3          4.7         3.2          1.3         0.2  setosa <U+05D9><U+05D5><U+05DD> <U+05E9><U+05DC><U+05D9><U+05E9><U+05D9>
4          4.6         3.1          1.5         0.2  setosa <U+05D9><U+05D5><U+05DD> <U+05E8><U+05D1><U+05D9><U+05E2><U+05D9>
5          5.0         3.6          1.4         0.2  setosa <U+05D9><U+05D5><U+05DD> <U+05D7><U+05DE><U+05D9><U+05E9><U+05D9>
6          5.4         3.9          1.7         0.4  setosa <U+05D9><U+05D5><U+05DD> <U+05E8><U+05D0><U+05E9><U+05D5><U+05DF>

save(iris_heb, file = "iris heb.RData")

在此处输入图片说明

您使用哪个操作系统?

如果您使用Windows,则可以尝试使用UTF-8编码将数据另存为csv:

write_utf8_for_hebrew <- function(df, file) {
  line <- paste('"', names(df), '"', sep = "", collapse = " , ")
  data <- apply(df, 1, function(x) {paste('"', x, '"', sep = "", collapse = " , ")})
  writeLines(c(line, data), file , useBytes = TRUE)
}

write_utf8_for_hebrew(iris_heb, "iris_heb.csv")

然后,您可以通过>连接>文本文件加载数据


您也可以尝试更改编码:

iris_heb$Heb_word <- as.character(iris_heb$Heb_word)
Encoding(iris_heb$Heb_word) <- "UTF-8"

save(iris_heb, file = "iris heb.RData")

更新资料

因此,我将使用ISO 8859-8

# set hebrew words to character type
iris_heb$Heb_word <- as.character(iris_heb$Heb_word)
# change the Encoding to ISO 8859-8
Encoding(iris_heb$Heb_word) <- "ISO 8859-8"
# save as RData
save(iris_heb, file = "iris heb.RData")

并设置一个特定的TDC文件:

<connection-customization class='stat-direct' enabled='true' version='10.0'>
<vendor name='stat-direct' />
<driver name='stat-direct' />
  <customizations>
    <customization name='source-charset' value='iso-8859-8' />
  </customizations>
</connection-customization>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM