<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/its-a-dirty-job-but-someones-got-to-do-it/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://johnmackintosh.com/2017-10-29-It%27s-a-dirty-job/"> HighlandR</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>	A tidytext analysis of Faith No More lyrics – </p>
<h2>Is this a midlife crisis?</h2>
<p>I wanted to ease myself back into text mining,specifically using the <a rel="nofollow" href="https://cran.r-project.org/package=tidytext" target="_blank">tidytext package</a> as I haven’t had to do any at work for well over a year.</p>
<p>I’ve been thinking about some of the old bands of the 90’s, some of whom split up, and then reformed. I was interested to see how lyrics evolve over time, and to see what changes there were as the band matured.</p>
<p>I’ve decided to look at Faith No More, because:</p>
<ul>
<li>they recently reformed after an 18 year split</li>
<li>they had numerous line up changes, the main one being a change of vocalist shortly before the release of their 3rd (and most successful) album, “The Real Thing”.</li>
<li>Said vocalist, Mike Patton, was only 21 when he joined. I thought it might be interesting to see how his lyrics evolved over time</li>
<li>Their 4th album “Angel Dust” has been named the most influential rock album of all time.</li>
</ul>
<p>Let’s get one thing out of the way – there will be some review of the band’s history as well as being an R article but I promise – there will be <strong>no wordclouds</strong>.</p>
<p>To start – let’s look at the number of tracks being analysed by album. I’ve excluded “We Care A Lot” from “Introduce Yourself”, as it’s the same as the title track from their first album, and would skew the analysis. I’ve also excluded cover versions and bonus tracks and a track from Sol Invictus, because the title is <strong>a very naughty word indeed</strong> .</p>
<p><img alt="2017-10-22-Tracks-Analysed-by-Album.png" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-Tracks-Analysed-by-Album.png?w=456" data-recalc-dims="1"></p>
<p>Most of the examples here follow the code available on the most excellent <a rel="nofollow" href="http://tidytextmining.com/" target="_blank">http://tidytextmining.com/</a>. Big thanks to the package authors, <a rel="nofollow" href="https://juliasilge.com/" target="_blank">Julia Silge</a> and <a rel="nofollow" href="http://varianceexplained.org/" target="_blank">David Robinson</a> for this package. I had done some text mining prior to the release of this package, but as someone used to dataframes, I soon found my progress limited to following a small number of tutorials and not knowing how to manipulate term document matrices etc to conduct further analysis.<br>
Tidytext is a game-changer because the data remains in dataframe/tibble format, and we can use dplyr and ggplot2 to wrangle and visualise.</p>
<p>I had originally hoped this whole exercise would give me some experience with web-scraping – but the site I chose only allowed the use of an API – and while there was a Python one, there was no R alternative. Regardless – I was able to collate the data I needed.</p>
<p>The original dataframe consisted of Title, Album and a lyrics column, and this was transformed into a format suitable for text analysis:</p>
<div>
<div>
<pre><code><span>text_df</span><span> </span><span>&lt;-</span><span> </span><span>data</span><span> </span><span>%>%</span><span> </span><span>unnest_tokens</span><span>(</span><span>word</span><span>,</span><span>lyrics</span><span>)</span><span> </span><span>%>%</span><span> </span><span>filter</span><span>(</span><span>word</span><span> </span><span>%notin%</span><span> </span><span>c</span><span>(</span><span>&quot;b&quot;</span><span>,</span><span>&quot;e&quot;</span><span>,</span><span>&quot;a&quot;</span><span>,</span><span>&quot;g&quot;</span><span>,</span><span>&quot;r&quot;</span><span>,</span><span>&quot;s&quot;</span><span>,</span><span>&quot;i&quot;</span><span>,</span><span>&quot;v&quot;</span><span>,</span><span>&quot;la&quot;</span><span>))</span><span> </span><span>%>%</span><span> </span><span>mutate</span><span>(</span><span>linenumber</span><span> </span><span>=</span><span> </span><span>row_number</span><span>())</span><span>
</span></code></pre>
</div>
</div>
<p>One song (“Be Aggressive”) has a cheerleader style chorus where the title is spelled out letter by letter – so, I excluded these, along with “la”, which was also featuring highly in my initial plot of common words. Along with filtering out common “stop words”, I arrived at the following plot:</p>
<p><img alt="2017-10-22-Most-Common-Words.png" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-Most-Common-Words.png?w=456" data-recalc-dims="1"></p>
<p>This looks pretty boring, so let’s at least split it by album:</p>
<p><img alt="2017-10-22-Most-Common-Words-by-Album.png" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-Most-Common-Words-by-Album.png?w=456" data-recalc-dims="1"></p>
<h3>We Care A Lot</h3>
<p><img alt="2017-10-22-WCAL.jpg" src="https://i0.wp.com/johnmackintosh.com/img/2017-10-22-WCAL.jpg?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-WCAL-lineup.jpg" src="https://i0.wp.com/johnmackintosh.com/img/2017-10-22-WCAL-lineup.jpg?w=456" data-recalc-dims="1"></p>
<p>Unsurprisingly, <a rel="nofollow" href="https://www.youtube.com/watch?v=LQhX8PbNUWI" target="_blank">“We Care A Lot”</a> dominates the first album, given that it is repeated endlessly throughout the title track. Live favourite “As The Worm Turns” doesn’t feature though.</p>
<h3>Introduce Yourself</h3>
<p><img alt="2017-10-22-IY.jpg" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-IY.jpg?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-IY-lineup.jpg" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-IY-lineup.jpg?w=456" data-recalc-dims="1"></p>
<p>Looking at “Introduce Yourself”, I’m surprised the title track doesn’t feature more heavily . Of the top words shown here, I recognise a couple from “Anne’s Song”. None from my under the radar favourites “Faster Disco” and “Chinese Arithmetic” though.</p>
<h3>The Real Thing</h3>
<p><img alt="2017-10-22-TRT.jpg" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-TRT.jpg?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-TRT-lineup.jpg" src="https://i0.wp.com/johnmackintosh.com/img/2017-10-22-TRT-lineup.jpg?w=456" data-recalc-dims="1"></p>
<p>Now on to the golden age of the band – Mike Patton unleashed his 6 octave vocal range and guitarist Jim Martin was still alternately shredding and providing short, clever solos. It took me a while figure out why “yeah” was so high, then I remembered the chorus of <a rel="nofollow" href="https://www.youtube.com/watch?v=ZG_k5CSYKhg" target="_blank">“Epic”</a>. Never heard Faith No More? Start with this one. Also featuring here are words from “Underwater Love”, “Surprise! You’re Dead!” and personal favourite <a rel="nofollow" href="https://www.youtube.com/watch?v=j4tsGWdarHc" target="_blank">“From Out of Nowhere”</a>.</p>
<h3>Angel Dust</h3>
<p><img alt="2017-10-22-AD.jpg" src="https://i0.wp.com/johnmackintosh.com/img/2017-10-22-AD.jpg?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-AD-lineup.jpg" src="https://i0.wp.com/johnmackintosh.com/img/2017-10-22-AD-lineup.jpg?w=456" data-recalc-dims="1"></p>
<p>“Angel Dust” is dominated from words in just 2 songs – the aforementioned “Be Aggressive” and <a rel="nofollow" href="https://www.youtube.com/watch?v=U8b88US-6ts" target="_blank">“Midlife Crisis”.</a>. Other popular tracks from this album were <a rel="nofollow" href="https://www.youtube.com/watch?v=i9_hCjcFNO0" target="_blank">“A Small Victory”</a>, and their hit cover of the Commodore’s <a rel="nofollow" href="https://www.youtube.com/watch?v=vPzDTfIb0DU" target="_blank">“Easy”</a>.</p>
<h3>King For A Day…Fool For A Lifetime</h3>
<p><img alt="2017-10-22-KFAD.jpg" src="https://i0.wp.com/johnmackintosh.com/img/2017-10-22-KFAD.jpg?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-KFAD-lineup.jpg" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-KFAD-lineup.jpg?w=456" data-recalc-dims="1"></p>
<p>“King For A Day…Fool For A Lifetime” marks the start of the post-Jim Martin era and stands out in this plot in that it has a number of different tracks with frequently mentioned words. This album saw the band alternate many musical styles – sometimes in the same track – an example being <a rel="nofollow" href="https://www.youtube.com/watch?v=4VcL9aMt9PQ" target="_blank">“Just A Man”</a>. This was one of the album’s highlights (see also – <a rel="nofollow" href="https://www.youtube.com/watch?v=7lvMNLhJrb0" target="_blank">“Evidence”</a>) but there was some filler on there too unfortunately.</p>
<h3>Album Of The Year</h3>
<p><img alt="2017-10-22-AOTY.jpg" src="https://i0.wp.com/johnmackintosh.com/img/2017-10-22-AOTY.jpg?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-AOTY-lineup.jpg" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-AOTY-lineup.jpg?w=456" data-recalc-dims="1"></p>
<p>The ironically titled “Album of the Year” reverts to being dominated by a few tracks, including single <a rel="nofollow" href="https://www.youtube.com/watch?v=FtIwfugF1zw" target="_blank">“Last Cup of Sorrow”</a>. Other highlights were “Ashes To Ashes” and <a rel="nofollow" href="https://www.youtube.com/watch?v=-_U6165DVeM" target="_blank">“Stripsearch”</a>.</p>
<p>Shortly after the release of this album, and years of in-fighting the band called it a day. They didn’t match the success of “The Real Thing” in the US, although the rest of the world were more switched on and “Angel Dust” actually outsold it in some areas.</p>
<p>Even towards the end, they were popular enough in the UK to appear on “TFI Friday” (popular 90’s live entertainment show, hosted by then top presenter Chris Evans) 2 weeks running. While Britpop was a thing, FNM played “Ashes to Ashes” and turned in one of the <a rel="nofollow" href="https://www.youtube.com/watch?v=-BhXeGemai0" target="_blank">finest live performances on UK TV</a> (according to the internet).</p>
<p>And, for a long time (18 years) it looked like that was that. An avant-garde rock band consigned to history. But, following several years of occasional live shows, the band returned in their final lineup and released “Sol Invictus”. I have to confess I have not listened to this album, apart from a few tracks. <a rel="nofollow" href="https://www.youtube.com/watch?v=uPlmhJG_xUM" target="_blank">“Sunny Side Up”</a> being the stand-out for me so far.</p>
<p>Enough history, let’s look at some more plots and R code.</p>
<div>
<div>
<pre><code><span>song_words</span><span> </span><span>&lt;-</span><span> </span><span>data</span><span> </span><span>%>%</span><span>
</span><span>unnest_tokens</span><span>(</span><span>word</span><span>,</span><span> </span><span>lyrics</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>count</span><span>(</span><span>Title</span><span>,</span><span> </span><span>word</span><span>,</span><span> </span><span>sort</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>n</span><span>></span><span>30</span><span>)</span><span> </span><span>%>%</span><span> </span><span>ungroup</span><span>()</span><span>
</span><span>ggplot</span><span>(</span><span>song_words</span><span>,</span><span>aes</span><span>(</span><span>reorder</span><span>(</span><span>word</span><span>,</span><span> </span><span>n</span><span>),</span><span>n</span><span>,</span><span> </span><span>fill</span><span>=</span><span>Title</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_col</span><span>()</span><span>+</span><span>
</span><span>xlab</span><span>(</span><span>NULL</span><span>)</span><span> </span><span>+</span><span>
</span><span>ylab</span><span>(</span><span>NULL</span><span>)</span><span>+</span><span>
</span><span>coord_flip</span><span>()</span><span>+</span><span>
</span><span>theme_ipsum</span><span>()</span><span>+</span><span>
</span><span>scale_fill_ipsum</span><span>()</span><span>+</span><span>
</span><span>#scale_fill_viridis(option =&quot;C&quot;, discrete = TRUE)+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Most Common Words - All Faith No More Studio Songs&quot;</span><span>,</span><span>
</span><span>subtitle</span><span> </span><span>=</span><span> </span><span>&quot;Frequency >30. Including common stop words&quot;</span><span>)</span><span>+</span><span>
</span><span>theme</span><span>(</span><span>legend.position</span><span> </span><span>=</span><span> </span><span>&quot;bottom&quot;</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><img alt="2017-10-22-MostCommonWordsbySongIncludingStopWords.png" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-MostCommonWordsbySongIncludingStopWords.png?w=456" data-recalc-dims="1"></p>
<div>
<div>
<pre><code><span> </span><span>## now remove stop words and the letters from</span><span>
</span><span># &quot;Be Aggressive&quot;</span><span>
</span><span>song_words_filtered</span><span> </span><span>&lt;-</span><span> </span><span>data</span><span> </span><span>%>%</span><span>
</span><span>unnest_tokens</span><span>(</span><span>word</span><span>,</span><span> </span><span>lyrics</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>anti_join</span><span>(</span><span>stop_words</span><span>)</span><span> </span><span>%>%</span><span> </span><span>filter</span><span>(</span><span>stringr</span><span>::</span><span>str_detect</span><span>(</span><span>word</span><span>,</span><span>&quot;[a-z`]$&quot;</span><span>),</span><span>
</span><span>!</span><span>word</span><span> </span><span>%in%</span><span> </span><span>stop_words</span><span>$</span><span>word</span><span>)</span><span> </span><span>%>%</span><span> </span><span>filter</span><span>(</span><span>word</span><span> </span><span>%notin%</span><span> </span><span>c</span><span>(</span><span>&quot;b&quot;</span><span>,</span><span>&quot;e&quot;</span><span>,</span><span>&quot;a&quot;</span><span>,</span><span>&quot;g&quot;</span><span>,</span><span>&quot;r&quot;</span><span>,</span><span>&quot;s&quot;</span><span>,</span><span>&quot;i&quot;</span><span>,</span><span>&quot;v&quot;</span><span>,</span><span>&quot;la&quot;</span><span>))</span><span> </span><span>%>%</span><span> </span><span>count</span><span>(</span><span>Title</span><span>,</span><span> </span><span>word</span><span>,</span><span> </span><span>sort</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>n</span><span>></span><span>20</span><span>)</span><span> </span><span>%>%</span><span> </span><span>ungroup</span><span>()</span><span>
</span><span>ggplot</span><span>(</span><span>song_words_filtered</span><span>,</span><span>aes</span><span>(</span><span>reorder</span><span>(</span><span>word</span><span>,</span><span> </span><span>n</span><span>),</span><span>n</span><span>,</span><span> </span><span>fill</span><span>=</span><span>Title</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_col</span><span>()</span><span>+</span><span>
</span><span>xlab</span><span>(</span><span>NULL</span><span>)</span><span> </span><span>+</span><span>
</span><span>ylab</span><span>(</span><span>NULL</span><span>)</span><span>+</span><span>
</span><span>coord_flip</span><span>()</span><span>+</span><span>
</span><span>theme_ipsum</span><span>()</span><span>+</span><span>
</span><span>scale_fill_ipsum</span><span>()</span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Most Common Words - All Faith No More Studio Songs&quot;</span><span>,</span><span>
</span><span>subtitle</span><span> </span><span>=</span><span> </span><span>&quot;Frequency >30. Excluding common stop words&quot;</span><span>)</span><span>+</span><span>
</span><span>theme</span><span>(</span><span>legend.position</span><span> </span><span>=</span><span> </span><span>&quot;bottom&quot;</span><span>)</span><span> </span></code></pre>
</div>
</div>
<p><img alt="2017-10-22-MostCommonWordsbySongExcludingStopWords.png" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-MostCommonWordsbySongExcludingStopWords.png?w=456" data-recalc-dims="1"></p>
<p>Term document frequency by album – the number of times a word is used in the lyrics / by the total number of words in the lyrics. A lot of words occur rarely and a very few occurring frequently:</p>
<p><img alt="" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-Term-Frequency-by-Album.png?w=456" data-recalc-dims="1"></p>
<p>Inverse Term Document frequency – or an attempt to identify words that don’t occur frequently but are important.</p>
<p><img alt="2017-10-22-Inverse-Term-Document-Frequency-by-Album.png" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-Inverse-Term-Document-Frequency-by-Album.png?w=456" data-recalc-dims="1"></p>
<p>Now we’ve looked at common and important words, let’s see if we can get a handle on the sentiment of those words.<br>
Admittedly, this first plot is a bit of a gimmick, but rather than use geom_col, or geom_point, I thought I’d use the <a rel="nofollow" href="https://cran.r-project.org/package=ggimage" target="_blank">ggimage</a> package, and mark the overall album sentiment using the relevant album covers.</p>
<p>Here’s the code:</p>
<div>
<div>
<pre><code><span>#overall album sentiment </span><span>
</span><span>albumsentiment</span><span>&lt;-</span><span> </span><span>text_df</span><span> </span><span>%>%</span><span>
</span><span>inner_join</span><span>(</span><span>get_sentiments</span><span>(</span><span>&quot;bing&quot;</span><span>))</span><span> </span><span>%>%</span><span>
</span><span>count</span><span>(</span><span>Album</span><span>,</span><span> </span><span>sentiment</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>spread</span><span>(</span><span>sentiment</span><span>,</span><span> </span><span>n</span><span>,</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>0</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>mutate</span><span>(</span><span>sentiment</span><span> </span><span>=</span><span> </span><span>positive</span><span> </span><span>-</span><span> </span><span>negative</span><span>)</span><span>
</span><span>#create vector of images</span><span>
</span><span>albumsentiment</span><span>$</span><span>img</span><span> </span><span>&lt;-</span><span> </span><span>c</span><span>(</span><span>&quot;2017-10-22-WCAL.jpg&quot;</span><span>,</span><span>&quot;2017-10-22-IY.jpg&quot;</span><span>,</span><span>
</span><span>&quot;2017-10-22-TRT.jpg&quot;</span><span>,</span><span>&quot;2017-10-22-AD.jpg&quot;</span><span>,</span><span>&quot;2017-10-22-KFAD.jpg&quot;</span><span>,</span><span>
</span><span>&quot;2017-10-22-AOTY.jpg&quot;</span><span>,</span><span>&quot;2017-10-22-SI.jpg&quot;</span><span>)</span><span>
</span><span>ggplot</span><span>(</span><span>albumsentiment</span><span>,</span><span> </span><span>aes</span><span>(</span><span>Album</span><span>,</span><span> </span><span>sentiment</span><span>,</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>Album</span><span>))</span><span> </span><span>+</span><span>
</span><span>#geom_col(show.legend = FALSE) +</span><span>
</span><span>theme_ipsum</span><span>()</span><span>+</span><span>
</span><span>ggExtra</span><span>::</span><span>removeGrid</span><span>()</span><span>+</span><span>
</span><span>coord_flip</span><span>()</span><span>+</span><span>
</span><span>geom_image</span><span>(</span><span>aes</span><span>(</span><span>image</span><span>=</span><span>img</span><span>),</span><span> </span><span>size</span><span>=</span><span>.15</span><span>)</span><span>+</span><span>
</span><span>ggtitle</span><span>(</span><span>&quot;Overall Sentiment Score by Album&quot;</span><span>,</span><span>
</span><span>subtitle</span><span> </span><span>=</span><span> </span><span>&quot;Faith No More Studio Albums - Excludes cover versions&quot;</span><span>)</span><span>+</span><span>
</span><span>labs</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>NULL</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>NULL</span><span>)</span><span>+</span><span>
</span><span>geom_text</span><span>(</span><span>aes</span><span>(</span><span>label</span><span>=</span><span>sentiment</span><span>),</span><span> </span><span>hjust</span><span>=</span><span>0</span><span>,</span><span> </span><span>nudge_y</span><span>=</span><span>7</span><span>)</span><span>+</span><span>
</span><span>theme</span><span>(</span><span>axis.text.x</span><span>=</span><span>element_blank</span><span>(),</span><span>
</span><span>axis.ticks.x</span><span>=</span><span>element_blank</span><span>())</span><span>
</span></code></pre>
</div>
</div>
<p><img alt="2017-10-22-Sentiment-by-Album.png" src="https://i0.wp.com/johnmackintosh.com/img/2017-10-22-Sentiment-by-Album.png?w=456" data-recalc-dims="1"></p>
<p>So only “Introduce Yourself” managed to get a positive overall sentiment score. I’m surprised that “Album of the Year” scores as highly as it does given the band were on the verge of splitting up. However – this is simply a case of summing positive &amp; negative scores by individual word and finding the overall difference – so its definitely not an exact science. Songs like “Collision” and “Helpless” do not convey positive emotion to me.</p>
<p>Here is a more straightforward plot of sentiment by track:</p>
<p><img alt="2017-10-22-Sentiment-by-track2.png" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-Sentiment-by-track2.png?w=456" data-recalc-dims="1"></p>
<h3>Topic Models</h3>
<p><img alt="2017-10-22-Topic_Models.png" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-Topic_Models.png?w=456" data-recalc-dims="1"></p>
<p>I’m going to take the easy way out and refer you to the tidytext website to explain topic models. I have to be honest, I don’t really see any themes that make any sense to me here. So, I thought I should look at lyrics by individual vocalist:</p>
<p><img alt="2017-10-22-Topic_Models_Chuck.png" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-Topic_Models_Chuck.png?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-Topic_Models_patton.png" src="https://i0.wp.com/johnmackintosh.com/img/2017-10-22-Topic_Models_patton.png?w=456" data-recalc-dims="1"></p>
<p>Here I take the first 5 topics by both to see if there is anything in common:</p>
<p><img alt="2017-10-22-Top_Topic_Model_by_Vocalist.png" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-Top_Topic_Model_by_Vocalist.png?w=456" data-recalc-dims="1"></p>
<p>After a bit of digging around, it turned out only 2 terms existed in both sets:</p>
<p><img alt="2017-10-22-Common_Terms_between_Vocalists.png" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-Common_Terms_between_Vocalists.png?w=456" data-recalc-dims="1"></p>
<p>Hmm,”Love” and “World”. Seems a bit “touchy feely” as they say. Perhaps I should look at this by album and see what topics appear?</p>
<p><img alt="2017-10-22-Topic_Models-WCAL.png" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-Topic_Models-WCAL.png?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-Topic_Models-IY.png" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-Topic_Models-IY.png?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-Topic_Models-TRT.png" src="https://i0.wp.com/johnmackintosh.com/img/2017-10-22-Topic_Models-TRT.png?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-Topic_Models-AD.png" src="https://i0.wp.com/johnmackintosh.com/img/2017-10-22-Topic_Models-AD.png?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-Topic_Models-KFAD.png" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-Topic_Models-KFAD.png?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-Topic_Models-AOTY.png" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-Topic_Models-AOTY.png?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-Topic_Models-SI.png" src="https://i1.wp.com/johnmackintosh.com/img/2017-10-22-Topic_Models-SI.png?w=456" data-recalc-dims="1"></p>
<p>I’d expected perhaps that words belonging to the same song would get grouped together, but that doesn’t appear to happen very often.</p>
<p>I also looked at splitting the lyrics into trigrams (sequences of 3 words, e.g. “We Care A”, “Care A Lot”, “A Lot We”, “Lot We Care” etc. By far the most common trigram was “Separation Anxiety Hey” from “Separation Anxiety”.</p>
<p>I also looked at words where “Not” was the first of the 3 words in the trigram, to see if they were of positive or negative sentiment. First -the second word of the 3, then the final word of the 3.</p>
<p><img alt="2017-10-22-Negating-words-2-of-3.png" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-Negating-words-2-of-3.png?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-Negating-words-3-of-3.png" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-Negating-words-3-of-3.png?w=456" data-recalc-dims="1"></p>
<p>This can be expanded to look at other types of negating words:</p>
<p><img alt="2017-10-22-Negative-trigrams-Word-2-of-3-by-negating-word.png" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-Negative-trigrams-Word-2-of-3-by-negating-word.png?w=456" data-recalc-dims="1"></p>
<p><img alt="2017-10-22-Negative-trigrams-Word-3-of-3-by-negating-word.png" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-Negative-trigrams-Word-3-of-3-by-negating-word.png?w=456" data-recalc-dims="1"></p>
<p>I also tried producing a network plot of the trigrams. Bit of a mess to be honest, but here it is:</p>
<p><img alt="2017-10-22-correlation-plot.png" src="https://i2.wp.com/johnmackintosh.com/img/2017-10-22-correlation-plot.png?w=456" data-recalc-dims="1"></p>
<p>Finally – a correlation plot looking at closely linked overall each album is to the others, in terms of words used:</p>
<div>
<div>
<pre><code><span>library</span><span>(</span><span>widyr</span><span>)</span><span>
</span><span>album_word_cors</span><span> </span><span>&lt;-</span><span> </span><span>album_words</span><span> </span><span>%>%</span><span> </span><span>pairwise_cor</span><span>(</span><span>Album</span><span>,</span><span>word</span><span>,</span><span>n</span><span>,</span><span> </span><span>sort</span><span>=</span><span> </span><span>TRUE</span><span>)</span><span>
</span><span>album_word_cors</span><span>
</span><span>library</span><span>(</span><span>ggraph</span><span>)</span><span>
</span><span>library</span><span>(</span><span>igraph</span><span>)</span><span>
</span><span>set.seed</span><span>(</span><span>1234</span><span>)</span><span>
</span><span>album_word_cors</span><span> </span><span>%>%</span><span>
</span><span>filter</span><span>(</span><span>correlation</span><span> </span><span>></span><span> </span><span>.05</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>graph_from_data_frame</span><span>()</span><span> </span><span>%>%</span><span>
</span><span>ggraph</span><span>(</span><span>layout</span><span> </span><span>=</span><span> </span><span>&quot;fr&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_edge_link</span><span>(</span><span>aes</span><span>(</span><span>alpha</span><span> </span><span>=</span><span> </span><span>correlation</span><span>,</span><span> </span><span>width</span><span> </span><span>=</span><span> </span><span>correlation</span><span>))</span><span> </span><span>+</span><span>
</span><span>geom_node_point</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>6</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;lightblue&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_node_text</span><span>(</span><span>aes</span><span>(</span><span>label</span><span> </span><span>=</span><span> </span><span>name</span><span>),</span><span> </span><span>repel</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>)</span><span> </span><span>+</span><span>
</span><span>theme_void</span><span>()</span><span>
</span><span>ggsave</span><span>(</span><span>&quot;2017-10-22-album-word-correlations.png&quot;</span><span>,</span><span>width</span><span>=</span><span>8</span><span>,</span><span> </span><span>height</span><span> </span><span>=</span><span>5</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p><img alt="2017-10-22-album-word-correlations.png" src="https://i0.wp.com/johnmackintosh.com/img/2017-10-22-album-word-correlations.png?w=456" data-recalc-dims="1"></p>
<p>This is more interesting -although – the correlations are pretty weak overall. However, The Real Thing, Angel Dust and King For A Day have the strongest correlations with each other.<br>
There appears to be less correlation over time between the lyrics used in The Real Thing compared to Album of the Year.</p>
<p>There appears to little (or no) correlation between Album of the Year and Sol Invictus – that 18 year gap really made a difference. But what is interesting is the thick line between Sol Invictus and Introduce Yourself – 28 years apart, and from 2 different vocalists.</p>
<p>However, the sting in the tail is that Mike Patton has said that he chose words more for their sound, and to fit the music, than for their actual meaning. That would explain the lyrics of “ Midlife Crisis” and “A Small Victory”, but seems to short change the cleverness of the lyrics in tracks like “Everything’s Ruined” and “Kindergarten”. Maybe this means this has been a massive waste of time? Regardless, I have enjoyed looking back at some great music from this wonderfully unique band.</p>
<p>Code for the plots, and the plots themselves is available <a rel="nofollow" href="https://github.com/johnmackintosh/FNM" target="_blank">here</a></p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://johnmackintosh.com/2017-10-29-It%27s-a-dirty-job/"> HighlandR</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 rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/I8kkRStnBgY" height="1"></a></div>