Hi everyone!
I'm trying to read in multiple files from multiple folders based on a pattern by writing my own function for it. The function takes two arguments: the folder path and an "id" string variable that is on each file in the folder.
I think the issue is with the id argument and how to read the string that I would pass in as the id into the subsequent pattern and sub function.
Any insight would be extremely helpful! Thanks.
read_docs <- function (path, id) {
file_list <- c(list.files(path, pattern = "./id/.\.pdf",
all.files = FALSE, full.names = TRUE, recursive = FALSE,
ignore.case = TRUE, include.dirs = FALSE, no.. = FALSE)
for (i in file_list) {
name <- sub(".*'id' - (.?) -.", "\1", i)
assign(name, pdf_text(i))
}
}