How to read in multiple “.xlsx” files to R

前端 未结 1 814
谎友^
谎友^ 2020-12-12 06:13

Having trouble trying to read in multiple .xlsx files to R from the same directory. I keep getting the following error.

\"Error in path.expand(file) :

相关标签:
1条回答
  • 2020-12-12 06:28

    You want to merge all Excel files in a folder?

    library(xlsx)
    setwd("C:/Users/rshuell001/Desktop/excel_files")
    data.files = list.files(pattern = "*.xlsx")
    data <- lapply(data.files, function(x) read.xlsx(x, sheetIndex = 1))
    
    for (i in data.files) {
        data <- rbind(data, read.xlsx(i, sheetIndex = 1))
    }
    
    0 讨论(0)
提交回复
热议问题