R: the argument matches several formal arguments

I tried to read data from an excel file that contains several distribution sheets.

setwd("C:/Users/XXX/XXX") getwd() rm(list=ls()) require(xlsx) df =read.xlsx("data.csv",sheet=3, colNames = TRUE) 

As soon as I run this code, it always returns with this error message:

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

I do not know what to do. Please help, thanks.

+6
source share
1 answer

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 a sheetIndex argument:

 df =read.xlsx("data.csv",sheetIndex=3, colNames = TRUE) 
+6
source

Source: https://habr.com/ru/post/988952/


All Articles