如何在TermDocumentmatrix中显示文档名称(PDF)

如何在TermDocumentmatrix中显示文档名称(PDF),r,pdf,R,Pdf,检查my Term DocumentMatrix时,列标题显示为数字,而不是(PDF的)文件名 以下是我迄今为止的步骤: setwd("E:/OneDrive/Thesis/Received comments document/Consultation 14") getwd() library(pdftools) files <- list.files(pattern = "pdf$") comments <- lapply(files, pdf_text) corp <- C

检查my Term DocumentMatrix时,列标题显示为数字,而不是(PDF的)文件名

以下是我迄今为止的步骤:

setwd("E:/OneDrive/Thesis/Received comments document/Consultation 14")
getwd()
library(pdftools)
files <- list.files(pattern = "pdf$")
comments <- lapply(files, pdf_text)
corp <- Corpus(VectorSource(comments))
Comments.tdm <- TermDocumentMatrix(corp, control = list(removePunctuation = TRUE,
    stopwords = TRUE,
    tolower = TRUE,
    stemming = TRUE,
    removeNumbers = TRUE,
bounds = list(global = c(3, Inf)))`) 

inspect(Comments.tdm[1:11,])

如何确保列标题显示PDF的文件名?

也许
corp Instant win!这立刻就成功了。感谢您的快速响应和简单的解决方案,三年多后仍然有效:)谢谢@lukeA
setwd("E:/OneDrive/Thesis/Received comments document/Consultation 14")
getwd()
library(pdftools)
files <- list.files(pattern = "pdf$")
comments <- lapply(files, pdf_text)
corp <- Corpus(VectorSource(comments))
Comments.tdm <- TermDocumentMatrix(corp, control = list(removePunctuation = TRUE,
    stopwords = TRUE,
    tolower = TRUE,
    stemming = TRUE,
    removeNumbers = TRUE,
bounds = list(global = c(3, Inf)))`) 

inspect(Comments.tdm[1:11,])
meta(corp[[1]], tag = "id") <- files[1]
**Error in `[.data.frame`(x$dmeta, tag) : undefined columns selected**