<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/quick-wordclouds-from-pubmed-abstracts-using-pmid-lists-in-r/"></div></div><div><a data-url="https://www.r-bloggers.com/quick-wordclouds-from-pubmed-abstracts-using-pmid-lists-in-r/" data-counturl="https://www.r-bloggers.com/quick-wordclouds-from-pubmed-abstracts-using-pmid-lists-in-r/" data-count="horizontal" data-text="Quick wordclouds from PubMed abstracts – using PMID lists in R" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://talesofr.wordpress.com/2016/09/26/quick-wordclouds-from-pubmed-abstracts-using-pmid-lists-in-r/"> R – Tales of R</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Wordclouds are one of the most visually straightforward, compelling ways of displaying text info in a graph.</p>
<p>Of course, we have a lot of web <a target="_blank" href="http://www.techlearning.com/default.aspx?tabid=100&entryid=364">pages</a> (and even <a target="_blank" href="https://ictevangelist.com/top-six-apps-for-creating-word-clouds/">apps</a>) that, given an input text, will plot you some nice tagclouds. However, when you need reproducible results, or getting done complex tasks -like combined wordclouds from several files-, a programming environment may be the best option.</p>
<p>In R, there are (as always), several alternatives to get this done, such as <a target="_blank" href="https://logfc.wordpress.com/2014/11/05/tagcloud-creating-tag-word-clouds/">tagcloud</a> and <a target="_blank" href="https://cran.r-project.org/web/packages/wordcloud/wordcloud.pdf">wordcloud</a>.</p>
<p>For this script I used the following packages:</p>
<ul>
<li><span>“</span><a target="_blank" href="https://cran.r-project.org/web/packages/RCurl/RCurl.pdf">RCurl</a><span>” to retrieve a <strong>PMID list</strong>, stored in my GitHub account as a <strong><a target="_blank" href="https://gist.githubusercontent.com/aurora-mareviv/14e5837814a8d8d47c20/raw/90b198bae82154688dcd9a2596af798612e6619f/pmids.csv">.csv</a></strong> file.</span></li>
<li><span><span>“</span><a target="_blank" href="https://cran.r-project.org/web/packages/RefManageR/RefManageR.pdf">RefManageR</a><span>” and</span></span> <span><span>“</span><a target="_blank" href="https://cran.r-project.org/web/packages/plyr/plyr.pdf">plyr</a><span>“</span></span><span><span> to retrieve and arrange PM records. To fetch the info from the inets, we’ll be using the <a target="_blank" href="http://www.ncbi.nlm.nih.gov/home/develop/api.shtml">PubMed API</a> (free version, with some limitations). </span></span></li>
<li>Finally, <span><span>“</span><a target="_blank" href="https://cran.r-project.org/web/packages/tm/tm.pdf">tm</a><span>“</span></span>, <span><span>“</span><a target="_blank" href="https://cran.r-project.org/web/packages/SnowballC/SnowballC.pdf">SnowballC</a><span>” to prepare the data and <span>“</span><a target="_blank" href="https://cran.r-project.org/web/packages/wordcloud/wordcloud.pdf">wordcloud</a><span>” to plot the wordcloud. This part of the script is based on this from <a target="_blank" href="https://georeferenced.wordpress.com/2013/01/15/rwordcloud/">Georeferenced</a>.</span></span></span></li>
</ul>
<p>One of the advantages of using RefManageR is that you can easily change the field from which you are importing from, and it usually works flawlessly with the PubMed API.</p>
<p>My biggest problem sources when running this script… download caps, busy hours, and firewalls!.</p>
<p>At the beginning of the <a target="_blank" href="https://gist.github.com/aurora-mareviv/697cbb505189591648224ed640e70fb1">gist</a>, there is also a handy function that automagically downloads all needed packages for you.</p>
<p>To source the script, simply type in the R console:</p>
<pre>
library(devtools)
source_url(&quot;https://gist.githubusercontent.com/aurora-mareviv/697cbb505189591648224ed640e70fb1/raw/b42ac2e361ede770e118f217494d70c332a64ef8/pmid.tagcloud.R&quot;)
</pre>
<p>And there is the code:</p>
<p></p>
<p>Enjoy!</p>
<p><img alt="wordcloud" class="wp-image-864" src="https://i1.wp.com/talesofr.files.wordpress.com/2016/09/wordcloud.png?w=456&ssl=1" data-recalc-dims="1"></p>
<p> <a target="_blank" rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/talesofr.wordpress.com/786/"><img alt="" src="http://feeds.wordpress.com/1.0/comments/talesofr.wordpress.com/786/" border="0"></a> <img alt="" src="https://i1.wp.com/pixel.wp.com/b.gif?resize=1%2C1&ssl=1" border="0" data-recalc-dims="1"></p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="https://www.r-bloggers.com/quick-wordclouds-from-pubmed-abstracts-using-pmid-lists-in-r/"></div></div><div><a data-url="https://www.r-bloggers.com/quick-wordclouds-from-pubmed-abstracts-using-pmid-lists-in-r/" data-counturl="https://www.r-bloggers.com/quick-wordclouds-from-pubmed-abstracts-using-pmid-lists-in-r/" data-count="vertical" data-text="Quick wordclouds from PubMed abstracts – using PMID lists in R" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://talesofr.wordpress.com/2016/09/26/quick-wordclouds-from-pubmed-abstracts-using-pmid-lists-in-r/"> R – Tales of R</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/6S1P-28s-EE"></a></div>