Elr Mant
Elr Mant

Reputation: 527

How to read multiple files with one read option

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")

Upvotes: 0

Views: 81

Answers (1)

JBGruber
JBGruber

Reputation: 12470

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"))

Upvotes: 1

Related Questions