PubMed Word Cloud

from http://rpubs.com/Felix/8567

install necessary packages and dependencies

# install.packages('PubMedWordcloud')
# source('http://www.bioconductor.org/biocLite.R') biocLite('limma')

Load library

library("PubMedWordcloud")
library("RColorBrewer")

define author, get PMIDs based on author

author <- "odisho a"
pmid <- getPMIDs(author = author, dFrom = 1900, dTo = 2013, n = 200)

Download abstracts based on PMID and clean them using tm() package (text mining, removes punctuation, numbers, makes all chars lower case, removes stop words, stem words, etc

abstracts <- getAbstracts(pmid)
words <- cleanAbstracts(abstracts)
words <- words[!words$word == "patients", ]
words400 <- words[1:400, ]

Start Plotting!

pmWordCloud(words[], rot.per = 0, colors = brewer.pal(9, "Set1"), scale = 0.5)

plot of chunk unnamed-chunk-5

pmWordCloud(words400[], colors = brewer.pal(9, "Set1"), scale = 0.5)

plot of chunk unnamed-chunk-5

pmWordCloud(words400[], rot.per = 0, colors = brewer.pal(9, "Set1"), scale = 0.5)  #no rotation

plot of chunk unnamed-chunk-5