<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/differences-in-word-use-across-music-genres-in-pitchfork-album-reviews/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://methodmatters.blogspot.com/2018/09/differences-in-word-use-across-music.html"> Method Matters</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>In this post we will return to the data on Pitchfork music reviews, parts of which I’ve <a rel="nofollow" href="http://methodmatters.blogspot.com/2017/12/clustering-music-genres-with-r.html" target="_blank">analyzed</a> <a rel="nofollow" href="http://methodmatters.blogspot.com/2018/06/sentiment-use-across-course-of.html" target="_blank">previously</a>. The goal of this post will be to gain an understanding of distinctive words in the reviews of albums of different musical genres. This type of analysis helps us understand the musical aspects that distinguish written descriptions of the music from different genres, at least in the context of music reviews written by Pitchfork writers. We will again use R and the tidytext approach to structure our text data, and make use of a basic visualization technique to understand what words are used more in a given genre compared to the others. </p>
<div><b>The Data</b></div>
<p>As described in previous posts, these data were obtained from the <a rel="nofollow" href="https://www.kaggle.com/nolanbconaway/pitchfork-data" target="_blank">Kaggle website</a>. Because we are interested in exploring word use that is particular to specific genres, I excluded reviews with more than 1 genre from the scope of this analysis, leaving us with 12,147 review texts. As in the <a rel="nofollow" href="http://methodmatters.blogspot.com/2018/06/sentiment-use-across-course-of.html" target="_blank">previous post</a>, we will focus on 3 columns in our dataset: one column containing a unique review identifier, one column with the review text, and one column that contains the genre of the album being reviewed (with the following options: <i>electronic</i>, <i>experimental</i>, <i>folk/country</i>, <i>global</i>, <i>jazz</i>, <i>metal</i>,<i> pop/rnb</i>, <i>rap </i>and <i>rock</i>). </p>
<div><b>Data Preparation</b></div>
<p>We will use the same data preparation steps as we did in the <a rel="nofollow" href="http://methodmatters.blogspot.com/2018/06/sentiment-use-across-course-of.html" target="_blank">previous post</a>. Our data frame is called <i>text_df</i>, and looks like this:</p>
<table>
<thead>
<tr>
<th></th>
<th>line</th>
<th>text</th>
<th>genre</th>
</tr>

