<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Katherine Ognyanova</title>
<link>https://kateto.net/blog/</link>
<atom:link href="https://kateto.net/blog/index.xml" rel="self" type="application/rss+xml"/>
<description>Posts by Katherine Ognyanova: tutorials, R code, and notes on network data. Not frequent, but still useful.</description>
<image>
<url>https://kateto.net/images/share-card.jpg</url>
<title>Katherine Ognyanova</title>
<link>https://kateto.net/blog/</link>
</image>
<generator>quarto-1.9.38</generator>
<lastBuildDate>Tue, 10 Nov 2026 05:00:00 GMT</lastBuildDate>
<item>
  <title>Computational social science R code</title>
  <link>https://kateto.net/computational-social-science-r-code/</link>
  <description><![CDATA[ 





<p>This page collects R code and materials from my <em>Computational Social Science</em> course at Rutgers University. The course combines theoretical discussion with hands-on training in R. It is a doctoral seminar that offers a gentle introduction to computational methods, both for people with some coding experience and for those just starting to learn. Topics include an introduction to R, survey data analysis, APIs, web scraping, network analysis, data visualization, text analysis, large language models, machine learning, and research ethics.</p>
<div class="btn-row">
<p><a href="..\css/2026/SCI 630 CSS Syllabus - Ognyanova - 2026.pdf" class="btn-k">2026 syllabus (PDF)</a> <a href="https://github.com/kateto/Computational_Social_Science_Course_R_Code" class="btn-k ghost">GitHub repository</a></p>
</div>
<section id="r-code-for-the-2026-lectures" class="level2">
<h2 data-anchor-id="r-code-for-the-2026-lectures">R code for the 2026 lectures</h2>
<div class="courses">
<ul>
<li><a href="..\css/2026/CSS - Week 02 - Intro.R" class="ptitle">Introduction to R</a> <span class="venue">Data types and structures, flow control, packages, reading and writing files</span></li>
<li><a href="..\css/2026/CSS - Week 03 - Surveys.R" class="ptitle">Analyzing survey data</a> <span class="venue">Descriptives, recoding, regression, survey weights</span></li>
<li><a href="..\css/2026/CSS - Week 04 - APIs.R" class="ptitle">Working with APIs</a> <span class="venue">Collecting Bluesky posts, followers, and threads</span></li>
<li><a href="..\css/2026/CSS - Week 05 - Web Scraping.R" class="ptitle">Web scraping</a> <span class="venue">rvest, XPath, regular expressions</span></li>
<li><a href="..\css/2026/CSS - Week 06 - Networks I Intro.R" class="ptitle">Network analysis 1</a> <span class="venue">Network data, descriptives, plots, and layouts</span></li>
<li><a href="..\css/2026/CSS - Week 07 - Networks II Ties.R" class="ptitle">Network analysis 2</a> <span class="venue">Reciprocity, transitivity, homophily</span></li>
<li><a href="..\css/2026/CSS - Week 08 - Networks III ERGM.R" class="ptitle">Network analysis 3</a> <span class="venue">Exponential random graph models</span></li>
<li><a href="..\css/2026/CSS - Week 09 - Visualization.R" class="ptitle">Data visualization</a> <span class="venue">Introduction to ggplot2</span></li>
<li><a href="..\css/2026/CSS - Week 10 - Text I.R" class="ptitle">Text analysis 1</a> <span class="venue">Preprocessing, term frequencies, tf-idf, sentiment</span></li>
<li><a href="..\css/2026/CSS - Week 11 - Text II.R" class="ptitle">Text analysis 2</a> <span class="venue">N-grams, topic models, structural topic models</span></li>
<li><a href="..\css/2026/CSS - Week 12 - LLMs I.R" class="ptitle">Large language models 1</a> <span class="venue">Classification, extraction, summarization, structured output, images</span></li>
<li><a href="..\css/2026/CSS - Week 13 - LLMs II.R" class="ptitle">Large language models 2</a> <span class="venue">Personas, prompt design, comparing models, validation</span></li>
<li><a href="..\css/2026/CSS - Week 14 - Machine Learning.R" class="ptitle">Machine learning</a> <span class="venue">tidymodels, classification, regression</span></li>
</ul>
</div>
</section>
<section id="data" class="level2">
<h2 data-anchor-id="data">Data</h2>
<p>The scripts download most of what they need. You can also get the data files here:</p>
<div class="courses">
<ul>
<li><a href="..\css/pew_data.zip" class="ptitle">Survey data</a> <span class="venue">Pew Research Center survey with codebook (Week 3)</span></li>
<li><a href="..\css/network_data.zip" class="ptitle">Network data</a> <span class="venue">Example networks (Weeks 6–7)</span></li>
<li><a href="..\css/sotu_data.zip" class="ptitle">State of the Union speeches</a> <span class="venue">Text data (Week 11)</span></li>
<li><a href="..\css/2026/llm_images.zip" class="ptitle">Images for the LLM examples</a> <span class="venue">Photos and memes (Weeks 12–13)</span></li>
</ul>
</div>
<p>The LLM scripts need your own API keys for OpenAI, Gemini, or the Guardian; the code shows where to set them.</p>
</section>
<section id="recommended-books" class="level2">
<h2 data-anchor-id="recommended-books">Recommended books</h2>
<ul>
<li>Salganik, M. J. (2017). <em>Bit by bit: Social research in the digital age.</em> <a href="https://www.bitbybitbook.com/en/1st-ed/preface/">Read online</a>.</li>
<li>Wickham, H., Çetinkaya-Rundel, M., &amp; Grolemund, G. (2023). <em>R for data science</em> (2nd ed.). <a href="https://r4ds.hadley.nz/">Read online</a>.</li>
<li>Long, J. D., &amp; Teetor, P. (2019). <em>R cookbook</em> (2nd ed.). <a href="https://rc2e.com/">Read online</a>.</li>
<li>Silge, J., &amp; Robinson, D. (2017). <em>Text mining with R.</em> <a href="https://www.tidytextmining.com/">Read online</a>.</li>
</ul>
</section>
<section id="earlier" class="level2">
<h2 data-anchor-id="earlier">The 2023 version</h2>
<p>The 2023 version of the course had separate weeks on network groups and communities (QAP, permutation tests) and did not cover large language models. Its materials are still available.</p>
<div class="courses">
<ul>
<li><a href="..\css/SCI 672 CSS Syllabus - Ognyanova - 2023.pdf" class="ptitle">2023 syllabus (PDF)</a> <span class="venue">16:194:672, Spring 2023</span></li>
<li><a href="..\css/CSS - Week 02 - Intro.R" class="ptitle">Introduction to R</a> <span class="venue">Data formats, flow control, packages</span></li>
<li><a href="..\css/CSS - Week 03 - Surveys.R" class="ptitle">Analyzing survey data</a> <span class="venue">Descriptives, recoding, GLM, weights</span></li>
<li><a href="..\css/CSS - Week 04 - APIs.R" class="ptitle">Working with APIs</a> <span class="venue">Twitter, Reddit, Internet Archive, bibliometrics</span></li>
<li><a href="..\css/CSS - Week 05 - Web Scraping.R" class="ptitle">Web scraping</a> <span class="venue">rvest, XPath, pattern matching</span></li>
<li><a href="..\css/CSS - Week 06 - Networks I Intro.R" class="ptitle">Network analysis 1</a> <span class="venue">Network data, network descriptives</span></li>
<li><a href="..\css/CSS - Week 07 - Networks II Ties.R" class="ptitle">Network analysis 2</a> <span class="venue">Reciprocity, transitivity, homophily</span></li>
<li><a href="..\css/CSS - Week 08 - Networks III Groups.R" class="ptitle">Network analysis 3</a> <span class="venue">Communities, permutation tests, QAP and netlm</span></li>
<li><a href="..\css/CSS - Week 09 - Networks IV ERGM.R" class="ptitle">Network analysis 4</a> <span class="venue">Exponential random graph models</span></li>
<li><a href="..\css/CSS - Week 10 - Visualization.R" class="ptitle">Data visualization</a> <span class="venue">Introduction to ggplot2</span></li>
<li><a href="..\css/CSS - Week 11 - Text I.R" class="ptitle">Text analysis 1</a> <span class="venue">Preprocessing, term frequencies, sentiment</span></li>
<li><a href="..\css/CSS - Week 12 - Text II.R" class="ptitle">Text analysis 2</a> <span class="venue">N-grams, topic models</span></li>
<li><a href="..\css/CSS - Week 13 - Machine Learning.R" class="ptitle">Machine learning</a> <span class="venue">tidymodels, classification, regression</span></li>
</ul>
</div>


</section>

 ]]></description>
  <guid>https://kateto.net/computational-social-science-r-code/</guid>
  <pubDate>Tue, 10 Nov 2026 05:00:00 GMT</pubDate>
  <media:content url="https://kateto.net/images/tut-css.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Static and dynamic network visualization with R</title>
  <link>https://kateto.net/network-visualization/</link>
  <description><![CDATA[ 





<p>This is a comprehensive tutorial on network visualization with R. It covers data input and formats, visualization basics, parameters and layouts for one-mode and bipartite graphs, multiplex links, interactive and animated visualization for longitudinal networks, and visualizing networks on geographic maps. To follow along, download the code and data below and use <a href="https://cran.r-project.org/">R</a> and <a href="https://posit.co/download/rstudio-desktop/">RStudio</a>.</p>
<div class="btn-row">
<p><a href="..\polnet2025.html" class="btn-k">Open the full-page tutorial</a> <a href="..\workshops/polnet/polnet2025.pdf" class="btn-k ghost">PDF version</a> <a href="..\workshops/polnet/polnet2025.zip" class="btn-k ghost">Code &amp; data (zip)</a> <a href="https://github.com/kateto/R-Network-Visualization-Workshop" class="btn-k ghost">GitHub</a></p>
</div>
<div class="cite-box">
<p><span class="label">Please cite</span> If you find the tutorial useful, please cite it in your work. This helps me make the case that open publishing of digital materials like this is a meaningful academic contribution.</p>
<p>Ognyanova, K. (2025). <em>Network visualization with R.</em> Retrieved from www.kateto.net/network-visualization</p>
</div>
<p>The tutorial is continuously updated and expanded. Earlier versions are still available: <a href="..\wp-content/uploads/2015/06/polnet.html">2015</a>, <a href="..\polnet2016.html">2016</a>, <a href="..\polnet2017.html">2017</a>, <a href="..\polnet2018.html">2018</a>, <a href="..\polnet2019.html">2019</a>, <a href="..\polnet2021.html">2021</a>, <a href="..\polnet2022.html">2022</a>, <a href="..\polnet2023.html">2023</a>, <a href="..\polnet2024.html">2024</a>. You can also find <a href="..\tutorials/">my other tutorials here</a>. Universities, companies, or government agencies interested in training or workshops can email <a href="mailto:workshop@ognyanova.net">workshop@ognyanova.net</a>.</p>
<p>The tutorial is below. It contains many images and JavaScript animations, so it may take a moment to load.</p>
<iframe class="tutorial-frame" src="../polnet2025.html" title="Network visualization with R: full tutorial" loading="lazy"></iframe>



 ]]></description>
  <guid>https://kateto.net/network-visualization/</guid>
  <pubDate>Tue, 12 Aug 2025 04:00:00 GMT</pubDate>
  <media:content url="https://kateto.net/images/tut-netviz.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Network datasets</title>
  <link>https://kateto.net/network-datasets/</link>
  <description><![CDATA[ 





<p>Since I started posting network tutorials on this site, people occasionally write to ask about the included example datasets. I also get emails asking where to find network data for a project or for teaching, so here is a quick answer.</p>
<p>The datasets in my tutorials are mostly synthetic (or trimmed and heavily manipulated) to illustrate visualization techniques in a manageable way. Feel free to use them (citing or linking to the source is appreciated), but keep in mind that they are artificially generated and not the result of actual data collection. When I do use empirical data, the download files include documentation (if I collected the data) or clearly point to the source (if someone else did).</p>
<p>If you are looking for network data, large or small, there are several excellent open repositories. Here is a short list; feel free to email me other good links and I will add them.</p>
<ul>
<li><a href="https://snap.stanford.edu/data/">Stanford Large Network Dataset Collection</a></li>
<li><a href="https://networkdata.ics.uci.edu/">UCI Network Data Repository</a></li>
<li><a href="https://networkrepository.com/">Network Data Repository</a></li>
<li><a href="https://datasets.syr.edu/">ASU social computing data repository</a></li>
<li><a href="https://luddy.indiana.edu/research/research-areas/complex-networks-systems.html">Indiana University CNetS data</a></li>
<li><a href="https://konect.cc/networks/">KONECT, the Koblenz Network Collection</a></li>
<li><a href="https://sociopatterns.org/datasets.html">SocioPatterns datasets</a></li>
<li><a href="https://sites.google.com/site/ucinetsoftware/datasets">UCINET datasets</a></li>
<li><a href="http://vlado.fmf.uni-lj.si/pub/networks/data/">Pajek datasets</a></li>
</ul>
<p>Another good place to find links to network resources, including data repositories, is the <a href="https://github.com/briatte/awesome-network-analysis">Awesome Network Analysis</a> list curated by <a href="https://github.com/briatte">François Briatte</a>.</p>
<p>For network data to use in teaching, I also recommend having students collect their own data, for instance from social media platforms with an open API, or by running a short name-generator survey of their own class.</p>



 ]]></description>
  <guid>https://kateto.net/network-datasets/</guid>
  <pubDate>Tue, 24 May 2016 04:00:00 GMT</pubDate>
  <media:content url="https://kateto.net/images/post-datasets.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Network analysis with R and igraph</title>
  <link>https://kateto.net/networks-r-igraph/</link>
  <description><![CDATA[ 





<p>This tutorial is a basic introduction to the R language and the <a href="https://igraph.org/r/">igraph</a> package for network analysis and visualization. It covers network generation, data input and processing, and the basics of graph analysis and visualization. A more recent tutorial covering network basics in R and igraph is <a href="..\tutorials/">on the tutorials page</a>.</p>
<div class="btn-row">
<p><a href="..\netscix2016.html" class="btn-k">Open the full-page tutorial</a> <a href="..\wp-content/uploads/2016/01/NetSciX_2016_Workshop.pdf" class="btn-k ghost">PDF version</a> <a href="http://bit.ly/netscix2016" class="btn-k ghost">Code &amp; data</a> <a href="https://github.com/kateto/R-igraph-Network-Workshop-NetSciX" class="btn-k ghost">GitHub</a></p>
</div>
<div class="cite-box">
<p><span class="label">Please cite</span> Ognyanova, K. (2016). <em>Network analysis with R and igraph: NetSci X Tutorial.</em> Retrieved from www.kateto.net/networks-r-igraph</p>
</div>
<iframe class="tutorial-frame" src="../netscix2016.html" title="Network analysis with R and igraph: full tutorial" loading="lazy"></iframe>



 ]]></description>
  <guid>https://kateto.net/networks-r-igraph/</guid>
  <pubDate>Sun, 10 Jan 2016 05:00:00 GMT</pubDate>
  <media:content url="https://kateto.net/images/tut-igraph.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Deleted congressional tweets: the R code</title>
  <link>https://kateto.net/deleted-congressional-tweets-the-r-code/</link>
  <description><![CDATA[ 





<div class="note-box">
<p>If you are interested in analyzing the deleted tweets of politicians, my R package <a href="https://github.com/kateto/PolitwoopsR">PolitwoopsR</a> is on GitHub. Also see <a href="https://gist.github.com/kateto/7da13df064fffaa3b8ab">this R script examining deleted tweets</a>. This post is from 2015, and the Politwoops and Twitter APIs it relies on have changed since. If you were brought here by a Dean Richards Twitter bot, read this.</p>
</div>
<p><a href="..\politwoops/"><img src="https://kateto.net/wp-content/uploads/2015/03/Politwoops-All-Charts-2015.png" class="fig-center img-fluid" alt="Politwoops charts" width="500"></a></p>
<p>A few days ago I published <a href="..\politwoops/">a post with interactive visualizations</a> of the deleted tweets of US politicians. Those tweets were collected by the <a href="https://web.archive.org/web/2015/https://politwoops.com/">Politwoops project</a> (now offline; the link opens an archived copy), maintained in the US by the <a href="https://sunlightfoundation.com/">Sunlight Foundation</a>. I promised to post the R code that grabs the tweet and politician data, cleans it, and generates the charts. As I started organizing the code, it seemed easy to take the next step and create a package that handles the data collection.</p>
<p>The <a href="https://github.com/kateto/PolitwoopsR">PolitwoopsR package</a> includes functions that extract tweet data from most of the country-specific Politwoops projects. It also provides a way to scrape politician information, though that only works with the US project. I have tested it with only a few countries (US, UK, Argentina), so you may still run into bugs with countries that use a non-standard JSON format or URL form.</p>
<p>I have also posted an example script in <a href="https://gist.github.com/kateto/7da13df064fffaa3b8ab">this GitHub gist</a> that collects and cleans this type of data. It includes the following steps:</p>
<ul>
<li>Getting the data using the PolitwoopsR package</li>
<li>Expanding the short URLs in tweets and extracting domains</li>
<li>Detecting the language of the tweets</li>
<li>Cleaning the tweet text, stemming and stem completion, top terms</li>
<li>Top hashtags by political party</li>
<li>Tweet sentiment and polarity</li>
<li>Collecting additional data from Twitter with the <a href="https://cran.r-project.org/package=twitteR">twitteR package</a></li>
<li>Downloading the politicians’ Twitter profile images to use in visualizations</li>
</ul>
<script src="https://gist.github.com/kateto/7da13df064fffaa3b8ab.js"></script>
<section id="data" class="level2">
<h2 data-anchor-id="data">PolitwoopsR examples</h2>
<p>Here are a few quick examples of what the package can do. Before getting started, install PolitwoopsR from GitHub using the <a href="https://cran.r-project.org/package=devtools">devtools</a> package.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">install.packages</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'devtools'</span>)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(devtools)</span>
<span id="cb1-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">install_github</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'kateto/PolitwoopsR'</span>)</span>
<span id="cb1-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(PolitwoopsR)</span></code></pre></div></div>
<p>Politwoops provides tweet data as paginated JSON (usually 10 or 20 tweets per page). To get a data frame with that data, use <code>get_pw_tweets()</code>. It takes four arguments: <code>start.page</code> (defaults to the first page), <code>end.page</code> (defaults to the last page available), <code>domain</code> (defaults to the US domain), and <code>json.ext</code> (defaults to <code>"/index.json?page="</code>, which is where you find the JSON for the US and UK projects). Getting all the pages (over 750 for the US at the time) may take a while.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get tweet JSONs - all pages from the US site:</span></span>
<span id="cb2-2">pw.df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_pw_tweets</span>()</span>
<span id="cb2-3"></span>
<span id="cb2-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get the first 5 pages only from the UK Politwoops tweets:</span></span>
<span id="cb2-5">pw.df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_pw_tweets</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"politwoops.co.uk"</span>)</span>
<span id="cb2-6"></span>
<span id="cb2-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get the first 5 pages from Argentina's Politwoops tweets:</span></span>
<span id="cb2-8">tweet.df <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_pw_tweets</span>(<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"www.politwoops.com/g/Argentina"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".json?page="</span>)</span></code></pre></div></div>
<p>The politician data is not available in a convenient format, but can be scraped from HTML tables on the US site with <code>get_pw_pol()</code>. Since it only works with the US site, it takes just two arguments: <code>start.page</code> (defaults to 1) and <code>end.page</code> (defaults to last).</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get all politician data:</span></span>
<span id="cb3-2">pol.inf <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">get_pw_pol</span>()</span></code></pre></div></div>
<p>The function <code>merge_pw()</code> does a left outer join of the tweet and politician data frames, merging by Twitter handle. In other words, it adds columns to the tweet data frame with information about the politician who wrote each tweet.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Combine tweet and politician data:</span></span>
<span id="cb4-2">pw.dfs <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">merge_pw</span>(pw.df, pol.inf)</span></code></pre></div></div>
<p>Helper functions in the package also include short URL expansion and domain extraction:</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Expand URLs:</span></span>
<span id="cb5-2">pw.dfs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>url.decoded <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">url_expand</span>(pw.df)</span>
<span id="cb5-3"></span>
<span id="cb5-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Extract domains from the URLs:</span></span>
<span id="cb5-5">pw.dfs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>url.domain <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">url_domain</span>(pw.dfs<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>url.decoded)</span></code></pre></div></div>
</section>
<section id="bots" class="level2">
<h2 data-anchor-id="bots">The Dean Richards bot tale</h2>
<p>After putting the PolitwoopsR package on GitHub, I sent out a tweet to let #rstats folks know about it. It was retweeted by Pew’s Claudia Deane, who was at the time getting a lot of unfortunate attention from an army of Russian bots.</p>
<p><img src="https://kateto.net/wp-content/uploads/2015/04/DeanRichardsBot.jpg" class="fig-center img-fluid" alt="A Dean Richards bot account" width="168"></p>
<p>All of the bots used the name, image, and profile info of WGN reporter Dean Richards (whose real account is verified), and their usernames were “c_deane” followed by a random string of letters. The bots would furiously repost (not retweet, but copy and paste without credit) anything they found on Claudia’s timeline. That included my tweet, which spent days being rebroadcast by bots several times an hour.</p>
<p>I alerted Twitter, though it’s hard to say whether that had any effect; the situation didn’t fit neatly in their spam, harassment, or copyright categories, especially since it involved many bot accounts rather than a single offender. The story has no real conclusion, except that (as science fiction has taught us) robot armies are tough to beat. So if you landed here because of a Dean Richards bot tweet, I hope you found this useful anyway. And please say hi to our robotic overlords for me.</p>


