<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Twitter Usage â€¢ vosonSML</title>
<!-- favicons --><link rel="icon" type="image/png" sizes="16x16" href="../favicon-16x16.png">
<link rel="icon" type="image/png" sizes="32x32" href="../favicon-32x32.png">
<link rel="apple-touch-icon" type="image/png" sizes="180x180" href="../apple-touch-icon.png">
<link rel="apple-touch-icon" type="image/png" sizes="120x120" href="../apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" type="image/png" sizes="76x76" href="../apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" type="image/png" sizes="60x60" href="../apple-touch-icon-60x60.png">
<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css">
<script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous">
<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet">
<script src="../pkgdown.js"></script><link href="../extra.css" rel="stylesheet">
<meta property="og:title" content="Twitter Usage">
<meta property="og:description" content="vosonSML">
<!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body data-spy="scroll" data-target="#toc">
    

    <div class="container template-article">
      <header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <span class="navbar-brand">
        <a class="navbar-link" href="../index.html">vosonSML</a>
        <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="">0.34.3</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
<li>
  <a href="../index.html">
    <span class="fa fa-home fa-lg"></span>
     
  </a>
</li>
<li>
  <a href="../news/index.html">
    <span class="fa fa-newspaper"></span>
     
    Changelog
  </a>
</li>
<li>
  <a href="../reference/index.html">
    <span class="fa fa-cubes fa-lg"></span>
     
    Reference
  </a>
</li>
<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
    <span class="fa fa-book"></span>
     
    Articles
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
<li>
      <a href="../articles/Intro-to-vosonSML.html">
        <span class="far fa-file-alt"></span>
         
        Introduction to vosonSML
      </a>
    </li>
    <li>
      <a href="https://vosonlab.github.io/posts/2021-03-15-hyperlink-networks-with-vosonsml" class="external-link">
        <span class="far fa-file-alt"></span>
         
        Hyperlink Networks with vosonSML
      </a>
    </li>
    <li>
      <a href="../articles/Twitter-Usage.html">
        <span class="far fa-file-alt"></span>
         
        Twitter Usage
      </a>
    </li>
    <li>
      <a href="https://vosonlab.github.io/posts/2022-06-05-egocentric-networks-from-twitter-timelines" class="external-link">
        <span class="far fa-file-alt"></span>
         
        Egocentric Networks from Twitter timelines
      </a>
    </li>
    <li>
      <a href="https://vosonlab.github.io/posts/2021-10-01-testing-bot-status-of-twitter-users" class="external-link">
        <span class="far fa-file-alt"></span>
         
        Testing the bot status of users in Twitter networks collected via vosonSML
      </a>
    </li>
  </ul>
</li>
      </ul>
<ul class="nav navbar-nav navbar-right">
<li>
  <a href="http://vosonlab.net/" class="external-link">
    <span class="fa fa-flask fa-lg"></span>
     
  </a>
</li>
<li>
  <a href="https://twitter.com/vosonlab" class="external-link">
    <span class="fab fa-twitter-square fa-lg"></span>
     
  </a>
</li>
<li>
  <a href="https://github.com/vosonlab/vosonSML" class="external-link">
    <span class="fab fa-github fa-lg"></span>
     
  </a>
</li>
      </ul>
</div>
<!--/.nav-collapse -->
  </div>
<!--/.container -->
</div>
<!--/.navbar -->

      

      </header><div class="row">
  <div class="col-md-9 contents">
    <div class="page-header toc-ignore">
      <h1 data-toc-skip>Twitter Usage</h1>
            
            <h4 data-toc-skip class="date">25 May, 2024</h4>
      
      <small class="dont-index">Source: <a href="https://github.com/vosonlab/vosonSML/blob/HEAD/vignettes/Twitter-Usage.Rmd" class="external-link"><code>vignettes/Twitter-Usage.Rmd</code></a></small>
      <div class="hidden name"><code>Twitter-Usage.Rmd</code></div>

    </div>

    
    
