Skip to content

Commit

Permalink
Correct typo in posts/international-external-debt-network
Browse files Browse the repository at this point in the history
  • Loading branch information
christophscheuch committed Nov 30, 2024
1 parent b0fe714 commit 0acb1b5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ <h5 class="quarto-listing-category-title">Categories</h5><div class="quarto-list

<div class="quarto-listing quarto-listing-container-grid" id="listing-listing">
<div class="list grid quarto-listing-cols-3">
<div class="g-col-1" data-index="0" data-categories="R,Visualization" data-listing-date-sort="1732748400000" data-listing-file-modified-sort="1732801037352" data-listing-date-modified-sort="NaN" data-listing-reading-time-sort="5" data-listing-word-count-sort="931">
<div class="g-col-1" data-index="0" data-categories="R,Visualization" data-listing-date-sort="1732748400000" data-listing-file-modified-sort="1732973818815" data-listing-date-modified-sort="NaN" data-listing-reading-time-sort="5" data-listing-word-count-sort="931">
<a href="./posts/international-external-debt-network/index.html" class="quarto-grid-link">
<div class="quarto-grid-item card h-100 card-left">
<p class="card-img-top">
Expand Down
6 changes: 3 additions & 3 deletions docs/posts/international-external-debt-network/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ <h2 id="toc-title">On this page</h2>

