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.
xwithhead(x)or better adput? - NelsonGontmpackage the column names must bedoc_idandtext. What is the column name of thetextpart? Try alsoVCorpus(DataframeSource(x)). Check out this answer: stackoverflow.com/questions/47406555/… which seems to have the same problem as you face. - user113156dputof a representative sample of the data. One row isn't enough to test out your code on. See here on making an R post folks can more easily help with. - camille