jessicacardoso

word_cloud

Nov 23rd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 0.62 KB | None | 0 0
  1. '%nin%' <- Negate('%in%')
  2. library(tm)
  3. library(wordcloud2)
  4. library(dplyr)
  5. library(stringi)
  6.  
  7. docs <- Corpus(VectorSource(df$stripped_text))
  8. dtm <- TermDocumentMatrix(docs)
  9. freq <- slam::row_sums(dtm)
  10. #freq <- freq[order(-freq)]
  11. word <- names(freq)
  12. df <- data.frame(word,
  13.              freq,
  14.              row.names = NULL)
  15. my_stopwords <- c(stopwords('pt'),'vc','vcs','vlw','flw','ta','pra','q','n','ok','okay')
  16. my_stopwords <- stri_trans_general(my_stopwords, "Latin-ASCII") #remover acentuações
  17. FreqMat <- df %>%
  18.            filter(word %nin% my_stopwords) %>%
  19.            filter(freq > 50)
  20. wordcloud2(FreqMat)
Add Comment
Please, Sign In to add comment