0

Having an option like this:

D <- readFiles("file (1).bib","file (2).bib","file (3).bib")

How is it possible to have a simple read for all. Something like this:

D <- readFiles("file (",1:3").bib")
Elr Mant
  • 507
  • 1
  • 4
  • 14
  • Have you read [this SO question](https://stackoverflow.com/questions/5758084/loop-in-r-to-read-many-files)? – Tim Biegeleisen Mar 09 '19 at 11:21
  • @TimBiegeleisen thank you for your suggestion. I tried this `test <- lapply(Sys.glob("file.*bib"), readFiles)` but it is not working – Elr Mant Mar 09 '19 at 11:33

1 Answers1

1

readFiles from the bibliometrix package is actually just a wrapper for readLines. But the way it is written does not play nicely with lapply, which makes it difficult to pass character objects with file names.

I would therefore simply stick with readLines:

library("bibliometrix")
files <- list.files(path = "path/to/your/bibfiles",
                    pattern = ".bib$",
                    recursive = TRUE,
                    full.names = TRUE)
D <- unlist(lapply(files, readLines, encoding = "UTF-8"))
JBGruber
  • 11,727
  • 1
  • 23
  • 45