[英]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.