Loading

連接到 RData 檔案時發生錯誤「The input RData file contains 0 members」

發佈日期: Oct 14, 2022
描述
在 Tableau Desktop 中連接到 RData 檔案(.rda、.rdata)時,會收到以下錯誤消息:
 
與資料源通信時出错。
Unable to connect to the Server.Check that the server is running and you have access privileges to the requested database.(無法連接到伺服器。請檢查伺服器是否正在運行並且您有所請求資料庫的訪問權限。)

The input RData file contains 0 members, there is no data to transfer, please check the log for further details.(輸入 RData 檔案包含 0 個成員,沒有要傳輸的資料,請檢查日誌瞭解更多詳細資訊。)
Error reading file mydata.rda: error code=-1(讀取檔案 mydata.rda 時出錯: 錯誤代碼 =-1)
The table "[...].[...]" does not exist.(表「[...].[...]」不存在。)

Cause

在 Tableau Desktop 中連接到 RData 檔案時,該檔案必須只包含一個對象,並且該對象必須是資料框架或矩陣
解決方案
確保 RData 檔案只包含單一資料框架或矩陣。
  1. 可使用 RStudio 中的 str() 函數來完成此操作。例如:
    > str(mydata)
    Classes ‘tbl_df’ and 'data.frame':    8 obs. of  9 variables:
    (--- lines of data ---)
    • 注意上面的 RData 檔案包含額外「tbl_df」類的方式。此檔案將在 Tableau Desktop 中生成上述錯誤消息。
  2. 若要僅從上面的檔案中擷取資料框架,請使用 as.data.frame() 函數。例如:
    > TEMP <- as.data.frame(mydata)
  3. 現在,如果我們在 TEMP 使用 str(),則會得到以下輸出:
    > str(TEMP)
    'data.frame':    8 obs. of  9 variables:
    (--- lines of data ---)
  4. 我們可以將擷取的資料框架保存到一個新的 RData 檔案:
    > save(TEMP,file = "mydataNEW.rda")
  5. 現在 mydataNEW.rda 只包含資料框架對象,它應該能在 Tableau Desktop 中成功載入。
知識文章編號

001498351

 
正在載入
Salesforce Help | Article