如何正确地从 R 中的 pdf 接收文本?
How to receive text from pdf in R properly?
我想在 R 中嵌入自己的词。我尝试打开并接收来自 pdf 的文本,但它给了我这个错误: normalizePath(path.expand(path), winslash, mustWork) 错误:
路径[1]="goethe_faust.pdf": 未找到文件
奇怪的是这个文件存在,我可以用任何 pdf 打开它 reader。它不是密码锁定或类似的东西。
我的代码:
library(pdftools)
file_vector <- list.files(path = "pdf_collections")
pdf_text <- pdf_text(file_vector[1])
默认情况下 list.files
只包含文件名。要打开这些文件,您需要包含您的路径 (pdf_collections)。您可以通过指定您想要文件的完整路径来解决此问题。
file_vector <- list.files(path = "pdf_collections", full.names=TRUE)
我想在 R 中嵌入自己的词。我尝试打开并接收来自 pdf 的文本,但它给了我这个错误: normalizePath(path.expand(path), winslash, mustWork) 错误: 路径[1]="goethe_faust.pdf": 未找到文件
奇怪的是这个文件存在,我可以用任何 pdf 打开它 reader。它不是密码锁定或类似的东西。 我的代码:
library(pdftools)
file_vector <- list.files(path = "pdf_collections")
pdf_text <- pdf_text(file_vector[1])
默认情况下 list.files
只包含文件名。要打开这些文件,您需要包含您的路径 (pdf_collections)。您可以通过指定您想要文件的完整路径来解决此问题。
file_vector <- list.files(path = "pdf_collections", full.names=TRUE)