Home > Back-end >  Facing an issue with R, DataframeSource error
Facing an issue with R, DataframeSource error

Time:10-25

I have just started learning R and I am facing an issue. i have already managed to load my dataframe into "txt", also have installed tm, sentimentr and SnowballC packages but when I run this programme, The error message is Error in DataframeSource(txt) : all(!is.na(match(c("doc_id", "text"), names(x)))) is not TRUE*

the code is

#setting df as working file

txt = read.csv("xxx.csv")

#creating corpus for data frame

comments_corpus= VCorpus(DataframeSource(txt))

comments = comments_corpus

comments = tm_map(comments, content_transformer(tolower))

comments = tm_map(comments, removePunctuation)

comments = tm_map(comments, removeNumbers)

CodePudding user response:

DataframeSource(x) expects the first column in x to be named "doc_id" and contain a unique string identifier. It looks like that's not the case in your txt file, which gets passed to DataframeSource

  • Related