Создать тепловую карту для результатов findAssocs на основе времени - PullRequest
0 голосов
/ 18 ноября 2018

У меня есть следующие данные, для которых я сначала создаю матрицу термина документа, а затем добавляю переменную времени в DTM.Чтобы увидеть корреляции с термином «обновление» в разные годы, я хотел бы иметь тепловую карту для findAssoc таким образом, чтобы ось X показывала время.

library(tm) 
library(ggplot2)

df <- structure(list(Description = structure(c(5L, 8L, 6L, 4L, 1L,
2L, 7L, 9L, 10L, 3L), .Label = c("general topics done", "keep the general topics updated",
 "rejected topic ", "several topics in hand", "this is a genetal topic",
 "topic 333555 needs to be updated", "topic 5647 is handed over",
 "topic is updated", "update the topic ", "updating the topic is done "
  ), class = "factor")), class = "data.frame", row.names = c(NA,
  -10L))
corpus=Corpus(VectorSource(df$Description))
corpus=tm_map(corpus,tolower)
corpus=tm_map(corpus,removePunctuation)
corpus=tm_map(corpus,removeWords,c(stopwords("english")))
corpus=tm_map(corpus,stemDocument,"english")

frequenciescontrol=DocumentTermMatrix(corpus)
frequenciescontrol$time=c("2015","2015","2015","2015","2015","2016","2016","2016","2016","2016")
findAssocs(frequenciescontrol, "updat", 0.01)

Итак, я хочу тепловую карту с осью y, показывающей слова, связанные с «updat», и осью x, показывающей годы.

...