</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>“Trip-hop” eventually became a ’90s punchline, a music-press shorthand for “overhyped hotel lounge music.”… </td>
<td>electronic</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>Eight years, five albums, and two EPs in, the New York-based outfit Krallice have long since shut up purists about their “hipster black metal.” …</td>
<td>metal</td>
</tr>
<tr>
<td>3</td>
<td>3</td>
<td>Minneapolis’ Uranium Club seem to revel in being aggressively obtuse… </td>
<td>rock</td>
</tr>
<tr>
<td>4</td>
<td>4</td>
<td>Kleenex began with a crash. It transpired one night not long after they’d formed, in Zurich of 1978… </td>
<td>rock</td>
</tr>
<tr>
<td>5</td>
<td>5</td>
<td>It is impossible to consider a given release by a footwork artist without confronting the long shadow cast by DJ Rashad’s catalog…</td>
<td>electronic</td>
</tr>
<tr>
<td>6</td>
<td>6</td>
<td>Rapper Simbi Ajikawo, who records as Little Simz, is by all measures on an upward trajectory…</td>
<td>rap</td>
</tr>
</tbody>
</table>
<p>The column “line” serves as an indicator of the review id. The column “text” contains the text of the review and the “genre” column indicates the genre.</p>
<p>Our data processing steps will turn our original data (which contains one review per row) into a tidy data frame with one word per row, and meta-data in additional columns. We additionally remove stop words (words which occur frequently but have little meaning such as “the”) and punctuation. Finally, as there are some issues with strange punctuation (the dreaded “<a rel="nofollow" href="https://practicaltypography.com/straight-and-curly-quotes.html" target="_blank">curly quotes</a>“), we remove all additional characters which are neither numbers nor letters. These data preparation steps are essentially those I described in the <a rel="nofollow" href="http://methodmatters.blogspot.com/2018/06/sentiment-use-across-course-of.html" target="_blank">previous post</a>, but here I combine all the steps in a single <a rel="nofollow" href="https://cran.r-project.org/web/packages/dplyr/index.html" target="_blank"><b>dplyr</b></a> chain: </p>
<pre><span># combine the cleaning steps in one dplyr chain</span><br><span>cleaned_reviews</span> <span>&lt;-</span> <span>text_df</span> %<span>></span>%<br>                <span># turn the dataframe into a tidydf</span><br>                <span># (also converts text to lower case, removes punctuation)</span><br>                unnest_tokens(<span>word</span>, <span>text</span>)  %<span>></span>%<br>                <span># add a column for word order</span><br>                group_by(<span>line</span>) %<span>></span>% mutate(<span>position_in_review</span> <span>=</span> <span>1</span><span>:</span>n()) %<span>></span>%<br>                <span># remove stop words and order by position in the review</span><br>                anti_join(<span>stop_words</span>) %<span>></span>% arrange(<span>line</span>, <span>position_in_review</span>) %<span>></span>%<br>                <span># remove remaining punctuation (problem with &quot;curly&quot; quotes)</span><br>                mutate(<span>word</span> <span>=</span> Trim(clean(gsub(<span>&quot;[^0-9A-Za-z]&quot;</span>,<span>&quot;&quot;</span> , <span>word</span> ,<span>ignore.case</span> <span>=</span> <span>TRUE</span>)))) <br><br></pre>
<p>Our resulting data, called <i>cleaned_reviews</i>, look like this:</p>
<table>
<thead>
<tr>
<th></th>
<th>line</th>
<th>genre</th>
<th>word</th>
<th>position_in_review</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>electronic</td>
<td>trip</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>electronic</td>
<td>hop</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
<td>electronic</td>
<td>eventually</td>
<td>3</td>
</tr>
<tr>
<td>4</td>
<td>1</td>
<td>electronic</td>
<td>90s</td>
<td>6</td>
</tr>
<tr>
<td>5</td>
<td>1</td>
<td>electronic</td>
<td>punchline</td>
<td>7</td>
</tr>
<tr>
<td>6</td>
<td>1</td>
<td>electronic</td>
<td>music</td>
<td>9</td>
</tr>
<tr>
<td>7</td>
<td>1</td>
<td>electronic</td>
<td>press</td>
<td>10</td>
</tr>
<tr>
<td>8</td>
<td>1</td>
<td>electronic</td>
<td>shorthand</td>
<td>11</td>
</tr>
<tr>
<td>9</td>
<td>1</td>
<td>electronic</td>
<td>overhyped</td>
<td>13</td>
</tr>
<tr>
<td>10</td>
<td>1</td>
<td>electronic</td>
<td>hotel</td>
<td>14</td>
</tr>
</tbody>
</table>
<div><b>Visualizing Distinctive Words in Reviews Across Album Genres </b></div>
<p>In order to visualize the distinctive words in reviews of music across genres, we will make a comparison cloud using the <a rel="nofollow" href="https://cran.r-project.org/web/packages/wordcloud/index.html" target="_blank"><b>wordcloud</b></a> package. Comparison clouds display the most distinctive words for a grouping variable, here the genre of the music reviewed. The size of the words is scaled to their distinctiveness, such that words in larger print are more distinctive of a given category than those in smaller print.</p>
<p>As explained in the <a rel="nofollow" href="https://cran.r-project.org/web/packages/tidytext/vignettes/tidytext.html" target="_blank">tidytext vignette</a> and in the <a rel="nofollow" href="http://methodmatters.blogspot.com/2018/06/sentiment-use-across-course-of.html" target="_blank">previous post</a>, it is possible to construct a comparison cloud using tidy text data from within a dplyr chain (with an assist from the <a rel="nofollow" href="https://cran.r-project.org/web/packages/reshape2/index.html" target="_blank"><b>reshape2</b></a> package). The following code is adapted from the vignette; it passes our <i>cleaned_reviews</i> data to a dplyr chain that counts the words per genre, transforms the shape of the data, and finally makes the comparison cloud: *</p>
<pre><span># load the required packages</span><br>library(<span>reshape2</span>)<br>library(<span>wordcloud</span>)<br><br><span># pass the cleaned reviews data to the dpylr chain</span><br><span># to make the wordcloud</span><br><span>cleaned_reviews</span> %<span>></span>%<br>  <span># count the number of times each word occurs in each genre</span><br>  count(<span>word</span>, <span>genre</span>, <span>sort</span> <span>=</span> <span>TRUE</span>) %<span>></span>% <br>  <span># reshape: rows contain the words and the columns contain the genres</span><br>  <span># the values of this matrix contain the counts of each word in each genre </span><br>  acast(<span>word</span> <span>~</span> <span>genre</span>, <span>value.var</span> <span>=</span> <span>&quot;n&quot;</span>, <span>fill</span> <span>=</span> <span>0</span>, <span>fun.aggregate</span> <span>=</span> <span>length</span>) %<span>></span>% <br>  <span># make the comparison cloud with 175 words, specifying size of word scaling</span><br>  comparison.cloud(<span>max.words</span> <span>=</span> <span>175</span>, <span>title.size</span> <span>=</span> <span>1</span>, <span>scale</span>=c(<span>1.7</span>,.<span>7</span>)) <br><br></pre>
<p>The resulting comparison cloud looks like this:</p>
<div></div>
<div><a rel="nofollow" href="https://i0.wp.com/3.bp.blogspot.com/-NzNaelyOIPk/WqBHFzHGMoI/AAAAAAAAAbM/9x4Ef_N1yl4MuqneW9OCgj1Z76xT_cG9wCLcBGAs/s1600/comp_cloud_genre_blog.png?ssl=1" target="_blank"><img border="0" data-original-height="1067" src="https://i0.wp.com/3.bp.blogspot.com/-NzNaelyOIPk/WqBHFzHGMoI/AAAAAAAAAbM/9x4Ef_N1yl4MuqneW9OCgj1Z76xT_cG9wCLcBGAs/s1600/comp_cloud_genre_blog.png?resize=450%2C1067&ssl=1" data-recalc-dims="1" data-original-width="450"></a></div>
<p><span></span><span></span><br>The visualization is quite revealing, and gives us a good sense of A) what musical aspects are mentioned in the reviews (e.g. what sonic or other musical qualities are deemed relevant to describe in a music review?) and B) how these music descriptions differ across the various genres.</p>
<p><i>Genres and Sub-Genres</i></p>
<p>We can see that the names of the genres (e.g. jazz, metal, pop, etc.) are among the most distinctive words. This is the case for every genre in our dataset. These descriptors no doubt center the subject matter of the reviews.</p>
<p>We also can see that these genres contain a number of different sub-genres. Indeed, “<b>rock </b>music” is not just a single type of music – we see here references to <i>punk </i>and <i>indie</i>, for example. The same goes for the other genres in our data. For <b>metal</b>, we see mentions of <i>black </i>metal and <i>hardcore</i>, for <b>rap </b>we see <i>soul </i>(no doubt describing samples used), for <b>electronic </b>we see <i>house</i>, <i>drum </i>and <i>bass</i>, and <i>dance</i>. Reviews for <b>folk/country</b> music contain more mentions of the <i>blues</i>, while<b> global </b>music reviews appear to contain the sub-genres of <i>dub </i>and <i>reggae </i>(although global music is of course much more varied), and finally for <b>jazz </b>we see the subgenres of <i>free </i>jazz and <i>fusion </i>(a mix of jazz and rock which was quite popular in the 70’s).</p>
<p>In sum, the name of each genre is mentioned in the reviews and this comes across clearly in the review texts. This is reassuring but unsurprising. However, the wordcloud also allows us to understand the inherent variation within each genre that is not captured by its simple descriptor, and to understand that there is, for example, black metal and free jazz. </p>
<p><i>Musicians </i></p>
<p>What types of musicians are important in creating the music in the various genres? The wordcloud gives us some interesting insight into this question.</p>
<p>For <b>metal</b>, we see comparatively more mentions of <i>drummers</i>, <i>guitarists</i>, and <i>vocalists </i>(which is an interesting word choice – my guess is that this makes reference to the wide variety of vocal performances in the metal genre, which can range between melodic singing to shouting or screaming); the Pitchfork reviews seem to indicate that these three types of musicians are important when describing the important qualities of metal music. For <b>pop</b>, the important musician is clearly the <i>singer</i>; indeed, in pop music, the singer is the focal musician, whose role is both to deliver the vocal performance and to sell the record. For <b>rap</b>, we see comparatively more mentions of <i>rappers</i>, <i>producers </i>and <i>MC’s</i>; indeed, these are key figures within this genre of music (and are likely to be found only in this genre), and the ones who determine the sound and feel of a rap album. For <b>electronic </b>we see <i>DJ</i>, and for <b>experimental </b>we see mention of the term <i>composer</i>. For <b>global</b>, we see mention of <i>musicians </i>which is intriguing but frustratingly unspecific. The genre with the most unique mentions of different types of musicians is clearly <b>jazz</b>. The wordcloud gives us the sense that jazz is a genre that relies on a number of different instrumentalists, with <i>saxophonist</i>, <i>bassist</i>, <i>pianist </i>and <i>trumpeter</i> mentioned individually; we also see the importance of the interaction between them (with the mention of <i>ensemble </i>and <i>players</i>). Finally, <b>folk and country</b> make comparatively more mentions of <i>songwriters</i> and <i>arrangements</i>. My knowledge of country music is not very advanced, but my understanding is that the Nashville country music ecosystem is full of consummate professionals who write and arrange music for or with country music stars. Given that the story and narrative are very important in this genre, indeed often defining the track, its instrumentation and sound and feel, it makes perfect sense that the term <i>songwriter </i>occurs more frequently when reviewing folk/country albums.  </p>
<p><i>Instruments and Musical Qualities </i></p>
<p>What does the music sound like? This is a key notion (and simultaneously one of the most difficult things) to convey in a written album review. How do the Pitchfork reviews describe the distinctive instruments and sounds one would hear in albums of the different genres? <br>  <br>For <b>metal</b>, we see the mention of <i>drums </i>and <i>guitars </i>(the instruments played by the above-mentioned <i>drummers</i> and <i>guitarists</i>), and we can expect the music to contains <i>riffs </i>(likely from <i>guitars</i>) and to have a <i>sludge</i>-like sound. It will likely be loud (see the mention of <i>heavy </i>sounds such as <i>power </i>and <i>blast</i>). For <b>pop</b>, we should probably be focused on the <i>vocal </i>performance; we can bet that the songs have a killer <i>chorus</i>. In <b>rap </b>music, we should be focused on the <i>beats</i>, the <i>production</i>, and the <i>hook </i>(the “chorus” of a rap track) which likely contains a <i>sample </i>of a previous song, and the rapper’s <i>flow </i>and <i>rhymes</i>. For <b>electronic </b>music, we will likely hear a lot of <i>synths </i>(e.g. electronic keyboards) and <i>ambient sounds</i>. In <b>experimental </b>music, we will likely hear <i>drones </i>and <i>noise</i>, which have specific (unspecified in this analysis) types of <i>tones</i>. In <b>country </b>music, we are more likely to hear the <i>banjo </i>and <i>guitar</i>, notice the <i>singer</i>‘s voice, to encounter instruments in an <i>acoustic </i>presentation, and to hear music in which the <i>arrangement </i>(e.g. the song structure and instrumentation) is notable. In <b>global </b>music, we’re more likely to encounter <i>funky rhythms</i>. Finally, in <b>jazz</b>, we are more likely to hear a number of different instruments: the <i>saxophone</i>, <i>trumpet </i>and <i>piano</i>. The <i>rhythm </i>is important, as are the <i>notes </i>which we’ll likely hear in the <i>solos</i>. More so than in the other genres, the <i>playing </i>of the music is important in jazz (especially the musician’s <i>tone</i>), and we will likely encounter <i>compositions </i>with distinct <i>sections</i>. </p>
<p><i>Subject Matter</i></p>
<p>What describes the subject matter? The data provide some clues here, but the reviews don’t give equal information about each genre. Metal music contains dark subject matter of course – words such as <i>death </i>and <i>doom </i>convey this notion quite clearly. <b>Pop/R&amp;B</b> music, in contrast, is more likely to be about <i>love</i>. Rap music, meanwhile, is more likely to deal with the topic of <i>money</i>. Finally, in comparison to the other genres, <b>global </b>music is more likely to deal with <i>political </i>subjects. </p>
<p></p>
<div><b>Summary and Conclusion</b></div>
<p>In this post, we used tidytext principles to clean and prepare the Pitchfork album review texts and to construct a word cloud to visualize the most distinctive words in the different musical genres. We first turned our raw dataset into a tidy format, and performed some basic cleaning (removing punctuation and stopwords). We then constructed a comparison cloud using the cleaned tidy data, which allowed us to see which words are unique for the reviews of music from different genres. The resulting visualization complements and expands our understanding of the sub-genres, musicians, instruments and musical qualities, and the subject matter of different genres of music. </p>
<p><i>Coming Up Next</i></p>
<p>In the next post, we’ll use a multi-level model to construct pairwise comparisons of many different means. The method is one described by the statistician and blogger Andrew Gelman, and is often mentioned on his <a rel="nofollow" href="https://andrewgelman.com/" target="_blank">blog</a>. It provides an interesting solution to a traditionally difficult statistical problem.</p>
<p><b></b>Stay tuned!<br><b></b></p>
<p><b>—</b></p>
<p>* In many cases, I would also stem the words before passing them to a wordcloud, but I’ve retained the unstemmed words for interpretability and aesthetic purposes. The comparison cloud made from the stemmed review corpus is virtually identical to the one presented above.</p>
<p><b> </b> </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://methodmatters.blogspot.com/2018/09/differences-in-word-use-across-music.html"> Method Matters</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/38ZvB4DPrzE" height="1"></a></div>