У меня есть 829 txt файла с экономическими новостными сводками, каждый назван по дате выхода новости, например 2014.05.16. Создаю из документов корпус,пытаюсь строить облако слов, но получаю ошибку: "Error in UseMethod("meta", x) : no applicable method for 'meta' applied to an object of class "character""
Подскажите, пожалуйста, в чем может быть дело?
# Create df with texts
files <- dir()
df_texts <- data.frame(matrix(ncol = 1, nrow = length(files)))
colnames(df_texts) <- "contents"
#colnames(df_texts) <- c("name","contents")
#df_texts$name <- files
# Read files to df
df_texts$contents <- unlist(lapply(files, function(x) read_file(x,
locale = locale(encoding = "CP1251"))))
# Get corpus
txts<-Corpus(DataframeSource(df_texts),
readerControl=list(language="ru"))
inspect(txts[1])
txts<-tm_map(txts, tolower)
txts<-tm_map(txts, removeWords, stopwords("ru"))
txts<-tm_map(txts, removePunctuation)
txts<-tm_map(txts, removeNumbers)
txts<-tm_map(txts, stripWhitespace)
txts<-tm_map(txts, removeWords, c("что", "мочь","составлять", "индекс",
"(анга)", "торги"))
#plot wordcloud
library(wordcloud)
col=brewer.pal(6, "Dark2")
wordcloud(txts, min.freq = 10, scale=c(9,4), rot.per = 0.5,random.color
= 1, max.words = 45, random.order = F, colors = col)
content_transformer
:txts<-tm_map(txts, content_transformer(tolower))
. Возможно, и в некоторых других местах следует к нему прибегнуть.