I want to import all the worksheets from an Excel file (except the first one) into R. Right now all the dataframes are sitting inside a list and I want them out as individual dataframes, but don't know how to do that. A for loop maybe?
# 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
I want this to be as dynamic as possible, so that I re-use this script with other excel files with more or less sheets.