<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/exploratory-sentiment-analysis-of-beer-tweets-from-untappd-on-twitter/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://jasdumas.github.io/2018-02-05-exploring_untp_beer_twitter/"> Jasmine Dumas' R Blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<h2>Project Objective</h2>
<p>Untappd has some usage restrictions for their <a rel="nofollow" href="https://untappd.com/api/register" target="_blank">API</a> namely not allowing any exploratory of analytics uses, so <a rel="nofollow" href="https://untappd.com/user/jasdumas" target="_blank">I’m</a> going to explore tweets of beer and brewery check-ins from the Untappd app to find some implicit trends in how users share their activity.</p>
<h2>Exploratory Analysis</h2>
<div>
<div>
<pre><code><span>library</span><span>(</span><span>tidyverse</span><span>)</span><span>
</span><span>library</span><span>(</span><span>rtweet</span><span>)</span><span>
</span><span>library</span><span>(</span><span>stringr</span><span>)</span><span>
</span><span>library</span><span>(</span><span>wesanderson</span><span>)</span><span>
</span><span>library</span><span>(</span><span>maps</span><span>)</span><span>
</span><span>library</span><span>(</span><span>tidytext</span><span>)</span><span>
</span><span>library</span><span>(</span><span>dumas</span><span>)</span><span> </span><span># http://jasdumas.github.io/dumas/</span><span>
</span><span>library</span><span>(</span><span>wordcloud</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p>All social media shares from the Untappd app include their own short URL <strong>‘untp.beer’</strong>, which makes the search query criteria identifiable using the <a rel="nofollow" href="http://rtweet.info/" target="_blank"><code>search_tweets()</code></a> function.</p>
<div>
<div>
<pre><code><span>untp</span><span> </span><span>&lt;-</span><span> </span><span>search_tweets</span><span>(</span><span>q</span><span> </span><span>=</span><span> </span><span>&quot;untp.beer&quot;</span><span>,</span><span> </span><span>n</span><span> </span><span>=</span><span> </span><span>18000</span><span>,</span><span> </span><span>include_rts</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>,</span><span> </span><span>retryonratelimit</span><span> </span><span>=</span><span> </span><span>TRUE</span><span>,</span><span> </span><span>geocode</span><span> </span><span>=</span><span> </span><span>lookup_coords</span><span>(</span><span>&quot;usa&quot;</span><span>),</span><span> </span><span>lang</span><span> </span><span>=</span><span> </span><span>&quot;en&quot;</span><span>
</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<p>Let’s take a peek at the text of the tweet!</p>
<div>
<div>
<pre><code><span>head</span><span>(</span><span>untp</span><span>$</span><span>text</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<div>
<div>
<pre><code>## [1] &quot;I just earned the 'Land of the Free (Level 94)' badge on @untappd! https://t.co/oSOzNMA6tn&quot; 
## [2] &quot;I just earned the 'Wheel of Styles (Level 10)' badge on @untappd! https://t.co/jbW0zjtyAl&quot;  
## [3] &quot;I just earned the 'God Save the Queen' badge on @untappd! https://t.co/CdhKjOKK40&quot;          
## [4] &quot;I just earned the 'Draft City (Level 2)' badge on @untappd! https://t.co/Ps0WOIRUot&quot;        
## [5] &quot;I just earned the 'Middle of the Road (Level 2)' badge on @untappd! https://t.co/XRXVRcc8Iq&quot;
## [6] &quot;Drinking a GRITz by @BrainDeadBrew at @luckdallas — https://t.co/BPCAmDcpdE&quot;
</code></pre>
</div>
</div>
<p>From this sample, its apparent that there a few type of default tweets that are available.</p>
<h4>Let’s explore some descriptive stats about the 18,000 tweets that were extracted</h4>
<p>How many unique users are in the data set?</p>
<div>
<div>
<pre><code><span>length</span><span>(</span><span>unique</span><span>(</span><span>untp</span><span>$</span><span>user_id</span><span>))</span><span>
</span></code></pre>
</div>
</div>
<div>
<div>
<pre><code>## [1] 5897
</code></pre>
</div>
</div>
<div>
<div>
<pre><code><span>paste</span><span>(</span><span>min</span><span>(</span><span>untp</span><span>$</span><span>created_at</span><span>),</span><span> </span><span>max</span><span>(</span><span>untp</span><span>$</span><span>created_at</span><span>),</span><span> </span><span>sep</span><span> </span><span>=</span><span> </span><span>&quot; to &quot;</span><span> </span><span>)</span><span>
</span></code></pre>
</div>
</div>
<div>
<div>
<pre><code>## [1] &quot;2018-02-04 19:35:40 to 2018-02-05 23:35:29&quot;
</code></pre>
</div>
</div>
<p>My initial assumptions were that all the tweets would be posted from the app, but it seems there is a little bit cross-posting going on from Facebook and some nerds who have set up <a rel="nofollow" href="https://ifttt.com/discover" target="_blank">IFTTT</a> applet recipes.</p>
<div>
<div>
<pre><code><span>count</span><span>(</span><span>untp</span><span>,</span><span> </span><span>source</span><span>)</span><span>
</span></code></pre>
</div>
</div>
<div>
<div>
<pre><code>## # A tibble: 3 x 2
##     source     n
##      </code></pre></div></div>