调用read.xlsx时出错

时间:2016-04-13 20:37:13

标签: r

我正在尝试使用R,

读取excel文件
download.file("https://data.baltimorecity.gov/api/views/dz54-2aru/rows.xls?accessType=DOWNLOAD","test2.xls")
cameraData <- read.xlsx("test2.xls", sheetIndex = 1)

但是我收到以下错误:

Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :java.io.IOException: block[ 0 ] already removed - does your POIFS have circular or duplicate block references?

所有必需的包都成功解压缩(rJava,xlsxjars,xlsx)

R版:

R version 3.2.4 (2016-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Java版:

java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)

感谢您的帮助。

2 个答案:

答案 0 :(得分:0)

问题是download.file调用中缺少参数: 模式=&#34; WB&#34;

所以,请致电

download.file("https://data.baltimorecity.gov/api/views/dz54-2aru/rows.xls?accessType=DOWNLOAD","test2.xls", mode="wb")

会起作用。

答案 1 :(得分:0)

检查sessionInfo()以确保加载库(xlsx)。文件已下载并保存到工作目录。在Open Office中打开并在r会话中正常加载。 HTH