Reputation: 125
I tried to import an Excelfile with many sheets to R using this code (using rio
package):
data_list <- import_list("x.xlsx")
it worked well but when I checked the number of sheets imported I discoverd an extra sheet by the name RAW
How can I import the sheets without getting this extra not needed data frame?
Upvotes: 1
Views: 308
Reputation: 27732
Not sure why you get the RAW
, but I suggest using the readxl
-package for reading excel-files to R.
library( readxl )
#get sheetnames of file
sheetnames <- readxl::excel_sheets( "./temp.xlsx" )
#loop over sheetname and read contenst, add to list
l <- lapply( sheetnames, function(x) readxl::read_excel( "./temp.xlsx", sheet = x ) )
#add sheetnames as names
names( l ) <- sheetnames
For binding together of l
, I suggest data.table::rbindlist()
. Make sure to set the use.names
-, fill
-, and idcol
-argument to your needs.
Upvotes: 2