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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With