</section>

 ]]></description>
  <guid>https://kateto.net/deleted-congressional-tweets-the-r-code/</guid>
  <pubDate>Sun, 29 Mar 2015 04:00:00 GMT</pubDate>
  <media:content url="https://kateto.net/images/post-politwoopsr.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>The Congress tweets you never did see</title>
  <link>https://kateto.net/politwoops/</link>
  <description><![CDATA[ 





<div class="note-box">
<p><strong>Update:</strong> the R code used to collect and clean the Politwoops and Twitter data is in <a href="..\deleted-congressional-tweets-the-r-code/">this follow-up post</a>, and the <a href="https://github.com/kateto/PolitwoopsR">PolitwoopsR</a> package that automates data collection is on GitHub. This post is from 2015; the charts reflect data from 2011 to 2015.</p>
</div>
<p>For some months now, I’ve been playing with data from <a href="https://web.archive.org/web/2015/https://politwoops.com/">Politwoops</a> (the site is now offline; the link opens an archived copy), an international project that tracks politicians on Twitter and stores their deleted tweets for posterity. The project started in the Netherlands and spread to dozens of other countries. In the US, it was run by the <a href="https://sunlightfoundation.com/">Sunlight Foundation</a>. Looking at those deleted tweets has been one of my side projects at the <a href="https://lazerlab.net/">Lazer Lab</a>. The initial idea was to separate tweets deleted for trivial reasons (typos, broken links) from those with politically problematic content, compare the latter to non-deleted tweets, and see whether some political issues appear disproportionately often in content removed by the left and the right.</p>
<p>I am still working on that with colleagues at the lab. In the meantime, I’ve put together some descriptive statistics as charts: the most deleted terms, hashtags, and URLs by Democrats and Republicans, the states where politicians most often go back and edit their Twitter history, the top tweet-deleting politicians, tweet sentiment, a semantic network of deleted terms, and so on. Thanks to <a href="https://openstate.eu/">Open State</a>’s Breyten Ernsting and Sunlight’s Nicko Margolies, whose helpful tweets clued me in on the data structure.</p>
<p><strong>Jump to:</strong> politicians · descriptives · party · sentiment · URLs · states · terms · hashtags · term network</p>
<section id="politicians" class="level2">
<h2 data-anchor-id="politicians">Politicians</h2>
<p><img src="https://kateto.net/charts/Top-10-politicians-deleted-tweets-2015.png" class="fig-center img-fluid" alt="Top 10 politicians by number of deleted tweets" width="600"></p>
<p><img src="https://kateto.net/charts/Top-10-politicians-deleted-tweets-percent-2015.png" class="fig-center img-fluid" alt="Top 10 politicians by percent of tweets deleted" width="600"></p>
</section>
<section id="descriptives" class="level2">
<h2 data-anchor-id="descriptives">Descriptives</h2>
<iframe class="chart-frame" src="../charts/deleted-tweets-party-cdn.html" height="450" title="Deleted tweets by party" loading="lazy"></iframe>
<iframe class="chart-frame" src="../charts/deleted-tweets-role-cdn.html" height="450" title="Deleted tweets by role" loading="lazy"></iframe>
<iframe class="chart-frame" src="../charts/deleted-tweets-clients-cdn.html" height="450" title="Deleted tweets by Twitter client" loading="lazy"></iframe>
<iframe class="chart-frame" src="../charts/deleted-tweets-time-cdn.html" height="450" title="Deleted tweets by time" loading="lazy"></iframe>
</section>
<section id="party" class="level2">
<h2 data-anchor-id="party">Deleted tweets by party, 2011–2015</h2>
<iframe class="chart-frame" src="../charts/deleted-tweets-volume-over-time.html" height="550" title="Deleted tweet volume over time by party" loading="lazy"></iframe>
</section>
<section id="sentiment" class="level2">
<h2 data-anchor-id="sentiment">Tweet sentiment by party, 2011–2015</h2>
<iframe class="chart-frame" src="../charts/deleted-tweets-sentiment-polarity.html" height="450" title="Sentiment and polarity of deleted tweets" loading="lazy"></iframe>
</section>
<section id="url" class="level2">
<h2 data-anchor-id="url">Deleted URLs</h2>
<iframe class="chart-frame" src="../charts/deleted-tweets-url-bubble.html" height="450" title="Domains linked in deleted tweets" loading="lazy"></iframe>
</section>
<section id="map" class="level2">
<h2 data-anchor-id="map">Deleted tweets per politician by state over time</h2>
<section id="all-politicians" class="level3">
<h3 data-anchor-id="all-politicians">All politicians</h3>
<iframe class="chart-frame" src="../charts/deleted-tweets-map-all-ani.html" height="550" title="Deleted tweets per politician by state, all" loading="lazy"></iframe>
</section>
<section id="democrats" class="level3">
<h3 data-anchor-id="democrats">Democrats</h3>
<iframe class="chart-frame" src="../charts/deleted-tweets-map-dem-ani.html" height="550" title="Deleted tweets per politician by state, Democrats" loading="lazy"></iframe>
</section>
<section id="republicans" class="level3">
<h3 data-anchor-id="republicans">Republicans</h3>
<iframe class="chart-frame" src="../charts/deleted-tweets-map-rep-ani.html" height="550" title="Deleted tweets per politician by state, Republicans" loading="lazy"></iframe>
</section>
</section>
<section id="terms" class="level2">
<h2 data-anchor-id="terms">Top terms in deleted tweets, 2011–2015</h2>
<div class="trio">
<p><a href="..\charts/deleted-tweets-wordcloud-all.png"><img src="https://kateto.net/charts/deleted-tweets-wordcloud-all.png" class="img-fluid" alt="Total"></a><br>All</p>
<p><a href="..\charts/deleted-tweets-wordcloud-Dem.png"><img src="https://kateto.net/charts/deleted-tweets-wordcloud-Dem.png" class="img-fluid" alt="Democrats"></a><br>Democrats</p>
<p><a href="..\charts/deleted-tweets-wordcloud-Rep.png"><img src="https://kateto.net/charts/deleted-tweets-wordcloud-Rep.png" class="img-fluid" alt="Republicans"></a><br>Republicans</p>
</div>
</section>
<section id="hashtag" class="level2">
<h2 data-anchor-id="hashtag">Top hashtags in deleted tweets, 2011–2015</h2>
<div class="trio">
<p><a href="..\charts/deleted-tweets-wordcloud-hashtag-all.png"><img src="https://kateto.net/charts/deleted-tweets-wordcloud-hashtag-all.png" class="img-fluid" alt="Total"></a><br>All</p>
<p><a href="..\charts/deleted-tweets-wordcloud-hashtag-dem.png"><img src="https://kateto.net/charts/deleted-tweets-wordcloud-hashtag-dem.png" class="img-fluid" alt="Democrats"></a><br>Democrats</p>
<p><a href="..\charts/deleted-tweets-wordcloud-hashtag-rep.png"><img src="https://kateto.net/charts/deleted-tweets-wordcloud-hashtag-rep.png" class="img-fluid" alt="Republicans"></a><br>Republicans</p>
</div>
</section>
<section id="network" class="level2">
<h2 data-anchor-id="network">The network of top terms in deleted tweets, 2011–2015</h2>
<iframe class="chart-frame" src="../charts/deleted-tweets-top-terms.html" height="800" title="Network of top terms in deleted tweets" loading="lazy"></iframe>
<p>Data: Politwoops, Sunlight Foundation.</p>


</section>

 ]]></description>
  <guid>https://kateto.net/politwoops/</guid>
  <pubDate>Tue, 10 Mar 2015 04:00:00 GMT</pubDate>
  <media:content url="https://kateto.net/images/post-politwoops.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Facebook data collection and photo network visualization with Gephi and R</title>
  <link>https://kateto.net/facebook-data-collection-and-photo-network-visualization-with-gephi-and-r/</link>
  <description><![CDATA[ 





<div class="note-box">
<p><strong>A note from today:</strong> this post is from 2014. Facebook has since closed the API access it describes, so the data-collection steps no longer work. The visualization techniques (images as nodes in Gephi, igraph, and qgraph) still apply to any network with pictures for its nodes. The <a href="..\wp-content/uploads/2014/04/Facebook-Data-Collect-Image-Network-Vis-2014.R">full R script</a> is still available.</p>
</div>
<div class="trio">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://kateto.net/wp-content/uploads/2015/04/Facebook-friends-net-GEPHI-Images.png" class="img-fluid figure-img" alt="Facebook friend network drawn in Gephi, with profile photos as nodes"></p>
<figcaption>Gephi</figcaption>
</figure>
</div>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://kateto.net/wp-content/uploads/2015/04/Facebook-friends-net-IGRAPH-Images.png" class="img-fluid figure-img" alt="Facebook friend network drawn in igraph, with profile photos as nodes"></p>
<figcaption>igraph</figcaption>
</figure>
</div>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://kateto.net/wp-content/uploads/2015/04/Facebook-friends-net-QGRAPH.png" class="img-fluid figure-img" alt="Facebook friend network drawn in qgraph, with profile photos as nodes"></p>
<figcaption>qgraph</figcaption>
</figure>
</div>
</div>
<p><em>Update, April 26, 2014:</em> <a href="https://twitter.com/estebanmoro">Esteban Moro</a> reminded me that there’s no need to manually rescale igraph layouts; you can use <code>layout.norm()</code> instead (<a href="https://gist.github.com/kateto/11092938">script updated accordingly</a>). <a href="https://github.com/hugle">Hugle</a> on GitHub kindly pointed out a couple of sneaky typos, now fixed.</p>
<p><a href="https://gephi.org/">Gephi</a> is one of my favorite network visualization tools. It offers a wide variety of customizable layouts, allows sophisticated tweaks, renders large graphs well, handles dynamic data, and generally lets you produce sleek results with minimal effort. That said, there are a few basic things (that pretty much any other network tool can do) that I’ve been missing in Gephi, like combining different node shapes or using images as nodes. Last week, the Yale Computer Graphics Group released a Gephi plugin that does exactly that. It’s called <em>Image Preview</em>, and it lets you use pictures in your Gephi network visualizations.</p>
<p>I played with the plugin for a while to figure out how it works, then switched to <a href="https://cran.r-project.org/">R</a> to replicate the results. I used my own Facebook network, which made it easy to get a picture for each node. Twitter would have worked just as well, but I also wanted to try the new version of the Rfacebook package. Here are the steps to getting the data and visualizing it in Gephi, <a href="https://igraph.org/r/">igraph</a>, or <a href="https://cran.r-project.org/package=qgraph">qgraph</a>. It turned out to be pretty straightforward, with only a couple of glitches along the way.</p>
<p>The same effect can be achieved even faster with Facebook apps like Bernie Hogan’s NameGenWeb, or with Marc Smith’s <a href="https://www.smrfoundation.org/nodexl/">NodeXL</a> network add-on for Excel.</p>
<section id="Facebook" class="level2">
<h2 data-anchor-id="Facebook">Collecting Facebook data</h2>
<p><strong>1. Registration.</strong> First, get the Facebook data. Before pulling it from R, you need to register as a developer at developers.facebook.com and create a new app. The name and description are irrelevant; the only thing to do is go to <em>Settings</em> → <em>Website</em> → <em>Site URL</em> and fill in <code>http://localhost:1410/</code> (the port we’ll use). The whole process takes about five minutes.</p>
<p><strong>2. Authentication.</strong> Now go to R, install the Rfacebook package, and authenticate using the <em>id</em> and <em>secret</em> shown in the Settings tab of your Facebook app.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">install.packages</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Rfacebook"</span>)</span>
<span id="cb1-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">library</span>(Rfacebook)</span>
<span id="cb1-3">oauth <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">fbOAuth</span>(<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">app_id =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"your_app_id_here"</span>,</span>
<span id="cb1-4">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">app_secret =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"your_app_secret_here"</span>,</span>
<span id="cb1-5">                 <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">extended_permissions =</span> T)</span>
<span id="cb1-6"></span>
<span id="cb1-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">save</span>(oauth, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">file=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"fb_oauth"</span>)</span>
<span id="cb1-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># load(file="fb_oauth")</span></span></code></pre></div></div>
<p><strong>3. Data download.</strong> At this point, you can get information from Facebook. <code>getFriends</code> returns a data frame with (among other things) the name, username, gender, location, hometown, and picture URLs of all Facebook contacts who provided that information. <code>getNetwork</code> collects the ties among people on your friend list, either as an edge list or as an adjacency matrix. Just for fun (and because it doesn’t take long), we’ll get both.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get friend info:</span></span>
<span id="cb2-2">my.friends <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">getFriends</span>(oauth, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">simplify=</span>F)</span>
<span id="cb2-3"></span>
<span id="cb2-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Get friend network in two formats, matrix and edge list:</span></span>
<span id="cb2-5">fb.net.mat <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">getNetwork</span>(oauth, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"adj.matrix"</span>)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># bool,+0 to get numeric</span></span>
<span id="cb2-6">fb.net.el  <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">as.data.frame</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">getNetwork</span>(oauth, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">format =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"edgelist"</span>))</span></code></pre></div></div>
<p><strong>4. Image download.</strong> Using the URLs from the friend data frame, we can download profile photos to a local folder (here FBImages). The download itself is simple with <code>download.file</code>; most of the lines below deal with naming the image files properly.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">setwd</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"C:/Research/R"</span>)</span>
<span id="cb3-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dir.create</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FbImages"</span>)</span>
<span id="cb3-3"></span>
<span id="cb3-4"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Image file name and local path stored here:</span></span>
<span id="cb3-5">my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>picture.dld <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span></span>
<span id="cb3-6"></span>
<span id="cb3-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Download the images:</span></span>
<span id="cb3-8"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dim</span>(my.friends)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]) {</span>
<span id="cb3-9">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Fb images appear to be mostly JPEGs, except for people</span></span>
<span id="cb3-10">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># with no profile pics - for those we seem to get a default GIF</span></span>
<span id="cb3-11">  pic.ext <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".jpg"</span></span>
<span id="cb3-12">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".gif$"</span>, my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>picture[i])) pic.ext <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".gif"</span></span>
<span id="cb3-13"></span>
<span id="cb3-14">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># We'll name files using people's full names plus file extension.</span></span>
<span id="cb3-15">  my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>picture.dld[i] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span></span>
<span id="cb3-16">                 <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FBImages/"</span>, <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">sub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">" "</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"_"</span>, my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>name[i]), pic.ext)</span>
<span id="cb3-17"></span>
<span id="cb3-18">  <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Some users have UTF-8 encoded names that don't work well as file names:</span></span>
<span id="cb3-19">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span> (<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">Encoding</span>(my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>name[i])<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"UTF-8"</span>) {</span>
<span id="cb3-20">       my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>picture.dld[i] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span></span>
<span id="cb3-21">                  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">paste0</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FBImages/"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FbID_"</span>, my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>id[i], pic.ext) }</span>
<span id="cb3-22"></span>
<span id="cb3-23"> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">download.file</span>(my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>picture[i],  my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>picture.dld[i],  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">mode =</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'wb'</span>)</span>
<span id="cb3-24">}</span></code></pre></div></div>
</section>
<section id="Gephi" class="level2">
<h2 data-anchor-id="Gephi">Visualizing the network with Gephi</h2>
<p>There are several ways to move network data from R to Gephi (both support formats like <a href="https://gexf.net/">GEXF</a>). For simple, small networks, the most straightforward export is probably CSV. Gephi needs two CSV files. The first is an edge list describing every link; the columns with the start and end node of each link should be named <em>Source</em> and <em>Target</em>. The second is a node attribute table with a column named <em>ID</em> containing node identifiers that match those in <em>Source</em> and <em>Target</em>. Other attributes are optional, but here you need one called <em>image</em> with the photo file names for the Image Preview plugin to work.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">colnames</span>(fb.net.el) <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">c</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Source"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Target"</span>)</span>
<span id="cb4-2">my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>ID <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>name</span>
<span id="cb4-3">my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>image <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">gsub</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"FBImages/(*.)"</span>, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">\\</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">1"</span>, my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>picture.dld)</span>
<span id="cb4-4"></span>
<span id="cb4-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(fb.net.el, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">file=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Facebook-friend-EDGES.csv"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names=</span>F)</span>
<span id="cb4-6"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">write.csv</span>(my.friends, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">file=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Facebook-friend-NODES.csv"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">row.names=</span>F)</span></code></pre></div></div>
<p>After you import the files (from <em>Data Laboratory</em> → <em>Import Spreadsheet</em>), you can tinker with the layout in the <em>Overview</em> tab until you’re happy with it, then switch to the <em>Preview</em> tab.</p>
<p><img src="https://kateto.net/wp-content/uploads/2015/04/Gephi-Nodes-as-Images-settings.png" class="fig-center img-fluid" alt="Gephi preview settings for rendering nodes as images"></p>
<p>With the Image Preview plugin installed, you should see a <em>Node Images</em> section at the bottom of the <em>Preview Settings</em> bar. Tick <em>Render nodes as images</em> and specify the folder where the photos are located.</p>
<p>Gephi takes the file names stored in the <em>image</em> node attribute and looks for them in the image path you’ve set. One glitch I hit (which the plugin’s creator, <a href="https://github.com/chrisxue815/gephi-plugin-image-preview">Chris Xue</a>, kindly helped with) was that the plugin had compatibility issues with Java 7. I had to install Java 6 and change Gephi’s startup configuration (the <em>jdkhome</em> parameter in <code>Gephi-0.8.2\etc\gephi.conf</code>) before the plugin would work.</p>
<p><img src="https://kateto.net/wp-content/uploads/2015/04/Facebook-friends-net-GEPHI.png" class="fig-center img-fluid" alt="Facebook friend network in Gephi"></p>
<p><img src="https://kateto.net/wp-content/uploads/2015/04/Facebook-friends-net-GEPHI-Images.png" class="fig-center img-fluid" alt="Facebook friend network in Gephi with photos as nodes"></p>
</section>
<section id="igraph" class="level2">
<h2 data-anchor-id="igraph">Visualizing the network with igraph</h2>
<p>R has long been able to add images to network graphs (and plots in general). I tried two packages, and both work well. I’m more familiar with igraph, which makes it easier to tweak things, but <a href="https://cran.r-project.org/package=qgraph">qgraph</a> has node images built in, so getting a network map with photos takes just a few lines (see the next section).</p>
<p>Before doing an igraph visualization with node images, we can plot the graph the old-fashioned way and tweak the layout until it looks right.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">require</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"png"</span>)</span>
<span id="cb5-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">require</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"jpeg"</span>)</span>
<span id="cb5-3"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">require</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"igraph"</span>)</span>
<span id="cb5-4"></span>
<span id="cb5-5">fb.net <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">graph.adjacency</span>(fb.net.mat)</span>
<span id="cb5-6"></span>
<span id="cb5-7"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Add node degree, node colors based on gender, and</span></span>
<span id="cb5-8"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># edge colors based on the color of the source node.</span></span>
<span id="cb5-9">my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>degree <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">degree</span>(fb.net)</span>
<span id="cb5-10">my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>color <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gray45"</span></span>
<span id="cb5-11">my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>color[my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>gender<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"female"</span>] <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lightpink3"</span></span>
<span id="cb5-12">my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>color[my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>gender<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"male"</span>]   <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"lightblue"</span></span>
<span id="cb5-13">fb.net.el<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>color <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>color[<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">match</span>(fb.net.el<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>Source, my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>name)]</span>
<span id="cb5-14"></span>
<span id="cb5-15">l <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">layout.fruchterman.reingold</span>(fb.net, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">niter=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">10000</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">area=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vcount</span>(fb.net)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.3</span>,</span>
<span id="cb5-16">                                  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">repulserad=</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">vcount</span>(fb.net)<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">^</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">2.2</span>)</span>
<span id="cb5-17"></span>
<span id="cb5-18"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">png</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Facebook-friends-net-IGRAPH.png"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2500</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2000</span>)</span>
<span id="cb5-19"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(fb.net, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vertex.size=</span>my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>degree<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">/</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">20</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vertex.label=</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>,</span>
<span id="cb5-20">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vertex.color=</span>my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>color, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">edge.color=</span>fb.net.el<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>color,</span>
<span id="cb5-21">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">edge.width=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">edge.arrow.size=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">edge.curved=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.3</span>,  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">layout=</span>l)</span>
<span id="cb5-22"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dev.off</span>()</span></code></pre></div></div>
<p>Now on to plotting with images. We’ll apply the layout <code>l</code> created above and plot the graph again, this time with white squares as nodes. Then we’ll use the layout coordinates to overlay the photos on top of those squares. One thing that took a bit to figure out (thanks to a comment by qgraph author <a href="http://sachaepskamp.com/">Sacha Epskamp</a>) is that the layout needs to be rescaled to [-1, 1] first.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;"># Rescale the layout so it goes from -1 to 1</span></span>
<span id="cb6-2">l <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">layout.norm</span>(l, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb6-3"></span>
<span id="cb6-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">png</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Facebook-friends-net-IGRAPH.png"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2500</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2000</span>)</span>
<span id="cb6-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">plot</span>(fb.net, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vertex.size=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">4</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vertex.label=</span><span class="cn" style="color: #8f5902;
background-color: null;
font-style: inherit;">NA</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">edge.color=</span>fb.net.el<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>color,</span>
<span id="cb6-6">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vertex.shape=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"square"</span>,<span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vertex.color=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">vertex.frame.color=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"white"</span>,</span>
<span id="cb6-7">     <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">edge.width=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">edge.arrow.size=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">edge.curved=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>,  <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">layout=</span>l)</span>
<span id="cb6-8"></span>
<span id="cb6-9">img.sc <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.03</span> <span class="co" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">#Image scaling</span></span>
<span id="cb6-10"><span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">for</span> (i <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">in</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span><span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dim</span>(l)[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]) {</span>
<span id="cb6-11">  img <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>picture.dld[i]</span>
<span id="cb6-12">  img <span class="ot" style="color: #003B4F;
background-color: null;
font-style: inherit;">&lt;-</span> <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">if</span>(<span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">grepl</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">".jpg"</span>, img)) <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">readJPEG</span>(img) <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">else</span> <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gray20"</span></span>
<span id="cb6-13">  <span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">rasterImage</span>(img, l[i,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>img.sc, l[i,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span>img.sc, l[i,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span>img.sc, l[i,<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>]<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span>img.sc)</span>
<span id="cb6-14">}</span>
<span id="cb6-15"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dev.off</span>()</span>
<span id="cb6-16"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">detach</span>(package<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>igraph)</span></code></pre></div></div>
<p>And here is what the exported images look like:</p>
<p><img src="https://kateto.net/wp-content/uploads/2015/04/Facebook-friends-net-IGRAPH.png" class="fig-center img-fluid" alt="Facebook friend network in igraph"></p>
<p><img src="https://kateto.net/wp-content/uploads/2015/04/Facebook-friends-net-IGRAPH-Images.png" class="fig-center img-fluid" alt="Facebook friend network in igraph with photos as nodes"></p>
</section>
<section id="qgraph" class="level2">
<h2 data-anchor-id="qgraph">Visualizing the network with qgraph</h2>
<p>There’s not much to explain here: node images are a built-in option in qgraph. The <code>qgraph</code> function takes a matrix and a vector of image file names (with paths) and produces a graph with node images right away, without further tinkering.</p>
<div class="code-copy-outer-scaffold"><div class="sourceCode" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">require</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"png"</span>)</span>
<span id="cb7-2"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">require</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"qgraph"</span>)</span>
<span id="cb7-3"></span>
<span id="cb7-4"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">png</span>(<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"Facebook-friends-net-2014-04-QGRAPH.png"</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">width =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2500</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">height =</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2000</span>)</span>
<span id="cb7-5"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">qgraph</span>(fb.net.mat, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">images =</span> my.friends<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">$</span>picture.dld, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">labels =</span> F,</span>
<span id="cb7-6">        <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">borders =</span> F, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">esize=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.1</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">curve=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.2</span>, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">curveAll=</span>T, <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">edge.color=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"gray55"</span>)</span>
<span id="cb7-7"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">dev.off</span>()</span>
<span id="cb7-8"></span>
<span id="cb7-9"><span class="fu" style="color: #4758AB;
background-color: null;
font-style: inherit;">detach</span>(package<span class="sc" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">:</span>qgraph)</span></code></pre></div></div>
<p><img src="https://kateto.net/wp-content/uploads/2015/04/Facebook-friends-net-QGRAPH.png" class="fig-center img-fluid" alt="Facebook friend network in qgraph with photos as nodes"></p>
<div class="btn-row">
<p><a href="..\wp-content/uploads/2014/04/Facebook-Data-Collect-Image-Network-Vis-2014.R" class="btn-k">Get the full R script</a></p>
</div>


</section>

 ]]></description>
  <guid>https://kateto.net/facebook-data-collection-and-photo-network-visualization-with-gephi-and-r/</guid>
  <pubDate>Sat, 19 Apr 2014 04:00:00 GMT</pubDate>
  <media:content url="https://kateto.net/images/post-facebook.jpg" medium="image" type="image/jpeg"/>
</item>
</channel>
</rss>
