WORDPLOTS
This is the first R project I am willing to post, my first wobbly little pancake baby, all misshapen yet still edible.
This took me an embarrassingly long period of time to figure out. I used The R Graph Gallery as my primary source, with additional frantic Googling and substacking and, I will admit it, even ChatGPT-ing. What I wanted to do was create a single visual representation of my latest paper about how adolescent alcohol exposure sensitizes the fever response to a viral challenge in males. Usually I summarize my work by graphing numbers – data – but here, I wanted to sum up my paper using just words.
I think for future examples I will post my code, but for this I will just summarize the work flow. The keys here were as follows:
- Download a pdf of your paper, turn it into a text file, remove all punctuation and other distractions, and pretty much perform a simple word frequency count. I manufactured my own hard times here by copying lines of code to test out but then personalizing things by retitling my text files and pdfs. The reason this created a hard time is because I substituted my own generic “mypaper.whatever” type of names for extant generic file names and in the end, became confused when the new code kept building on previous code. Actually, this was a pretty good way to catch all the instances in which I was merely copying things without truly understanding them. 5/10, would recommend but also would not recommend.
- Use the wordcloud2 package to create the hover-over effect. The whole point of a word plot is to make word size the visual representation of the frequency with which the words appear in the document. If you make this image interactive with this package, it will show you word count when you hover over that particular word. This paper used the word “fever” 142 times. Pretty cool!
- Create a custom list of words to delete. I had to keep going back in and removing more and more things. My paper included a bibliography, so one of my top frequency words was “doi.” If I were more thorough, I’d probably also remove people I cited a lot (ehem, “gano”) and also things like “ηp.” Three points to Gryffindor if you can guess what that originally was and how I used it!

You can export these wordplots as an html object like I did here in order to preserve the hover-over function. You can also export them as a static png file, like the image I used to link this page from the main page or like this image here that I generated using my dissertation document. On to the next dataviz adventure!