Loading...
 
Skip to main content

History: Profile_r_test5_wordcloud

Preview of version: 6

Testing some nice graphs from R through Pluginr in Tiki.

Word-cloud art from mods.t.o


Copy to clipboard
{RR(loadandsave="1", wikisyntax="0")} # Includes a word cloud with the description of the packages from http://mods.tiki.org # Example adapted from the ones shown here: http://www.r-bloggers.com/word-cloud-in-r/ if(!require(XML)){ install.packages("XML", lib="/usr/lib/R/site-library", repos="http://ftp.heanet.ie/mirrors/cran.r-project.org/") } if(!require(tm)){ install.packages("tm", lib="/usr/lib/R/site-library", repos="http://ftp.heanet.ie/mirrors/cran.r-project.org/") } if(!require(wordcloud)){ install.packages("wordcloud", lib="/usr/lib/R/site-library", repos="http://ftp.heanet.ie/mirrors/cran.r-project.org/") } if(!require(RColorBrewer)){ install.packages("RColorBrewer", lib="/usr/lib/R/site-library", repos="http://ftp.heanet.ie/mirrors/cran.r-project.org/") } require(XML) require(tm) require(wordcloud) require(RColorBrewer) u2 = "http://mods.tiki.org/" t2 = readHTMLTable(u2) ap.corpus2 <- Corpus(DataframeSource(data.frame(t2[[1]][6]))) ap.corpus2 <- tm_map(ap.corpus2, removePunctuation) ap.corpus2 <- tm_map(ap.corpus2, tolower) ap.corpus2 <- tm_map(ap.corpus2, function(x) removeWords(x, stopwords("english"))) ap.tdm2 <- TermDocumentMatrix(ap.corpus2) ap.m2 <- as.matrix(ap.tdm2) ap.v2 <- sort(rowSums(ap.m2),decreasing=TRUE) ap.d2 <- data.frame(word = names(ap.v2),freq=ap.v2) #table(ap.d2$freq) pal2 <- brewer.pal(8,"Dark2") #png("wordcloud_packages.png", width=1280,height=800) wordcloud(ap.d2$word,ap.d2$freq, scale=c(8,.2),min.freq=3, max.words=Inf, random.order=FALSE, rot.per=.15, colors=pal2) #dev.off() {RR}


Produces:

 Plugin disabled
Plugin rr cannot be executed.


And once everything is ready in your system (all packages installed, etc), you'll see something like this:

Image

History

Information Version
Sat 21 of Nov, 2015 21:40 GMT-0000 Xavier de Pedro cleared the initial description of the source of that code 10
Sat 21 of Nov, 2015 21:38 GMT-0000 Xavier de Pedro adapted to a working example which is simpler in code reusing an external function 9
Sat 21 of Nov, 2015 20:21 GMT-0000 Xavier de Pedro new example and function 8
Fri 31 of May, 2013 10:04 GMT-0000 Xavier de Pedro added echo param 7
Tue 10 of Jul, 2012 14:52 GMT-0000 Xavier de Pedro remove obsolete info line 6
Tue 10 of Jul, 2012 14:51 GMT-0000 Xavier de Pedro added check for preinstalled package 5
Sat 13 of Aug, 2011 18:59 GMT-0000 Xavier de Pedro better without setting the lib location 4
Sat 13 of Aug, 2011 18:19 GMT-0000 Xavier de Pedro added url and path for easier installation of required packages 3
Thu 04 of Aug, 2011 16:29 GMT-0000 Xavier de Pedro typo 2
Thu 04 of Aug, 2011 16:28 GMT-0000 Xavier de Pedro new info 1