<p>The Twitter features of vosonSML use the <code>rtweet</code> package,
please ensure version <code>1.1</code> or later is installed.</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/utils/packageDescription.html" class="external-link">packageVersion</a></span><span class="op">(</span><span class="st">"rtweet"</span><span class="op">)</span></span>
<span><span class="co">## [1] '1.1.0'</span></span></code></pre></div>
<div class="section level2">
<h2 id="importing-tweets-from-rtweet">
<a name="twitter-import"></a>Importing tweets from rtweet<a class="anchor" aria-label="anchor" href="#importing-tweets-from-rtweet"></a>
</h2>
<p>Because <code>vosonSML</code> uses the <code>rtweet</code> package to
access and collect tweets data, <code>rtweet</code> data is also able to
be easily imported from dataframe or file and then transformed into a
<code>Collect</code> object for use in creating networks.</p>
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">tw_auth_rt</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/readRDS.html" class="external-link">readRDS</a></span><span class="op">(</span><span class="st">"~/.rtweet_oauth1a"</span><span class="op">)</span></span>
<span></span>
<span><span class="va">tweets</span> <span class="op">&lt;-</span> <span class="fu">rtweet</span><span class="fu">::</span><span class="fu"><a href="https://docs.ropensci.org/rtweet/reference/search_tweets.html" class="external-link">search_tweets</a></span><span class="op">(</span><span class="st">"#auspol"</span>, n <span class="op">=</span> <span class="fl">20</span>, token <span class="op">=</span> <span class="va">tw_auth_rt</span><span class="op">)</span></span>
<span><span class="va">data_tw</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/ImportRtweet.html">ImportRtweet</a></span><span class="op">(</span><span class="va">tweets</span><span class="op">)</span></span>
<span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/names.html" class="external-link">names</a></span><span class="op">(</span><span class="va">data_tw</span><span class="op">)</span></span>
<span><span class="co">## [1] "tweets" "users"</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/class.html" class="external-link">class</a></span><span class="op">(</span><span class="va">data_tw</span><span class="op">)</span></span>
<span><span class="co">## [1] "datasource" "twitter"    "list"</span></span></code></pre></div>
</div>
<div class="section level2">
<h2 id="authenticate-with-the-twitter-api">Authenticate with the Twitter API<a class="anchor" aria-label="anchor" href="#authenticate-with-the-twitter-api"></a>
</h2>
<p><code>Authenticate</code> is used to create an object that contains a
Twitter token for accessing the Twitter API. This can and should be
re-used by saving it once to file after calling
<code>Authenticate</code> and then by loading it again during future
sessions.</p>
<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://github.com/vosonlab/vosonSML" class="external-link">vosonSML</a></span><span class="op">)</span></span>
<span></span>
<span><span class="co"># twitter authentication creates an access token as part of the auth object</span></span>
<span><span class="va">auth_tw_bearer</span> <span class="op">&lt;-</span> <span class="fu"><a href="../reference/Authenticate.html">Authenticate</a></span><span class="op">(</span><span class="st">"twitter"</span>, bearerToken <span class="op">=</span> <span class="st">"xxxxxxxxxxxx"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># save the object to file after authenticate</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/readRDS.html" class="external-link">saveRDS</a></span><span class="op">(</span><span class="va">auth_tw_bearer</span>, file <span class="op">=</span> <span class="st">"~/.auth_tw_bearer"</span><span class="op">)</span></span></code></pre></div>
<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># load a previously saved auth object for use in collect</span></span>
<span><span class="va">auth_tw_bearer</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/readRDS.html" class="external-link">readRDS</a></span><span class="op">(</span><span class="st">"~/.auth_tw_bearer"</span><span class="op">)</span></span></code></pre></div>
</div>
<div class="section level2">
<h2 id="collect-tweets-using-a-search-or-from-user-timelines">Collect tweets using a search or from user timelines<a class="anchor" aria-label="anchor" href="#collect-tweets-using-a-search-or-from-user-timelines"></a>
</h2>
<p><code>Collect</code> can be used to perform a twitter search with a
search term or collect tweets from timelines using user names. The
following example collects 100 <code>recent</code> tweets for the
hashtag <code>#auspol</code> and creates a dataframe with the collected
tweet data.</p>
<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># set output data directory</span></span>
<span><span class="fu"><a href="https://rdrr.io/r/base/options.html" class="external-link">options</a></span><span class="op">(</span>voson.data <span class="op">=</span> <span class="st">"./vsml-data"</span><span class="op">)</span></span>
<span></span>
<span><span class="co"># collect 100 recent tweets for the hashtag #auspol</span></span>
<span><span class="va">collect_tw</span> <span class="op">&lt;-</span> <span class="va">auth_tw_bearer</span> <span class="op">|&gt;</span></span>
<span>  <span class="fu"><a href="../reference/Collect.html">Collect</a></span><span class="op">(</span>searchTerm <span class="op">=</span> <span class="st">"#auspol"</span>,</span>
<span>          searchType <span class="op">=</span> <span class="st">"recent"</span>,</span>
<span>          numTweets <span class="op">=</span> <span class="fl">100</span>,</span>
<span>          includeRetweets <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>          writeToFile <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>          verbose <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="co">## Collecting tweets for search query...</span></span>
<span><span class="co">## Search term: #auspol</span></span>
<span><span class="co">## Requested 100 tweets of 44900 in this search rate limit.</span></span>
<span><span class="co">## Rate limit reset: 2023-04-02 07:43:58</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## tweet        | status_id           | created            </span></span>
<span><span class="co">## --------------------------------------------------------</span></span>
<span><span class="co">## Latest Obs   | 1642429383460925441 | 2023-04-02 07:30:54</span></span>
<span><span class="co">## Earliest Obs | 1642428234058039297 | 2023-04-02 07:26:20</span></span>
<span><span class="co">## Collected 100 tweets.</span></span>
<span><span class="co">## RDS file written: ./vsml-data/2023-04-02_073109-TwitterData.rds</span></span>
<span><span class="co">## Done.</span></span></code></pre></div>
<p>The next example collects the 100 most recent tweets from the
<code>@vosonlab</code> and <code>@ANU_SOC</code> user timelines. Note
that this method requires the <code>endpoint = "timeline"</code>
parameter.</p>
<div class="sourceCode" id="cb6"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># collect 100 timeline tweets for each specified user</span></span>
<span><span class="va">collect_tw_tl</span> <span class="op">&lt;-</span> <span class="va">auth_tw_bearer</span> <span class="op">|&gt;</span></span>
<span>  <span class="fu"><a href="../reference/Collect.html">Collect</a></span><span class="op">(</span>endpoint <span class="op">=</span> <span class="st">"timeline"</span>,</span>
<span>          users <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"vosonlab"</span>, <span class="st">"ANU_SOCY"</span><span class="op">)</span>,</span>
<span>          numTweets <span class="op">=</span> <span class="fl">100</span>,</span>
<span>          writeToFile <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>          verbose <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="co">## Collecting timeline tweets for users...</span></span>
<span><span class="co">## Requested 200 tweets of 149800 in this search rate limit.</span></span>
<span><span class="co">## Rate limit reset: 2023-04-02 07:44:01</span></span>
<span><span class="co">## </span></span>
<span><span class="co">## tweet        | status_id           | created            </span></span>
<span><span class="co">## --------------------------------------------------------</span></span>
<span><span class="co">## Latest Obs   | 1641303253823680512 | 2023-03-30 04:56:04</span></span>
<span><span class="co">## Earliest Obs | 1437995199636983808 | 2021-09-15 04:22:26</span></span>
<span><span class="co">## Collected 200 tweets.</span></span>
<span><span class="co">## RDS file written: ./vsml-data/2023-04-02_073113-TwitterData.rds</span></span>
<span><span class="co">## Done.</span></span></code></pre></div>
<p>The output for these methods also lists the earliest and most recent
tweet as well as the number of tweets collected.</p>
</div>
<div class="section level2">
<h2 id="create-twitter-activity-actor-semantic-and-2-mode-network-graphs">Create twitter activity, actor, semantic and 2-mode network
graphs<a class="anchor" aria-label="anchor" href="#create-twitter-activity-actor-semantic-and-2-mode-network-graphs"></a>
</h2>
<p>The twitter <code>Create</code> function accepts the data from
<code>Collect</code> and a type parameter of <code>activity</code>,
<code>actor</code>, <code>semantic</code> or <code>twomode</code> that
specifies the type of network to create from the collected data.
<code>Create</code> produces two dataframes, one for network
<code>nodes</code> and one for node relations or <code>edges</code> in
the network. These can then undergo further processing as per the <a href="https://vosonlab.github.io/vosonSML/#supplemental-functions" class="external-link">supplemental
functions</a> section or be passed to the <code>Graph</code> function
that creates an <code>igraph</code> object.</p>
<div class="section level3">
<h3 id="activity-network">Activity network<a class="anchor" aria-label="anchor" href="#activity-network"></a>
</h3>
<p>Nodes are tweets and edges are the relationship to other tweets such
as <code>reply</code>, <code>retweet</code> or <code>quote</code>
tweets.</p>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">net_activity</span> <span class="op">&lt;-</span> <span class="va">collect_tw</span> <span class="op">|&gt;</span> <span class="fu"><a href="../reference/Create.html">Create</a></span><span class="op">(</span><span class="st">"activity"</span>, verbose <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="co">## Generating twitter activity network...</span></span>
<span><span class="co">## -------------------------</span></span>
<span><span class="co">## collected tweets | 100</span></span>
<span><span class="co">## tweet            | 2 </span></span>
<span><span class="co">## retweet          | 92</span></span>
<span><span class="co">## reply            | 4 </span></span>
<span><span class="co">## quote            | 2 </span></span>
<span><span class="co">## nodes            | 167</span></span>
<span><span class="co">## edges            | 100</span></span>
<span><span class="co">## -------------------------</span></span>
<span><span class="co">## Done.</span></span></code></pre></div>
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">g_activity</span> <span class="op">&lt;-</span> <span class="va">net_activity</span> <span class="op">|&gt;</span> <span class="fu"><a href="../reference/Graph.html">Graph</a></span><span class="op">(</span>writeToFile <span class="op">=</span> <span class="cn">TRUE</span>, verbose <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="co">## Creating igraph network graph...</span></span>
<span><span class="co">## GRAPHML file written: ./vsml-data/2023-04-02_173114-TwitterActivity.graphml</span></span>
<span><span class="co">## Done.</span></span>
<span></span>
<span><span class="va">g_activity</span></span>
<span><span class="co">## IGRAPH 5943f8d DN-- 167 100 -- </span></span>
<span><span class="co">## + attr: type (g/c), name (v/c), author_id (v/c), author_screen_name</span></span>
<span><span class="co">## | (v/c), created_at (v/c), user_id (e/c), screen_name (e/c), created_at</span></span>
<span><span class="co">## | (e/c), edge_type (e/c)</span></span>
<span><span class="co">## + edges from 5943f8d (vertex names):</span></span>
<span><span class="co">##  [1] 1642429383460925441-&gt;1642343694660677632</span></span>
<span><span class="co">##  [2] 1642429382257147904-&gt;1641392034991726592</span></span>
<span><span class="co">## + ... omitted several edges</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="actor-network">Actor network<a class="anchor" aria-label="anchor" href="#actor-network"></a>
</h3>
<p>Nodes are twitter users and edges are the relationship to other users
in the network such as <code>reply</code>, <code>mention</code>,
<code>retweet</code> and <code>quote</code> tweets. Mentions can be
excluded by setting the parameter <code>inclMentions</code> to
<code>FALSE</code>.</p>
<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">net_actor</span> <span class="op">&lt;-</span> <span class="va">collect_tw</span> <span class="op">|&gt;</span></span>
<span>  <span class="fu"><a href="../reference/Create.html">Create</a></span><span class="op">(</span><span class="st">"actor"</span>, inclMentions <span class="op">=</span> <span class="cn">TRUE</span>, verbose <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="co">## Generating twitter actor network...</span></span>
<span><span class="co">## -------------------------</span></span>
<span><span class="co">## collected tweets | 100</span></span>
<span><span class="co">## tweet            | 2 </span></span>
<span><span class="co">## retweet          | 92</span></span>
<span><span class="co">## reply mention    | 1 </span></span>
<span><span class="co">## reply            | 4 </span></span>
<span><span class="co">## quote mention    | 3 </span></span>
<span><span class="co">## quote            | 2 </span></span>
<span><span class="co">## nodes            | 125</span></span>
<span><span class="co">## edges            | 104</span></span>
<span><span class="co">## -------------------------</span></span>
<span><span class="co">## Done.</span></span></code></pre></div>
<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">g_actor</span> <span class="op">&lt;-</span> <span class="va">net_actor</span> <span class="op">|&gt;</span> <span class="fu"><a href="../reference/Graph.html">Graph</a></span><span class="op">(</span>writeToFile <span class="op">=</span> <span class="cn">TRUE</span>, verbose <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="co">## Creating igraph network graph...</span></span>
<span><span class="co">## GRAPHML file written: ./vsml-data/2023-04-02_173115-TwitterActor.graphml</span></span>
<span><span class="co">## Done.</span></span>
<span></span>
<span><span class="va">g_actor</span></span>
<span><span class="co">## IGRAPH 59a5dc7 DN-- 125 104 -- </span></span>
<span><span class="co">## + attr: type (g/c), name (v/c), screen_name (v/c), status_id (e/c),</span></span>
<span><span class="co">## | created_at (e/c), edge_type (e/c)</span></span>
<span><span class="co">## + edges from 59a5dc7 (vertex names):</span></span>
<span><span class="co">##  [1] 2849412290         -&gt;2882834947</span></span>
<span><span class="co">##  [2] 141563430          -&gt;4168028659</span></span>
<span><span class="co">## + ... omitted several edges</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="semantic-network">Semantic network<a class="anchor" aria-label="anchor" href="#semantic-network"></a>
</h3>
<p>Nodes are concepts represented as common <code>words</code> and
<code>hashtags</code>. Edges represent the occurence of a particular
word and a particular hashtag in the same tweet. The semantic network is
<code>undirected</code>.</p>
<div class="sourceCode" id="cb11"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="co"># install additional required packages</span></span>
<span><span class="co"># install.packages("stopwords")</span></span>
<span></span>
<span><span class="co"># create a semantic network excluding the hashtag #auspol, include only the</span></span>
<span><span class="co"># top 10% most frequent words and 20% most frequent hashtags as nodes</span></span>
<span><span class="va">net_semantic</span> <span class="op">&lt;-</span> <span class="va">collect_tw</span> <span class="op">|&gt;</span></span>
<span>  <span class="fu"><a href="../reference/Create.html">Create</a></span><span class="op">(</span></span>
<span>    <span class="st">"semantic"</span>,</span>
<span>    removeTermsOrHashtags <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"#auspol"</span><span class="op">)</span>,</span>
<span>    termFreq <span class="op">=</span> <span class="fl">10</span>,</span>
<span>    hashtagFreq <span class="op">=</span> <span class="fl">20</span>,</span>
<span>    verbose <span class="op">=</span> <span class="cn">TRUE</span></span>
<span>  <span class="op">)</span></span>
<span><span class="co">## Generating twitter semantic network...</span></span>
<span><span class="co">## Removing terms and hashtags: #auspol</span></span>
<span><span class="co">## -------------------------</span></span>
<span><span class="co">## retweets                 | 92</span></span>
<span><span class="co">## tokens                   | 231</span></span>
<span><span class="co">## removed specified        | 8 </span></span>
<span><span class="co">## removed users            | 7 </span></span>
<span><span class="co">## hashtag count            | 9 </span></span>
<span><span class="co">## hashtags unique          | 9 </span></span>
<span><span class="co">## term count               | 89</span></span>
<span><span class="co">## terms unique             | 85</span></span>
<span><span class="co">## top 20% hashtags n (&gt;=1) | 9 </span></span>
<span><span class="co">## top 10% terms n (&gt;=1)    | 85</span></span>
<span><span class="co">## nodes                    | 41</span></span>
<span><span class="co">## edges                    | 91</span></span>
<span><span class="co">## -------------------------</span></span>
<span><span class="co">## Done.</span></span></code></pre></div>
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">g_semantic</span> <span class="op">&lt;-</span> <span class="va">net_semantic</span> <span class="op">|&gt;</span> <span class="fu"><a href="../reference/Graph.html">Graph</a></span><span class="op">(</span>writeToFile <span class="op">=</span> <span class="cn">TRUE</span>, verbose <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="co">## Creating igraph network graph...</span></span>
<span><span class="co">## GRAPHML file written: ./vsml-data/2023-04-02_173115-TwitterSemantic.graphml</span></span>
<span><span class="co">## Done.</span></span>
<span></span>
<span><span class="va">g_semantic</span></span>
<span><span class="co">## IGRAPH 59de049 UN-B 41 91 -- </span></span>
<span><span class="co">## + attr: type (g/c), name (v/c), type (v/c), n (v/n), from.type (e/c),</span></span>
<span><span class="co">## | to.type (e/c), status_id (e/c)</span></span>
<span><span class="co">## + edges from 59de049 (vertex names):</span></span>
<span><span class="co">##  [1] immoral     --#assisteddy... immoral     --#vad</span></span>
<span><span class="co">##  [3] immoral     --#endoflif...   immoral     --#humanrights</span></span>
<span><span class="co">## + ... omitted several edges</span></span></code></pre></div>
</div>
<div class="section level3">
<h3 id="mode-network">2-mode network<a class="anchor" aria-label="anchor" href="#mode-network"></a>
</h3>
<p>Nodes are twitter <code>users</code> or <code>hashtags</code>. Edges
represent the use of a <code>hashtag</code> or the reference to another
<code>user</code> in a tweet. The <code>weighted</code> parameter will
add a simple frequency weight column for <code>edges</code>.</p>
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">net_2mode</span> <span class="op">&lt;-</span> <span class="va">collect_tw</span> <span class="op">|&gt;</span></span>
<span>  <span class="fu"><a href="../reference/Create.html">Create</a></span><span class="op">(</span><span class="st">"twomode"</span>, </span>
<span>         removeTermsOrHashtags <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="st">"#auspol"</span><span class="op">)</span>,</span>
<span>         weighted <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>         verbose <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="co">## Generating twitter 2-mode network...</span></span>
<span><span class="co">## Removing terms and hashtags: #auspol</span></span>
<span><span class="co">## -------------------------</span></span>
<span><span class="co">## collected tweets  | 100</span></span>
<span><span class="co">## removed specified | 8 </span></span>
<span><span class="co">## users             | 7 </span></span>
<span><span class="co">## hashtags          | 9 </span></span>
<span><span class="co">## nodes             | 22</span></span>
<span><span class="co">## edges             | 16</span></span>
<span><span class="co">## -------------------------</span></span>
<span><span class="co">## Done.</span></span></code></pre></div>
<div class="sourceCode" id="cb14"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">g_2mode</span> <span class="op">&lt;-</span> <span class="va">net_2mode</span> <span class="op">|&gt;</span> <span class="fu"><a href="../reference/Graph.html">Graph</a></span><span class="op">(</span>writeToFile <span class="op">=</span> <span class="cn">TRUE</span>, verbose <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="co">## Creating igraph network graph...</span></span>
<span><span class="co">## GRAPHML file written: ./vsml-data/2023-04-02_173115-Twitter2mode.graphml</span></span>
<span><span class="co">## Done.</span></span>
<span></span>
<span><span class="fu">mask</span><span class="op">(</span><span class="va">g_2mode</span><span class="op">)</span></span>
<span><span class="co">## IGRAPH 59f5de1 DNWB 22 16 -- </span></span>
<span><span class="co">## + attr: type (g/c), name (v/c), type (v/c), user_id (v/c), screen_name</span></span>
<span><span class="co">## | (v/c), status_id (e/c), created_at (e/c), is_retweet (e/l), is_quote</span></span>
<span><span class="co">## | (e/l), is_reply (e/l), weight (e/n)</span></span>
<span><span class="co">## + edges from 59f5de1 (vertex names):</span></span>
<span><span class="co">##  [1] @uxxxxxxxxxlg  -&gt;#assisteddy...   @uxxxxxxxxxlg  -&gt;#vad            </span></span>
<span><span class="co">##  [3] @uxxxxxxxxxlg  -&gt;#endoflif...     @uxxxxxxxxxlg  -&gt;#humanrights    </span></span>
<span><span class="co">##  [5] @axxxxdo       -&gt;#turnbull        @axxxxdo       -&gt;#murdoch        </span></span>
<span><span class="co">##  [7] @axxxxdo       -&gt;#media           @cxxxxxxxxbc   -&gt;@cxxxxxxxxxnl</span></span>
<span><span class="co">## + ... omitted several edges</span></span></code></pre></div>
</div>
</div>
  </div>

  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">

        <nav id="toc" data-toggle="toc"><h2 data-toc-skip>Contents</h2>
    </nav>
</div>

</div>



      <footer><div class="copyright">
  <p></p>
<p>Developed by Bryan Gertzel, Robert Ackland, Timothy Graham.</p>
</div>

<div class="pkgdown">
  <p></p>
<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.9.</p>
</div>

      </footer>
</div>

  


  

  </body>
</html>
