I keep getting this error when trying to import a csv document into R and trying to develop a corpus for topic modeling. I have used this approach successfully on 4 other projects but cannot get past this error. My data source has a doc_id column and a text column. Error is Error:
all(!is.na(match(c("doc_id", "text"), names(x)))) is not TRUE
I tried importing using a a number of different suggestions such as Error faced while using TM package's VCorpus in R
file_loc <- "C:\\Users\\mdlawrence\\Desktop\\Test2.csv "
x <- read.csv(file_loc, header = TRUE, stringsAsFactors = F)
require(tm)
Loading required package: tm
Loading required package: NLP
corp <- Corpus(DataframeSource(x))
Error: all(!is.na(match(c("doc_id", "text"), names(x)))) is not TRUE
docs <- DocumentTermMatrix(corp)
Error in TermDocumentMatrix(x, control) : object 'corp' not found
I expect to see a corpus with one document per row in the .csv file. Any suggestions are greatly appreciated.