简体   繁体   English

XLConnect :: readWorksheet函数上的错误

[英]Error on XLConnect::readWorksheet function

I have a line of R code that is giving me an error. 我有一行R代码给我一个错误。 The line of code is: 代码行是:

var <- readWorksheet(paste(dir.censo, arq.variaveis, sep="/"), sheet = sheet.variaveis)

where dir.censo holds the directory path of the excel workbook and arq.variaveis is the name of the variable holding the file name. 其中dir.censo保存excel工作簿的目录路径,而arq.variaveis是保存文件名的变量的名称。 Naturally sheet.variaveis holds the name of the worksheet that I need. 自然, sheet.variaveis拥有我需要的工作表的名称。 The file is saved as XLSX. 该文件另存为XLSX。 Here is the error: 这是错误:

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘readWorksheet’ for signature ‘"character", "character"’

I searched that error online, but nothing showed up. 我在线搜索了该错误,但未显示任何错误。 If you could help me resolve this problem, I'd greatly appreciate it. 如果您可以帮助我解决此问题,我们将不胜感激。 Some system information in case you need them: 一些系统信息,以备您需要时使用:

Operating system: Windows 10 作业系统:Windows 10

R version: 3.2.3 R版本:3.2.3

RStudio version: 0.99.473 RStudio版本:0.99.473

Java version: 8.0_66 Java版本:8.0_66

Again, thanks a lot. 再次,非常感谢。

I just figured out how to resolve this issue. 我只是想出了解决该问题的方法。 I'm just posting the answer here in case someone else runs into this problemj, so their search wouldn't be fruitless. 我只是在这里发布答案,以防其他人遇到此问题j,因此他们的搜索并非没有结果。 I replaced that line of code above with the following two lines: 我用以下两行替换了上面的代码行:

wb <- loadWorkbook(file.path(dir.censo, arq.variaveis))
variaveis <- readWorksheet(wb, sheet = sheet.variaveis)

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

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