0

I would like to extract specific cells from multiple excel files in a folder.

Taking the xlxs sample file here as an example, I would like to extract cell C10 as row header, rows A18:A22 as column headers and the values J18:J22 and L18:L22.

library("readxl")

file.list <- list.files(path=".", pattern=".xlsx")

df.list <- lapply(file.list, read_excel, sheet=1, range=("L18:L22"), col_names=FALSE, col_types = NULL)
df <- data.frame(df.list)
Jane
  • 385
  • 4
  • 11
  • You could use `Map()` or `mapply()` and supply several parameters as arguments to an anonymous function. Also, people will be more able to help if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Andrew Oct 01 '20 at 11:36
  • @Andrew possible to show how should I amend the code? I’m quite new to map and mapply – Jane Oct 01 '20 at 12:39
  • Something like this `Map(function(x, y, z) read_excel(x, sheet = y, range = z), file_paths, sheets_for_files, ranges_for_files)`. If you post a small example I would be happy to help. E.g., using `datasets::mtcars` or an analog. – Andrew Oct 01 '20 at 17:24
  • @Andrew Hi, I have edited with a small example. Hopefully you could help, much appreciated! – Jane Oct 02 '20 at 00:07

0 Answers0