I have a number of pdf files (these are "scanned") in a folder ( "C:/Users/Documents/files_i_want"
). All the pdf files have different names. I am trying to import them all into R at the same time, by using the following command: pdftools::pdf_convert
library(pdftools)
library(tesseract)
#Get the path of filenames
filenames <- list.files("C:/Users/Documents/files_i_want", full.names = TRUE)
#Read them in a list
list_data <- lapply(filenames, pdftools::pdf_convert)
#Name them as per your choice (df_1, df_2 etc)
names(list_data) <- paste('df', seq_along(filenames), sep = '_')
#Create objects in global environment.
list2env(list_data, .GlobalEnv)
This returns the following error:
Error in names(list_data) <- paste("df", seq_along(filenames), sep = "_") :
'names' attribute [1] must be the same length as the vector [0]
Does anyone know why this error is being produced?
Thanks