I'm trying to in put multiple sheets of excel using for loop in R and do some impuations. The code which i have written is below,
sheet <- getSheetNames("market_latest.xlsx")
for (i in 2:length(sheet)-1){
data[i] <- read.xlsx("market_latest.xlsx",sheet = sheet[i],fillMergedCells = TRUE)
col[i] <- colnames(data[i])
colnames(data[i]) <- as.character(unlist(data[i][1,]))
col[i+1] <- colnames(data[i])
colnames(data[i]) <- as.character(unlist(data[i][1,]))
data[i] <- data[i][, !duplicated(colnames(data[i]))]
write.xlsx(data[i],file="sampleop.xlsx",sheetName="Sheet1",
col.names=TRUE, row.names=FALSE, append=FALSE)
}
The imputation part is working so i have no problem with it. But when i ran the code its throwing me warnings but no output. I want to use 2 sheet to n-1 sheet of excel, please do let me know where im wrong. The error pic is added below. enter image description here