Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R: argument matches multiple formal arguments

Tags:

r

excel

I tried to read-in data from a excel file which contains multiple spread sheets.

    setwd("C:/Users/XXX/XXX")
    getwd()
    rm(list=ls())

    require(xlsx)
    df =read.xlsx("data.csv",sheet=3, colNames = TRUE)

once I run this code, it always come back with this error message :

    Error in read.xlsx("dt.csv", sheet = 3,  :argument 2 matches multiple formal arguments

I don't know what to do. Please help, thanks.

like image 979
Jfang Avatar asked Jun 11 '15 20:06

Jfang


1 Answers

The two arguments to the read.xlsx method that match sheet are sheetIndex and sheetName, according to the signature:

read.xlsx(file, sheetIndex, sheetName=NULL, rowIndex=NULL,
  startRow=NULL, endRow=NULL, colIndex=NULL,
  as.data.frame=TRUE, header=TRUE, colClasses=NA,
  keepFormulas=FALSE, encoding="unknown", ...)

You need the sheetIndex argument:

df =read.xlsx("data.csv",sheetIndex=3, colNames = TRUE)
like image 103
Ishamael Avatar answered Sep 22 '22 11:09

Ishamael