> library(tm)
> library(wordcloud)
Loading required package: RColorBrewer
> wordcloud (c (letters, LETTERS, 0:9), seq (1, 1000, length.out = 80))
> data (crude)
> wordcloud (crude)
> load ("tdm.rdata")
> inspect (tdm)
<<TermDocumentMatrix (terms: 395, documents: 5)>>
Non-/sparse entries: 508/1467
Sparsity           : 74%
Maximal term length: 17
Weighting          : term frequency (tf)
Sample             :
          Docs
Terms      1 2 3 4 5
  artifici 2 0 1 0 2
  becom    0 3 2 1 0
  expert   0 1 1 3 1
  human    2 3 3 1 2
  intellig 2 1 3 1 3
  mani     1 1 0 4 1
  might    0 3 3 0 0
  research 1 1 1 3 0
  system   0 5 2 0 0
  task     3 2 1 0 0
> frq <- rowSums (as.matrix (tdm))
> wt <- data.frame (word = names(frq), freq = frq)
> head (wt)
               word freq
agi             agi    2
algorithm algorithm    1
anyth         anyth    2
artifici   artifici    5
autonom     autonom    3
can             can    3
> wordcloud (words = wt$word, freq = wt$freq)
> wordcloud (words = wt$word, freq = wt$freq, min.freq = 2, max.words = 60)
> wordcloud (words = wt$word, freq = wt$freq, min.freq = 2, max.words = 60, random.order = TRUE)
> wordcloud (words = wt$word, freq = wt$freq, min.freq = 2, max.words = 60, random.order = FALSE)
> wordcloud (words = wt$word, freq = wt$freq, min.freq = 2, max.words = 60, random.order = FALSE, colors = "gold")
> wordcloud (words = wt$word, freq = wt$freq, min.freq = 2, max.words = 60, random.order = FALSE, colors = c ("gold", "red", "blue")
+ )
> wordcloud (words = wt$word, freq = wt$freq, min.freq = 2, max.words = 60, random.order = FALSE, colors = c ("gold", "red", "blue"), random.color = TRUE)
> ??RColorBrewer
starting httpd help server ... done
> wordcloud (words = wt$word, freq = wt$freq, min.freq = 2, max.words = 60, random.order = FALSE, colors = brewer.pal (8, "Accent"))
> wordcloud (words = wt$word, freq = wt$freq, min.freq = 2, max.words = 60, random.order = FALSE, colors = brewer.pal (9, "Set1"))
> comparison.cloud (as.matrix (tdm), max.words = 60, colors = brewer.pal (9, "Set1"))
There were 24 warnings (use warnings() to see them)
> comparison.cloud (as.matrix (tdm),colors = brewer.pal (9, "Set1"))
There were 50 or more warnings (use warnings() to see the first 50)
> 
