2

I have 2 tables, Table_1 and Table_2, on one sheet (sheet_5) in my excel workbook myWorkbook.xlsx. I know there are plenty of packages that allow you to specify which sheet to load in, but is there a way to load in only the table(s) you want? In this case, I want to load Table_2 only.

Thanks

heyydrien
  • 971
  • 1
  • 11
  • 28

1 Answers1

3

The most recent version of readxl has the ability to set the range. IMHO this is BY FAR the best excel read in package for R.

See the part of this post entitled "Specifying the data rectangle": https://blog.rstudio.org/2017/04/19/readxl-1-0-0/

the syntax should be very familiar to an excel user.

Also please see this post for asking questions on SO: How to make a great R reproducible example?

Community
  • 1
  • 1
boshek
  • 4,100
  • 1
  • 31
  • 55
  • I went through the blog post, but I was not able to find any references to load Excel-Tables in a worksheet. By Excel-Table, I am referring to the "structures" we get by clicking Insert > Table; or what are called List Objects in the Excel-VBA World. Is there a way to refer to tables in readxl? – Ejaz Ahmed Nov 26 '19 at 19:43
  • Hmm... seems like you are wanting to work exclusively in Excel. This is a question about R. – boshek Nov 28 '19 at 18:47
  • I have an Excel workbook which hosts all the dimensions tables of my data model. There are multiple tables in a single sheet. I was looking for an easy way to import all excel tables in a workbook into R. – Ejaz Ahmed Dec 01 '19 at 05:04
  • 1
    So your options here are to use a better data structure (i.e. one table per sheet) or use the `range` argument in `readxl::read_excel`. – boshek Dec 02 '19 at 19:08
  • I see. Thank you! – Ejaz Ahmed Dec 02 '19 at 19:08