0

I have tried to run the script of loop that opens every one of the files and adds them to the blank data frame.

fileNames <- list.files(pattern=".xlsm", recursive = TRUE)
fileNumbers <- seq(fileNames)

excel.data <- read_excel(fileNames[fileNumber], 
                      skip=1, 
                      col_names = T,
                      sheet = "Output")`

It is a part of loop:

for (fileNumber in fileNumbers){  
  tryCatch({
    # read in the data from excel. 
    excel.data <- read_excel(fileNames[fileNumber], 
                      skip=1, 
                      col_names = T,
                      sheet = "Output")........}).

Loops run correct but gives blank column for the excel combined to new data frame. When i try to run individual subscript as above, it says "Error: path must be a string" in console.

benson23
  • 16,369
  • 9
  • 19
  • 38
  • What exactly is stored in `fileNames` and `fileNumber`. Without knowing the exact contents of those variables, it's not really possible to say what's happening. It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Feb 04 '22 at 07:02
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 12 '22 at 12:21

0 Answers0