2016-11-03 74 views
0

使用XLConnect我想讀的使用R.我安裝了XLConnect包,收到以下錯誤我的硬盤.xls或.xlsx文件.xlsx文件:如何閱讀中的R

Data <- readWorksheet(loadWorkbook("C:/test1.xlsx"),sheet=1) 
Error: FileNotFoundException (Java): File 'test1.xlsx' could not be found - you may specify to automatically create the file if not existing. 

我想閱讀我的Excel文件的第一個標籤。我也嘗試了gdata read.xls函數並失敗。

+3

看起來像您指定給該文件的路徑不正確。我會加倍(和三倍)檢查。 (也許嘗試反斜槓而不是正斜槓?) – joran

+0

您也可以查看'readxl'和'openxlsx',它們不需要Java。 – alistaire

+0

錯誤的路徑...關閉爲錯字。 –

回答

0

嘗試在調用xlsx文件之前定義您的工作目錄。所以在調用文件之前使用函數setwd。例如:

setwd("the location where the file is placed on your pc") 
Data <- readWorksheet(loadWorkbook("C:/test1.xlsx"),sheet=1) 

注意:請確保在setwd函數中使用正斜槓而不是反斜槓。