简体   繁体   中英

Error on XLConnect::readWorksheet function

I have a line of R code that is giving me an error. 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. Naturally sheet.variaveis holds the name of the worksheet that I need. The file is saved as 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

R version: 3.2.3

RStudio version: 0.99.473

Java version: 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. 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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