<ul>
<li><a href="#data-preparation" id="toc-data-preparation" class="nav-link active" data-scroll-target="#data-preparation">Data Preparation</a></li>
<li><a href="#debitor-centric-view" id="toc-debitor-centric-view" class="nav-link" data-scroll-target="#debitor-centric-view">Debitor-Centric View</a></li>
<li><a href="#debtor-centric-view" id="toc-debtor-centric-view" class="nav-link" data-scroll-target="#debtor-centric-view">Debtor-Centric View</a></li>
<li><a href="#creditor-centric-view" id="toc-creditor-centric-view" class="nav-link" data-scroll-target="#creditor-centric-view">Creditor-Centric View</a></li>
<li><a href="#concluding-remarks" id="toc-concluding-remarks" class="nav-link" data-scroll-target="#concluding-remarks">Concluding Remarks</a></li>
</ul>
Expand Down Expand Up @@ -286,8 +286,8 @@ <h2 class="anchored" data-anchor-id="data-preparation">Data Preparation</h2>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">to =</span> <span class="fu">str_squish</span>(to))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="debitor-centric-view" class="level2">
<h2 class="anchored" data-anchor-id="debitor-centric-view">Debitor-Centric View</h2>
<section id="debtor-centric-view" class="level2">
<h2 class="anchored" data-anchor-id="debtor-centric-view">Debtor-Centric View</h2>
<p>For now, let’s narrow our focus to specific debtor countries. This step allows us to examine the relationships from a debtor’s perspective, understanding how much debt they owe and to whom. In the following, we focus on Nigeria and its neighbor Cameroon.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>selected_geographies <span class="ot">&lt;-</span> <span class="fu">c</span>(<span class="st">"Nigeria"</span>, <span class="st">"Cameroon"</span>)</span>
Expand Down
7 changes: 7 additions & 0 deletions docs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -992,5 +992,12 @@
"title": "Interactive Data Visualization with Python",
"section": "Conclusion",
"text": "Conclusion\nplotly, bokeh, and altair each cater to distinct visualization needs in Python. plotly shines with its interactive, high-quality visuals and ease of embedding in web applications, making it ideal for creating complex interactive charts and dashboards. bokeh is focused on real-time data visualizations and interactivity, particularly suited for web apps that require dynamic data streaming. Its strength lies in the seamless integration of Python code with web technologies. altair offers a declarative approach, emphasizing simplicity and efficiency in creating elegant statistical visualizations with minimal code, making it ideal for exploratory data analysis in notebooks."
},
{
"objectID": "posts/international-external-debt-network/index.html#debtor-centric-view",
"href": "posts/international-external-debt-network/index.html#debtor-centric-view",
"title": "Global Debt Networks",
"section": "Debtor-Centric View",
"text": "Debtor-Centric View\nFor now, let’s narrow our focus to specific debtor countries. This step allows us to examine the relationships from a debtor’s perspective, understanding how much debt they owe and to whom. In the following, we focus on Nigeria and its neighbor Cameroon.\n\nselected_geographies &lt;- c(\"Nigeria\", \"Cameroon\")\n\nexternal_debt_sub &lt;- external_debt |&gt;\n filter(from %in% selected_geographies) \n\nvisNetwork requires two data frames: nodes and edges, each with corresponding properties. To enhance the visualization, we create helper functions for formatting node titles and labels:\n\nformat_title &lt;- function(id, value, type) {\n prefix &lt;- if_else(\n type == \"debtor\", \"&lt;br&gt;Received: \", \"&lt;br&gt;Provided: \"\n )\n debt &lt;- scales::label_number(\n accuracy = 0.1, scale_cut = scales::cut_short_scale()\n )(value)\n title &lt;- str_c(\n id, prefix, debt, \" USD\"\n )\n title\n}\n\nformat_label &lt;- function(id) {\n label &lt;- str_wrap(id, width = 20)\n label\n}\n\nWe now construct the nodes and edges for the network. Nodes represent entities (countries or institutions), and edges represent debt relationships. The data looks like this:\n\ncreate_nodes &lt;- function(external_debt_sub) {\n \n total_debt &lt;- sum(external_debt_sub$value)\n \n nodes &lt;- external_debt_sub |&gt; \n group_by(id = from, type = \"debtor\", color = \"Country\") |&gt; \n summarize(value = sum(value),\n .groups = \"drop\") |&gt; \n bind_rows(\n external_debt_sub |&gt; \n group_by(id = to, type = \"creditor\", color = counterpart_type) |&gt; \n summarize(value = sum(value),\n .groups = \"drop\")\n ) |&gt; \n mutate(\n title = format_title(id, value, type),\n label = format_label(id),\n size = value / total_debt,\n color = case_when(\n color == \"Other\" ~ \"#C46231\",\n color == \"Country\" ~ \"#3193C4\",\n color == \"Global MDBs\" ~ \"#AB31C4\",\n color == \"Bondholders\" ~ \"#4AC431\"\n )\n )\n nodes\n}\n\nnodes &lt;- create_nodes(external_debt_sub)\nnodes\n\n# A tibble: 33 × 7\n id type color value title label size\n &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; &lt;dbl&gt; &lt;chr&gt; &lt;chr&gt; &lt;dbl&gt;\n 1 Cameroon debt… #319… 1.18e10 Came… \"Cam… 2.28e-1\n 2 Nigeria debt… #319… 4.00e10 Nige… \"Nig… 7.72e-1\n 3 African Dev. Bank cred… #C46… 4.18e 9 Afri… \"Afr… 8.07e-2\n 4 African Export-Import Bank cred… #C46… 7.60e 7 Afri… \"Afr… 1.47e-3\n 5 Arab Bank for Economic Dev. in Afric… cred… #C46… 7.23e 7 Arab… \"Ara… 1.39e-3\n 6 Austria cred… #319… 8.78e 6 Aust… \"Aus… 1.69e-4\n 7 Belgium cred… #319… 5.69e 7 Belg… \"Bel… 1.10e-3\n 8 Bondholders cred… #4AC… 1.73e10 Bond… \"Bon… 3.33e-1\n 9 Central Bank of West African States … cred… #C46… 2.28e 7 Cent… \"Cen… 4.40e-4\n10 China cred… #319… 8.08e 9 Chin… \"Chi… 1.56e-1\n# ℹ 23 more rows\n\n\nEdges add the connective tissue to the network, showing who owes whom. Here is how the example data looks like:\n\ncreate_edges &lt;- function(external_debt_sub) {\n edges &lt;- external_debt_sub |&gt; \n select(from, to) |&gt; \n mutate(\n shadow = TRUE, \n color = \"grey\",\n smooth = TRUE\n )\n edges\n}\n\nedges &lt;- create_edges(external_debt_sub)\nedges\n\n# A tibble: 45 × 5\n from to shadow color smooth\n &lt;chr&gt; &lt;chr&gt; &lt;lgl&gt; &lt;chr&gt; &lt;lgl&gt; \n 1 Cameroon World Bank-IDA TRUE grey TRUE \n 2 Cameroon World Bank-IBRD TRUE grey TRUE \n 3 Cameroon United States TRUE grey TRUE \n 4 Cameroon United Kingdom TRUE grey TRUE \n 5 Cameroon United Arab Emirates TRUE grey TRUE \n 6 Cameroon Turkiye TRUE grey TRUE \n 7 Cameroon Switzerland TRUE grey TRUE \n 8 Cameroon Spain TRUE grey TRUE \n 9 Cameroon Saudi Arabia TRUE grey TRUE \n10 Cameroon OPEC Fund for International Dev. TRUE grey TRUE \n# ℹ 35 more rows\n\n\nThe visNetwork library brings everything together, producing an interactive network. This visualization provides a debtor-centric perspective, illustrating how selected countries distribute their debt obligations among creditors.\n\nvisualize_network &lt;- function(external_debt_sub) {\n nodes &lt;- create_nodes(external_debt_sub)\n edges &lt;- create_edges(external_debt_sub)\n \n visNetwork(\n nodes, edges, width = \"100%\", height = \"600px\"\n ) |&gt; \n visNodes(shape = \"dot\")\n}\n\nvisualize_network(external_debt_sub)\n\n\n\n\n\nVisualizing the network from a debtor’s perspective sheds light on the diversity of funding sources for countries like Nigeria and Cameroon. While both nations share some creditors, the wider spread of Cameroon’s creditor network could indicate stronger diversification in funding sources—a potentially advantageous position for economic resilience."
}
]
2 changes: 1 addition & 1 deletion docs/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</url>
<url>
<loc>https://blog.tidy-intelligence.com/posts/international-external-debt-network/index.html</loc>
<lastmod>2024-11-28T13:37:17.352Z</lastmod>
<lastmod>2024-11-30T13:36:58.815Z</lastmod>
</url>
<url>
<loc>https://blog.tidy-intelligence.com/posts/dplyr-vs-tidierdata/index.html</loc>
Expand Down
2 changes: 1 addition & 1 deletion posts/international-external-debt-network/index.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ external_debt <- external_debt_raw |>
mutate(to = str_squish(to))
```

## Debitor-Centric View
## Debtor-Centric View

For now, let’s narrow our focus to specific debtor countries. This step allows us to examine the relationships from a debtor’s perspective, understanding how much debt they owe and to whom. In the following, we focus on Nigeria and its neighbor Cameroon.

Expand Down

0 comments on commit 0acb1b5

Please sign in to comment.