I have around 30 excel files in my folder.
I am interested in reading them all.
I used this code below
library(readxl) file.list <- list.files(pattern='*.xlsx') df.list <- lapply(file.list, read_excel)
The problem is each excel file has multiple sheets and I am interested in the contents of only one sheet , sheetName = “Piano”, not interested in the contents of other sheets.
So how can I ensure that in addition to reading all the 30 excel files r reads only data from sheetName=”Piano” from all these excel files. Thanks.
We can make use of the
sheet argument of
read_excel. According to
sheet – Sheet to read. Either a string (the name of a sheet), or an integer (the position of the sheet). Ignored if the sheet is specified via range. If neither argument specifies the sheet, defaults to the first sheet.
library(dplyr) library(readxl) df.list <- map(file.list, read_excel, sheet = 'Piano')