[R] From for loop to lappy?

Ek Esawi e@@wiek @ending from gm@il@com
Tue Oct 2 00:32:33 CEST 2018


Hi All—

I am using Tabulizer to extract tables from PDF files. Tabulizer
creates a list of matrices for each set of tables in each document.
My code, below, works well. Then i thought i would use lapply instead
of for loop since it is a little faster and more compact,
but i kept getting an error message below.

Any help is greatly appreciated

EK

install.packages("tabulizer")
installed.packages("stringr")
library(stringi)
library(tabulizer)
path = "C:/Users/name/Documents/TextMining/"
file.names <- dir(path, pattern =".PDF")

for(i in 1:length(file.names)){
  print(file.names[i])
  A[[i]] <- extract_tables(file.names[i])
}


lapply(file.names, function(i) A[[i]] <- extract_tables(file.names[i]))

 Error in normalizePath(path.expand(path), winslash, mustWork) :
  path[1]="NA": The system cannot find the file specified



More information about the R-help mailing list