Reputation: 443
I am learning R studio right now and I was just wondering how do I import an xlsx file with multiple sheets (8 sheets).
So far.. I have:
library(readxl)
(filename) <- read_excel("(file location).xlsx")
view(filename)
It prints out only the first sheet of the excel file, but I would appreciate it if it printed out all of them.
Also, is it better to use CSV files or xlsx?
thanks, guys.
Upvotes: 2
Views: 9300
Reputation: 27792
This will work for all sheets in the workbook
lapply(excel_sheets(path), read_excel, path = path)
read ?excel_sheets
Upvotes: 3
Reputation: 50738
You could do
lst <- lapply(1:8, function(i) read_excel("file_name.xlsx", sheet = i))
This will store all 8 sheets in a list
of data.frame
s.
Upvotes: 11