0

originally, list.files works with the document name. I would like to use the worksheet [1] name to create a dataframe.

So, I set my directory and this code works fine, but it returns a df using the document names instead of the worksheet [1] names.

files_listed<-list.files(path=".", full.names=FALSE, pattern="*xlsx",recursive=FALSE)

files_listed<-list.files(path=".", full.names=FALSE, pattern="*xlsx",recursive=FALSE)

For example, each document has a name, but the worksheets are an abbreviation from that name. (document name is income, sheet name is INC) and each sheet has multiple columns.

jogo
  • 12,469
  • 11
  • 37
  • 42
  • Possible duplicate of [How to extract sheet names from Excel file in R](https://stackoverflow.com/questions/17944777/how-to-extract-sheet-names-from-excel-file-in-r) – walnut Aug 28 '19 at 09:02
  • `list.files` lists the files in a given file system path, it is not specific to Excel documents. I assume you want to extract the Excel sheet names from these files? If so, see the linked duplicate. – walnut Aug 28 '19 at 09:03
  • does that also work with multiple files? – Lieke Oltheten Aug 28 '19 at 09:13
  • That's what loops or `apply` are for. Loop over the values returned by `list.files` and obtain the worksheet names of each. – walnut Aug 28 '19 at 09:16

0 Answers0