Based on the question below, I have a follow up question in reference to the following two similar solutions. What if the headers in the sheets are the same and you don't want the headers to be repeated as rows from sheet 2 and so on?
Purpose: Combining all sheets into one dataframe.
I am guessing one will have to match the headers from sheet 2 and so on with the headers of the first sheet and remove them if found.
I guess the most straight forward way would be to delete the header rows from sheet 2 and so on before before importing them into R
.
Read all worksheets in an Excel workbook into an R list with data.frames
Solutions for combining sheets:
library(readxl)
library(purrr)
library(pacman)
# Solution 1 for all in one df
final_df = bind_rows(path %>%
excel_sheets() %>%
set_names() %>%
map(read_excel, path = path))
# Solution 2 to concatenate
data = path %>%
excel_sheets() %>%
set_names() %>%
map_df(~ read_excel(path = path, sheet = .x), .id = "Sheet")