2

I'm not founding any argument in the fread() function to let me select the sheet I want.
I'm trying this:

tab <- data.table::fread('myfile.xlsx')

As my file has many sheets, how can I select just one of them by sheet name?

igorkf
  • 3,159
  • 2
  • 22
  • 31

1 Answers1

2
 library("readxl")
 FirstTable  <- read_excel("locations.xlsx", 1) # for first tab
 SecondTable <- read_excel("locations.xlsx", 4) # for fourth tab

An alternative way!

You may find this link useful - importing excel to r

bp41
  • 137
  • 13
  • 4
    As far as I, and the Internet knows, `fread` can't read Excel files. https://stackoverflow.com/questions/48313025/how-to-load-xlsx-file-using-fread-function – Andrew Chisholm Jun 04 '20 at 20:29
  • This is strange, because I can read the xlsx file with `fread()`, however I can't select which sheet I want to use. – igorkf Jun 04 '20 at 22:46
  • @igorkf can you please upload your xlsx for a test? Because nobody else is able to load an xlsx file aside from you. So we can test it ourselves. – Herman Toothrot Mar 11 '21 at 11:03
  • Sorry, there was a long time ago and I cant reproduce it anymore – igorkf Mar 11 '21 at 12:21