我想将所有工作表从Excel文件(第一个除外)导入到R.现在所有数据框都位于列表中,我希望它们作为单独的数据帧,但不知道如何要做到这一点。一个for循环可能吗?
# read rawdatabase in Excel file and create list with a dataframe for each sheet
library(magrittr)
library(dplyr)
library(readxl)
workbook <- "rawdata.xlsx"
# Because I don't want the first sheet
noReadme <- "README"
sheets <- excel_sheets(workbook) %>% setdiff(noReadme)
# Create list with all the remaining dataframes
l <- lapply(sheets, function(v) read_excel(workbook, sheet = v))
# Give each dataframe the proper name
names(l) <- sheets
我希望它尽可能地动态,以便我将此脚本与其他具有更多或更少工作表的excel文件一起使用。