-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscientificCase.html
More file actions
581 lines (552 loc) · 34.9 KB
/
Copy pathscientificCase.html
File metadata and controls
581 lines (552 loc) · 34.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.9.36">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>2026 Workshop</title>
<style>
/* Default styles provided by pandoc.
** See https://pandoc.org/MANUAL.html#variables-for-html for config info.
*/
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
/* CSS for citations */
div.csl-bib-body { }
div.csl-entry {
clear: both;
margin-bottom: 0em;
}
.hanging-indent div.csl-entry {
margin-left:2em;
text-indent:-2em;
}
div.csl-left-margin {
min-width:2em;
float:left;
}
div.csl-right-inline {
margin-left:2em;
padding-left:1em;
}
div.csl-indent {
margin-left: 2em;
}</style>
<script src="scientificCase_files/libs/clipboard/clipboard.min.js"></script>
<script src="scientificCase_files/libs/quarto-html/quarto.js" type="module"></script>
<script src="scientificCase_files/libs/quarto-html/tabsets/tabsets.js" type="module"></script>
<script src="scientificCase_files/libs/quarto-html/popper.min.js"></script>
<script src="scientificCase_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="scientificCase_files/libs/quarto-html/anchor.min.js"></script>
<link href="scientificCase_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="scientificCase_files/libs/quarto-html/quarto-syntax-highlighting-845c23b38eaddc0f92fda52bfe77a8c8.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="scientificCase_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="scientificCase_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="scientificCase_files/libs/bootstrap/bootstrap-eeb5072725b83a3d2339e0264c232edd.min.css" rel="stylesheet" append-hash="true" id="quarto-bootstrap" data-mode="light">
</head>
<body class="quarto-light">
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#updating-urban-segregation-computation-with-r" id="toc-updating-urban-segregation-computation-with-r" class="nav-link active" data-scroll-target="#updating-urban-segregation-computation-with-r">Updating urban segregation computation with R</a></li>
<li><a href="#scientific-case" id="toc-scientific-case" class="nav-link" data-scroll-target="#scientific-case">Scientific case</a></li>
<li><a href="#expected-outcomes" id="toc-expected-outcomes" class="nav-link" data-scroll-target="#expected-outcomes">Expected outcomes</a></li>
<li><a href="#publi-list" id="toc-publi-list" class="nav-link" data-scroll-target="#publi-list">References</a></li>
</ul>
</nav>
</div>
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">2026 Workshop</h1>
</div>
<div class="quarto-title-meta">
</div>
</header>
<section id="updating-urban-segregation-computation-with-r" class="level2">
<h2 class="anchored" data-anchor-id="updating-urban-segregation-computation-with-r">Updating urban segregation computation with R</h2>
<p>During this 5 day <a href="https://erc-segue.nl/Workshop">workshop</a>, we want to foster <strong>research discussions</strong> spanning the diversity of theories and approaches to urban segregation (in terms of location, scale and social attributes considered, as well as type of data used), create a <strong>community</strong> of urban scholars who can collaborate on frontier research projects, comparative analysis, theory and methodology development, but also prepare the development of an <strong>R package</strong> dedicated to assist with the selection of appropriate measures of urban segregation (a “routemap”), their computation, visualization and analysis necessary to tackle state-of-the-art research questions in the field of urban segregation.</p>
<p>If you would like to be part of this event, please fill in <a href="https://framaforms.org/workshop-updating-urban-segregation-computation-with-r-1777633857">the registration form</a> <strong>before 30th June 2026</strong>. Admission results will be communicated mid-July 2026. We expect to invite between 10 and 20 participants to this workshop.</p>
</section>
<section id="scientific-case" class="level2">
<h2 class="anchored" data-anchor-id="scientific-case">Scientific case</h2>
<p>Urban segregation – i.e. the pattern of (geographical) separation between people of different social groups or economic levels – is a large component of the scientific program of urban sciences (geography, sociology, demography and economics). With dire consequences for social cohesion, economic mobility, but also health and education opportunities, urban segregation is a topic of renewed importance in a context of rising economic inequalities and uneven development. However, many questions about its causes, consequences and evolution persist: How does urban segregation relate to economic inequality? At which scale can urban planners best design more efficient policies to reduce urban segregation? What are the mechanisms through which some places produce better outcomes than others? Does segregation directly harm children in vulnerable families?</p>
<p>Although urban segregation is as old as cities <span class="citation" data-cites="nightingale2012segregation">(<a href="#ref-nightingale2012segregation" role="doc-biblioref">Nightingale, 2012</a>)</span>, its scientific analysis and measurement can be traced back to the 20th century, with the development of the first segregation indices (cf. <span class="citation" data-cites="massey1988dimensions">(<a href="#ref-massey1988dimensions" role="doc-biblioref">Massey & Denton, 1988</a>)</span> for the first review). Since then, methodological developments, technical jumps and the release of ever more detailed social data at increasingly fine grain have fostered the creation of dozens of new indices, to address the spatial dimension of segregation <span class="citation" data-cites="white1983measurement">(<a href="#ref-white1983measurement" role="doc-biblioref">White, 1983</a>)</span> <span class="citation" data-cites="morrill1991">(<a href="#ref-morrill1991" role="doc-biblioref">Morrill, 1991</a>)</span>, to consider multi-groups <span class="citation" data-cites="wong1998measuring">(<a href="#ref-wong1998measuring" role="doc-biblioref">Wong, 1998</a>)</span>, ordinal variables <span class="citation" data-cites="reardon2009measures">(<a href="#ref-reardon2009measures" role="doc-biblioref">Reardon, 2009</a>)</span> and to identify the sub-group components driving segregation. In a first review of the segregation index landscape, the organising team identified 30 distinct measures, along with their use case characteristics.</p>
<p>To apply these measures empirically, researchers from European institutions have access to more and richer data nowadays, from register microdata (as in the Netherlands, one of the leading countries in their dissemination, but also Austria or Sweden) to granular census tract-based data on an annual basis (e.g. Spain). These rich sources of data represent an opportunity that has not yet been fully exploited, partly due to the substantial computational and coding requirements involved with their wrangling and analysis. On this technical front, websites, applications, dedicated software and packages have spurred to assist segregation scholars in computing segregation indices to describe the level and dimension of urban segregation, but few address the challenges of automation, reproducibility and scalability associated with the scientific approach. When they do, like the R packages <code>OasisR</code>, <code>seg</code>, <code>segregation</code>, <code>divseg</code>, <code>ineq</code> or <code>mutualinf</code>, multiple problems arise:</p>
<ol type="1">
<li>The plethora of indices generates confusion as to which indices are the most appropriate to a particular analysis, given the social attribute studied, the scale, data type and dimension of segregation analysed. <strong>We are missing a “routemap” to choose urban segregation measures</strong>. This routemap would function as a decision tree to support urban scholars in their choice of possible segregation indices based on the characteristics of the case study . Without being prescriptive, this routemap would identify options for computing segregation adequately, including recent indices.</li>
<li>New methods take time to get adopted, and often require more technical skills or unique kinds of data to be used. Unfortunately, this means many urban scholars still exclusively resort to historic and simple indices – such as the (aspatial, 2-group) dissimilarity index – which are easy to compute and interpret but are ill-suited to analyse segregation of ordinal social attributes (such as income), the exposure dimension of segregation, its spatial structure, etc. In a systematic review of the literature on economic segregation, <span class="citation" data-cites="cottineau2025economic">(<a href="#ref-cottineau2025economic" role="doc-biblioref">Cottineau-Mugadza, 2025</a>)</span> finds a significant proportion of segregation indices are indeed misused, while a lack of consensus about which indices are best-suited in comparable contexts hampers reproducibility and comparative research. <strong>We are missing a tool to make the computation of relevant indices, spatial counterfactuals and robustness analysis painless in order to address big questions of the field of segregation.</strong></li>
<li>Current theoretical developments in the field of urban segregation often ignore methodological innovations, and methodological developments do not address current debates of the field. <strong>We are missing a forum where sharp theoretical developments meet novel computational science.</strong></li>
<li>Current computational approaches to address urban segregation are siloed into methodological traditions: segregation indices, spatial modelling methods and visualisation techniques are all relevant and complementary assets to qualify, quantify, observe and explain the evolution of urban segregation. <strong>We are missing a workflow where all these can be accessed and put in relation using the same R package.</strong></li>
</ol>
<p>To address these objectives, this workshop will provide a variety of knowledge sharing moments for a community of young and more established scholars to meet and discuss, a collective moment to reflect and cooperate on the computational needs and opportunities of the field. It will also enable this community to work together to develop a solution to these challenges in the form of a new R package. During the 5-day workshop, participants will share their position on the four above challenges, propose and prioritize specific functionality needed in the new package, as well as prepare a user group responsible for testing the new developments on a diverse set of case studies. We thus aim to create a community of urban scholars to share frontier ideas on urban segregation research, collaborate on comparative analysis, theory and methodology development (AIM1). We also to advance the development of new tools and guidance to assist the wider community of urban scholars with the selection of appropriate measures of urban segregation, their computation, visualization and analysis necessary to tackle state-of-the-art research questions (AIM2).</p>
<p>This workshop comes at a point where the toolbox available in R to conduct research on urban segregation is both plentiful, cutting-edge and confusing. Two of the leading packages (<code>seg</code> and <code>OasisR</code>) have been temporarily unavailable and deprecated in the past two years, leading to disruption in the work of scholars used to them and reproducibility issues. Additionally, despite using existing packages in our daily research (whether <code>divseg</code>, <code>ineq</code>, <code>OasisR</code>, <code>seg</code> or <code>segregation</code>), we find three main limitations:</p>
<ol type="1">
<li>they do not allow all combinations of data features (multi-group AND spatial, ordinal AND spatial)</li>
<li>they do not consider multilayered attributes of segregation (i.e. the fact that economic groups are segregated differently from racial or ethnic groups, yet people have multiple identities and spatialities). This is particularly striking in the works on network segregation <span class="citation" data-cites="kazmina2024socio">(<a href="#ref-kazmina2024socio" role="doc-biblioref">Kazmina et al., 2024</a>)</span> and daytime segregation <span class="citation" data-cites="le2017social">(<a href="#ref-le2017social" role="doc-biblioref">Le Roux et al., 2017</a>)</span></li>
<li>they do not consider the multiple scales at which segregation might arise, from local segregation in the streets around one’s home to large-scale segregation in metropolitan areas, and every level in between <span class="citation" data-cites="petrovic2018multiscale">(<a href="#ref-petrovic2018multiscale" role="doc-biblioref">Petrović et al., 2018</a>)</span>.</li>
</ol>
</section>
<section id="expected-outcomes" class="level2">
<h2 class="anchored" data-anchor-id="expected-outcomes">Expected outcomes</h2>
<p>This workshop is meant to reach consensus on the current and most pressing needs of our community and team up with Seong-Yun Hong’s team (creator of the <code>seg</code> package) to update or recreate a segregation R package to complement the current offer. Writing a full package, with functions, tests, and documentation, is not realistic in 5 days. Rather, this workshop will be considered a success if we end up with:</p>
<ol type="1">
<li>an agreement on the most pressing needs of the community</li>
<li>a list of tests (using test-driven development, we first address the requirements of the package in plain English before coding the functions)</li>
<li>an ordered list of functions to develop</li>
<li>a series of diverse use cases from all over the world, with associated data</li>
<li>a roadmap for completing the work</li>
</ol>
<p>To make sure these outcomes are achieved, the first part of the workshop is devoted to review the various aspects of the state of the art, namely the reasons for quantifying segregation, the pool of possible indices and methods for quantification, available technical tools, functions, methods and visualisations provided by existing software packages, the workflow of computational urban segregation studies, which includes quantification, (spatial) modelling and visualisation. By discussing these elements and running through available tools on R through code-along moments, we address the levelling of information and skills for a pool of diverse participants. The second part of the workshop addresses the R package design and development planning, with group sessions dedicated to different aspects (indicators to code, spatial component to add, interpretation guide, etc.) and different roles (developer vs. user). The last day is entirely dedicated to writing down the priority lists of tests, functions and use cases to develop, and to plan the next steps.</p>
<p>In the weeks to follow, we will work on completing the package (developer group), write documentation and user manual, including diverse use cases (user group), and write two publications: one describing the package for a journal such as the <a href="https://joss.theoj.org/">Journal of Open Source Software</a>, and one the review exercise of this workshop, agenda-setting objective and scientific contribution of this package to urban segregation research, for a journal such as <a href="https://journals.sagepub.com/home/usj">Urban Studies</a>.</p>
<p>To do so, we will make use of two types of research infrastructure. First, we will tap into <a href="http://rbanism.org/"><img src="Logo_Rbanism_%20Full.png" class="img-fluid quarto-figure quarto-figure-left" width="50"></a>’s experience. Founded by three participants of this workshop, Rbanism is a community of R practice operating at the department of Urbanism of <a href="https://www.tudelft.nl/"><img src="TUDelft.png" class="img-fluid quarto-figure quarto-figure-left" width="80"></a> since 2022. It provides a pool of beta-users to test the package, a communication infrastructure and experience with engagement around computational tools for urban research. Second, we will use of the expertise and financial capacity of the ERC project <a href="http://erc-segue.nl/"><img src="logo.png" class="img-fluid quarto-figure quarto-figure-left" width="50"></a> led by <a href="http://clementinecttn.github.io">Clémentine Cottineau-Mugadza</a>, on the topic of urban economic segregation. This project allows Clémentine to dedicate time to coordinate follow-up and writing activities, and will fund a conference in 2028-2029 to share and showcase the results of the package use and their contribution to urban segregation research. This activity should bring visibility to the newly created community of workshop participants.</p>
</section>
<section id="publi-list" class="level2">
<h2 class="anchored" data-anchor-id="publi-list">References</h2>
<div id="refs" class="references csl-bib-body hanging-indent" data-entry-spacing="0" data-line-spacing="2" role="list">
<div id="ref-cottineau2025economic" class="csl-entry" role="listitem">
Cottineau-Mugadza, C. (2025). Economic inequality and economic segregation: A systematic review of causal pathways. <em>Social Forces</em>. <a href="https://doi.org/10.1093/sf/soaf195">https://doi.org/10.1093/sf/soaf195</a>
</div>
<div id="ref-kazmina2024socio" class="csl-entry" role="listitem">
Kazmina, Y., Heemskerk, E. M., Bokányi, E., & Takes, F. W. (2024). Socio-economic segregation in a population-scale social network. <em>Social Networks</em>, <em>78</em>, 279–291.
</div>
<div id="ref-le2017social" class="csl-entry" role="listitem">
Le Roux, G., Vallée, J., & Commenges, H. (2017). Social segregation around the clock in the paris region (france). <em>Journal of Transport Geography</em>, <em>59</em>, 134–145.
</div>
<div id="ref-massey1988dimensions" class="csl-entry" role="listitem">
Massey, D. S., & Denton, N. A. (1988). The dimensions of residential segregation. <em>Social Forces</em>, <em>67</em>(2), 281–315.
</div>
<div id="ref-morrill1991" class="csl-entry" role="listitem">
Morrill, B. (1991). On the measure of geographic segregation. <em>Geography Research Forum</em>, <em>11</em>, 25–36.
</div>
<div id="ref-nightingale2012segregation" class="csl-entry" role="listitem">
Nightingale, C. H. (2012). <em>Segregation: A global history of divided cities</em>. University of Chicago Press.
</div>
<div id="ref-petrovic2018multiscale" class="csl-entry" role="listitem">
Petrović, A., Van Ham, M., & Manley, D. (2018). Multiscale measures of population: Within-and between-city variation in exposure to the sociospatial context. <em>Annals of the American Association of Geographers</em>, <em>108</em>(4), 1057–1074.
</div>
<div id="ref-reardon2009measures" class="csl-entry" role="listitem">
Reardon, S. F. (2009). Measures of ordinal segregation. <em>Research on Economic Inequality</em>, <em>17</em>, 129–155.
</div>
<div id="ref-white1983measurement" class="csl-entry" role="listitem">
White, M. J. (1983). The measurement of spatial segregation. <em>American Journal of Sociology</em>, <em>88</em>(5), 1008–1018.
</div>
<div id="ref-wong1998measuring" class="csl-entry" role="listitem">
Wong, D. W. (1998). Measuring multiethnic spatial segregation. <em>Urban Geography</em>, <em>19</em>(1), 77–87.
</div>
</div>
</section>
</main>
<!-- /main column -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
const icon = "";
const anchorJS = new window.AnchorJS();
anchorJS.options = {
placement: 'right',
icon: icon
};
anchorJS.add('.anchored');
const isCodeAnnotation = (el) => {
for (const clz of el.classList) {
if (clz.startsWith('code-annotation-')) {
return true;
}
}
return false;
}
const onCopySuccess = function(e) {
// button target
const button = e.trigger;
// don't keep focus
button.blur();
// flash "checked"
button.classList.add('code-copy-button-checked');
var currentTitle = button.getAttribute("title");
button.setAttribute("title", "Copied!");
let tooltip;
if (window.bootstrap) {
button.setAttribute("data-bs-toggle", "tooltip");
button.setAttribute("data-bs-placement", "left");
button.setAttribute("data-bs-title", "Copied!");
tooltip = new bootstrap.Tooltip(button,
{ trigger: "manual",
customClass: "code-copy-button-tooltip",
offset: [0, -8]});
tooltip.show();
}
setTimeout(function() {
if (tooltip) {
tooltip.hide();
button.removeAttribute("data-bs-title");
button.removeAttribute("data-bs-toggle");
button.removeAttribute("data-bs-placement");
}
button.setAttribute("title", currentTitle);
button.classList.remove('code-copy-button-checked');
}, 1000);
// clear code selection
e.clearSelection();
}
const getTextToCopy = function(trigger) {
const outerScaffold = trigger.parentElement.cloneNode(true);
const codeEl = outerScaffold.querySelector('code');
for (const childEl of codeEl.children) {
if (isCodeAnnotation(childEl)) {
childEl.remove();
}
}
return codeEl.innerText;
}
const clipboard = new window.ClipboardJS('.code-copy-button:not([data-in-quarto-modal])', {
text: getTextToCopy
});
clipboard.on('success', onCopySuccess);
if (window.document.getElementById('quarto-embedded-source-code-modal')) {
const clipboardModal = new window.ClipboardJS('.code-copy-button[data-in-quarto-modal]', {
text: getTextToCopy,
container: window.document.getElementById('quarto-embedded-source-code-modal')
});
clipboardModal.on('success', onCopySuccess);
}
var localhostRegex = new RegExp(/^(?:http|https):\/\/localhost\:?[0-9]*\//);
var mailtoRegex = new RegExp(/^mailto:/);
var filterRegex = new RegExp('/' + window.location.host + '/');
var isInternal = (href) => {
return filterRegex.test(href) || localhostRegex.test(href) || mailtoRegex.test(href);
}
// Inspect non-navigation links and adorn them if external
var links = window.document.querySelectorAll('a[href]:not(.nav-link):not(.navbar-brand):not(.toc-action):not(.sidebar-link):not(.sidebar-item-toggle):not(.pagination-link):not(.no-external):not([aria-hidden]):not(.dropdown-item):not(.quarto-navigation-tool):not(.about-link)');
for (var i=0; i<links.length; i++) {
const link = links[i];
if (!isInternal(link.href)) {
// undo the damage that might have been done by quarto-nav.js in the case of
// links that we want to consider external
if (link.dataset.originalHref !== undefined) {
link.href = link.dataset.originalHref;
}
}
}
function tippyHover(el, contentFn, onTriggerFn, onUntriggerFn) {
const config = {
allowHTML: true,
maxWidth: 500,
delay: 100,
arrow: false,
appendTo: function(el) {
return el.parentElement;
},
interactive: true,
interactiveBorder: 10,
theme: 'quarto',
placement: 'bottom-start',
};
if (contentFn) {
config.content = contentFn;
}
if (onTriggerFn) {
config.onTrigger = onTriggerFn;
}
if (onUntriggerFn) {
config.onUntrigger = onUntriggerFn;
}
window.tippy(el, config);
}
const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
for (var i=0; i<noterefs.length; i++) {
const ref = noterefs[i];
tippyHover(ref, function() {
// use id or data attribute instead here
let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
try { href = new URL(href).hash; } catch {}
const id = href.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
if (note) {
return note.innerHTML;
} else {
return "";
}
});
}
const xrefs = window.document.querySelectorAll('a.quarto-xref');
const processXRef = (id, note) => {
// Strip column container classes
const stripColumnClz = (el) => {
el.classList.remove("page-full", "page-columns");
if (el.children) {
for (const child of el.children) {
stripColumnClz(child);
}
}
}
stripColumnClz(note)
if (id === null || id.startsWith('sec-')) {
// Special case sections, only their first couple elements
const container = document.createElement("div");
if (note.children && note.children.length > 2) {
container.appendChild(note.children[0].cloneNode(true));
for (let i = 1; i < note.children.length; i++) {
const child = note.children[i];
if (child.tagName === "P" && child.innerText === "") {
continue;
} else {
container.appendChild(child.cloneNode(true));
break;
}
}
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(container);
}
return container.innerHTML
} else {
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(note);
}
return note.innerHTML;
}
} else {
// Remove any anchor links if they are present
const anchorLink = note.querySelector('a.anchorjs-link');
if (anchorLink) {
anchorLink.remove();
}
if (window.Quarto?.typesetMath) {
window.Quarto.typesetMath(note);
}
if (note.classList.contains("callout")) {
return note.outerHTML;
} else {
return note.innerHTML;
}
}
}
for (var i=0; i<xrefs.length; i++) {
const xref = xrefs[i];
tippyHover(xref, undefined, function(instance) {
instance.disable();
let url = xref.getAttribute('href');
let hash = undefined;
if (url.startsWith('#')) {
hash = url;
} else {
try { hash = new URL(url).hash; } catch {}
}
if (hash) {
const id = hash.replace(/^#\/?/, "");
const note = window.document.getElementById(id);
if (note !== null) {
try {
const html = processXRef(id, note.cloneNode(true));
instance.setContent(html);
} finally {
instance.enable();
instance.show();
}
} else {
// See if we can fetch this
fetch(url.split('#')[0])
.then(res => res.text())
.then(html => {
const parser = new DOMParser();
const htmlDoc = parser.parseFromString(html, "text/html");
const note = htmlDoc.getElementById(id);
if (note !== null) {
const html = processXRef(id, note);
instance.setContent(html);
}
}).finally(() => {
instance.enable();
instance.show();
});
}
} else {
// See if we can fetch a full url (with no hash to target)
// This is a special case and we should probably do some content thinning / targeting
fetch(url)
.then(res => res.text())
.then(html => {
const parser = new DOMParser();
const htmlDoc = parser.parseFromString(html, "text/html");
const note = htmlDoc.querySelector('main.content');
if (note !== null) {
// This should only happen for chapter cross references
// (since there is no id in the URL)
// remove the first header
if (note.children.length > 0 && note.children[0].tagName === "HEADER") {
note.children[0].remove();
}
const html = processXRef(null, note);
instance.setContent(html);
}
}).finally(() => {
instance.enable();
instance.show();
});
}
}, function(instance) {
});
}
let selectedAnnoteEl;
const selectorForAnnotation = ( cell, annotation) => {
let cellAttr = 'data-code-cell="' + cell + '"';
let lineAttr = 'data-code-annotation="' + annotation + '"';
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
return selector;
}
const selectCodeLines = (annoteEl) => {
const doc = window.document;
const targetCell = annoteEl.getAttribute("data-target-cell");
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
const lineIds = lines.map((line) => {
return targetCell + "-" + line;
})
let top = null;
let height = null;
let parent = null;
if (lineIds.length > 0) {
//compute the position of the single el (top and bottom and make a div)
const el = window.document.getElementById(lineIds[0]);
top = el.offsetTop;
height = el.offsetHeight;
parent = el.parentElement.parentElement;
if (lineIds.length > 1) {
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
height = bottom - top;
}
if (top !== null && height !== null && parent !== null) {
// cook up a div (if necessary) and position it
let div = window.document.getElementById("code-annotation-line-highlight");
if (div === null) {
div = window.document.createElement("div");
div.setAttribute("id", "code-annotation-line-highlight");
div.style.position = 'absolute';
parent.appendChild(div);
}
div.style.top = top - 2 + "px";
div.style.height = height + 4 + "px";
div.style.left = 0;
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
if (gutterDiv === null) {
gutterDiv = window.document.createElement("div");
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
gutterDiv.style.position = 'absolute';
const codeCell = window.document.getElementById(targetCell);
const gutter = codeCell.querySelector('.code-annotation-gutter');
gutter.appendChild(gutterDiv);
}
gutterDiv.style.top = top - 2 + "px";
gutterDiv.style.height = height + 4 + "px";
}
selectedAnnoteEl = annoteEl;
}
};
const unselectCodeLines = () => {
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
elementsIds.forEach((elId) => {
const div = window.document.getElementById(elId);
if (div) {
div.remove();
}
});
selectedAnnoteEl = undefined;
};
// Handle positioning of the toggle
window.addEventListener(
"resize",
throttle(() => {
elRect = undefined;
if (selectedAnnoteEl) {
selectCodeLines(selectedAnnoteEl);
}
}, 10)
);
function throttle(fn, ms) {
let throttle = false;
let timer;
return (...args) => {
if(!throttle) { // first call gets through
fn.apply(this, args);
throttle = true;
} else { // all the others get throttled
if(timer) clearTimeout(timer); // cancel #2
timer = setTimeout(() => {
fn.apply(this, args);
timer = throttle = false;
}, ms);
}
};
}
// Attach click handler to the DT
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
for (const annoteDlNode of annoteDls) {
annoteDlNode.addEventListener('click', (event) => {
const clickedEl = event.target;
if (clickedEl !== selectedAnnoteEl) {
unselectCodeLines();
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
if (activeEl) {
activeEl.classList.remove('code-annotation-active');
}
selectCodeLines(clickedEl);
clickedEl.classList.add('code-annotation-active');
} else {
// Unselect the line
unselectCodeLines();
clickedEl.classList.remove('code-annotation-active');
}
});
}
const findCites = (el) => {
const parentEl = el.parentElement;
if (parentEl) {
const cites = parentEl.dataset.cites;
if (cites) {
return {
el,
cites: cites.split(' ')
};
} else {
return findCites(el.parentElement)
}
} else {
return undefined;
}
};
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
for (var i=0; i<bibliorefs.length; i++) {
const ref = bibliorefs[i];
const citeInfo = findCites(ref);
if (citeInfo) {
tippyHover(citeInfo.el, function() {
var popup = window.document.createElement('div');
citeInfo.cites.forEach(function(cite) {
var citeDiv = window.document.createElement('div');
citeDiv.classList.add('hanging-indent');
citeDiv.classList.add('csl-entry');
var biblioDiv = window.document.getElementById('ref-' + cite);
if (biblioDiv) {
citeDiv.innerHTML = biblioDiv.innerHTML;
}
popup.appendChild(citeDiv);
});
return popup.innerHTML;
});
}
}
});
</script>
</div> <!-- /content -->
</body></html>