-
Notifications
You must be signed in to change notification settings - Fork 6
/
report.html
811 lines (780 loc) · 42.3 KB
/
report.html
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
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
<!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.3.361">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="author" content="Author1, Author2">
<meta name="dcterms.date" content="2023-11-15">
<meta name="description" content="A template to help contributors style their articles and make use of different Quarto features.">
<title>How to create an article for Real World Data Science</title>
<style>
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 syntax highlighting */
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
}
pre.numberSource { margin-left: 3em; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
/* CSS for citations */
div.csl-bib-body { }
div.csl-entry {
clear: both;
}
.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="report_files/libs/clipboard/clipboard.min.js"></script>
<script src="report_files/libs/quarto-html/quarto.js"></script>
<script src="report_files/libs/quarto-html/popper.min.js"></script>
<script src="report_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="report_files/libs/quarto-html/anchor.min.js"></script>
<link href="report_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="report_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="report_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="report_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="report_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<script src="report_files/libs/quarto-contrib/kbd/kbd.js"></script>
<link href="report_files/libs/quarto-contrib/kbd/kbd.css" rel="stylesheet">
<meta name="mermaid-theme" content="neutral">
<script src="report_files/libs/quarto-diagram/mermaid.min.js"></script>
<script src="report_files/libs/quarto-diagram/mermaid-init.js"></script>
<link href="report_files/libs/quarto-diagram/mermaid.css" rel="stylesheet">
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js" type="text/javascript"></script>
<link rel="stylesheet" href="rwds.css">
</head>
<body>
<header id="title-block-header" class="quarto-title-block default page-columns page-full">
<div class="quarto-title-banner page-columns page-full">
<div class="quarto-title column-body">
<h1 class="title">How to create an article for Real World Data Science</h1>
<div>
<div class="description">
<p>A template to help contributors style their articles and make use of different Quarto features.</p>
</div>
</div>
<div class="quarto-categories">
<div class="quarto-category">Resources</div>
<div class="quarto-category">for</div>
<div class="quarto-category">Contributors</div>
</div>
</div>
</div>
<div class="quarto-title-meta">
<div>
<div class="quarto-title-meta-heading">Author</div>
<div class="quarto-title-meta-contents">
<p>Author1, Author2 </p>
</div>
</div>
<div>
<div class="quarto-title-meta-heading">Published</div>
<div class="quarto-title-meta-contents">
<p class="date">November 15, 2023</p>
</div>
</div>
</div>
</header><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="#a-main-section-about-writing-text" id="toc-a-main-section-about-writing-text" class="nav-link active" data-scroll-target="#a-main-section-about-writing-text">A main section about writing text</a>
<ul class="collapse">
<li><a href="#sub-section-creating-tables" id="toc-sub-section-creating-tables" class="nav-link" data-scroll-target="#sub-section-creating-tables">Sub-section: Creating tables</a></li>
</ul></li>
<li><a href="#another-main-section-writing-code" id="toc-another-main-section-writing-code" class="nav-link" data-scroll-target="#another-main-section-writing-code">Another main section: Writing code</a></li>
<li><a href="#figures-and-their-layout" id="toc-figures-and-their-layout" class="nav-link" data-scroll-target="#figures-and-their-layout">Figures and their layout</a></li>
<li><a href="#creating-diagrams" id="toc-creating-diagrams" class="nav-link" data-scroll-target="#creating-diagrams">Creating diagrams</a></li>
<li><a href="#interactive-elements" id="toc-interactive-elements" class="nav-link" data-scroll-target="#interactive-elements">Interactive elements</a>
<ul class="collapse">
<li><a href="#shiny" id="toc-shiny" class="nav-link" data-scroll-target="#shiny">Shiny</a></li>
<li><a href="#webr" id="toc-webr" class="nav-link" data-scroll-target="#webr">webR</a></li>
</ul></li>
<li><a href="#some-icing-on-the-cake" id="toc-some-icing-on-the-cake" class="nav-link" data-scroll-target="#some-icing-on-the-cake">Some icing on the cake</a></li>
</ul>
</nav>
</div>
<main class="content quarto-banner-title-block page-columns page-full" id="quarto-document-content">
<p>This is a template for writing Real World Data Science (RWDS) articles in <a href="https://quarto.org"><code>Quarto</code></a>. Please insert graphs and tables as static objects, i.e. <code>.png</code> files or markdown tables, rather than generating them by code, as it otherwise takes too long to render the full RWDS website.</p>
<p>One idea for a workflow could be to write your analysis and text directly in the <code>report.qmd</code> file, execute your code cells in your local terminal, save figures into the images folder, and import them as files in the <code>report.qmd</code>.</p>
<!-- TODO: What about creating the files once and freezing them? Is there a more elegant way? -->
<p>For the content of your writing, make sure to check out the resources on <a href="https://realworlddatascience.net/contributor-docs/call-for-contributions.html">RWDS—Call for Contributions</a>.</p>
<section id="a-main-section-about-writing-text" class="level2">
<h2 class="anchored" data-anchor-id="a-main-section-about-writing-text">A main section about writing text</h2>
<p>Notice how the headings and their hierarchy also show up in the table of contents on the right-hand side.</p>
<p>When writing, use <strong>bold</strong>, <em>italics</em>, and <del>strikethrough</del> text for emphasis, but use sparingly.</p>
<!-- You can also write comments for yourself, which won't show up in the rendered documents. However, be aware that these comments will be displayed in the online source code in the RWDS repository, so don't share any secrets here! -->
<p>In this subsection, we will show how to create lists and blockquotes:</p>
<ol type="1">
<li>First item</li>
<li>Second item</li>
</ol>
<ul>
<li>Item A</li>
<li>Item B
<ul>
<li>Subitem B1</li>
</ul></li>
</ul>
<blockquote class="blockquote">
<p>You can make profound statements in a blockquote.</p>
</blockquote>
<p>You can add a footnote to your writing.<a href="#fn1" class="footnote-ref" id="fnref1" role="doc-noteref"><sup>1</sup></a></p>
<p>By adding your references as BibTeX to the <code>references.bib</code> file in this repository, you not only maintain your references in the right citation style, but you can also cite directly, as recommended by <span class="citation" data-cites="example-bibtexkey">Doe (<a href="#ref-example-bibtexkey" role="doc-biblioref">2020</a>)</span>, or indirectly <span class="citation" data-cites="example-bibtexkey">(see <a href="#ref-example-bibtexkey" role="doc-biblioref">Doe 2020</a>)</span>.</p>
<p>By writing <code>---</code> you can add a horizontal line separator.</p>
<hr>
<p>If your article includes tips on special keyboard shortcuts, you can typeset them like this: <em>To print, press</em> <kbd>Shift-Ctrl-P</kbd>. <em>To open an existing new project, press</em> <kbd data-linux="Shift-Ctrl-L" data-mac="Shift-Command-O" data-windows="Shift-Control-O"></kbd>.</p>
<p>You can write equations in-line like this <span class="math inline">\(y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \epsilon \text{, }\)</span> or in a separate block like this: <span id="eq-first"><span class="math display">\[
y = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \epsilon \text{. }
\tag{1}\]</span></span></p>
<p><a href="#eq-first">Equation 1</a> is an example of a reference to an equation.</p>
<div class="callout callout-style-simple callout-note">
<div class="callout-body d-flex">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-body-container">
<p>For more information on <strong>cross-references</strong>, see the <a href="https://quarto.org/docs/authoring/cross-references.html#equations">Quarto documentation</a>.</p>
</div>
</div>
</div>
<section id="sub-section-creating-tables" class="level3">
<h3 class="anchored" data-anchor-id="sub-section-creating-tables">Sub-section: Creating tables</h3>
<p>Adding a table in markdown is easy, but can result in some formatting work. Consider using a tool like <a href="https://www.tablesgenerator.com/markdown_tables">tablesgenerator</a>, or the <a href="https://quarto.org/docs/visual-editor/">Visual Editor if you are using R Studio</a>.</p>
<div id="tbl-example" class="anchored">
<table class="table">
<caption>Table 1: Example table with a caption.</caption>
<thead>
<tr class="header">
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
<tr class="even">
<td>D</td>
<td>E</td>
<td>F</td>
</tr>
</tbody>
</table>
</div>
<p>You can also reference great tables such as <a href="#tbl-example">Table 1</a>.</p>
<p>If needed, you can also add sub-tables:</p>
<div id="tbl-panel" class="tbl-parent quarto-layout-panel anchored">
<div class="panel-caption table-caption">
<p>Table 2: Main Caption.</p>
</div>
<div class="quarto-layout-row quarto-layout-valign-top">
<div id="tbl-first" class="quarto-layout-cell quarto-layout-cell-subref anchored" data-ref-parent="tbl-panel" style="flex-basis: 50.0%;justify-content: center;">
<table class="table">
<caption>(a) First Table.</caption>
<thead>
<tr class="header">
<th style="text-align: left;">Col1</th>
<th style="text-align: left;">Col2</th>
<th style="text-align: left;">Col3</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">A</td>
<td style="text-align: left;">B</td>
<td style="text-align: left;">C</td>
</tr>
<tr class="even">
<td style="text-align: left;">E</td>
<td style="text-align: left;">F</td>
<td style="text-align: left;">G</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A</td>
<td style="text-align: left;">G</td>
<td style="text-align: left;">G</td>
</tr>
</tbody>
</table>
</div>
<div id="tbl-second" class="quarto-layout-cell quarto-layout-cell-subref anchored" data-ref-parent="tbl-panel" style="flex-basis: 50.0%;justify-content: center;">
<table class="table">
<caption>(b) Second Table.</caption>
<thead>
<tr class="header">
<th style="text-align: left;">Col1</th>
<th style="text-align: left;">Col2</th>
<th style="text-align: left;">Col3</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;">A</td>
<td style="text-align: left;">B</td>
<td style="text-align: left;">C</td>
</tr>
<tr class="even">
<td style="text-align: left;">E</td>
<td style="text-align: left;">F</td>
<td style="text-align: left;">G</td>
</tr>
<tr class="odd">
<td style="text-align: left;">A</td>
<td style="text-align: left;">G</td>
<td style="text-align: left;">G</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<p>See <a href="#tbl-panel">Table 2</a> for details, especially <a href="#tbl-second">Table 2 (b)</a>.</p>
<div class="callout callout-style-simple callout-note">
<div class="callout-body d-flex">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-body-container">
<p>For more information on <strong>tables</strong>, see the <a href="https://quarto.org/docs/authoring/tables.html#grid-tables">Quarto documentation</a>.</p>
</div>
</div>
</div>
</section>
</section>
<section id="another-main-section-writing-code" class="level2">
<h2 class="anchored" data-anchor-id="another-main-section-writing-code">Another main section: Writing code</h2>
<p>Authoring technical articles may also include code chunks. You can add code chunks in <code>R</code> like this:</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">set_signif_par</span>()</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(<span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>, <span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>, <span class="at">col=</span><span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>, <span class="at">pch=</span><span class="dv">19</span>, <span class="at">cex=</span><span class="dv">3</span>, <span class="at">xlab=</span><span class="st">""</span>, <span class="at">ylab=</span><span class="st">""</span>,</span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="at">main =</span> <span class="st">"My Significance Plot"</span>,</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> <span class="at">sub =</span> <span class="st">"Source: data source"</span>)</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="fu">abline</span>(<span class="at">h=</span><span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>, <span class="at">v=</span><span class="dv">1</span><span class="sc">:</span><span class="dv">4</span>, <span class="at">col =</span> <span class="st">"lightgrey"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>We can write not only about <code>R</code>, but also about <code>Python</code>:</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="im">import</span> pandas <span class="im">as</span> pd</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a><span class="bu">print</span>(<span class="st">"Hello this is Python code"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>or <code>Julia</code> (and many other languages):<a href="#fn2" class="footnote-ref" id="fnref2" role="doc-noteref"><sup>2</sup></a></p>
<div class="sourceCode" id="cb3"><pre class="sourceCode markdown code-with-copy"><code class="sourceCode markdown"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="in">```{julia}</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a>using Plots</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>plot(<span class="fu">sin</span>, </span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> x-><span class="fu">sin</span>(<span class="dv">2</span>x), </span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="dv">0</span>, </span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a> <span class="dv">2</span>π, </span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a> leg=false, </span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a> fill=(<span class="dv">0</span>,:lavender))</span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<p>If you want to show how to write a specific code chunk in <code>Quarto</code>, you can use the <code>echo: fenced</code> option to show the code in the output.</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode markdown code-with-copy"><code class="sourceCode markdown"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="in">```{r}</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="co"># This is a fenced code block with some R code</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a>x <span class="ot"><-</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">10</span></span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a>y <span class="ot"><-</span> x<span class="sc">^</span><span class="dv">2</span></span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="fu">plot</span>(x, y)</span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a><span class="in">```</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>If you want to reference specific lines of code, set <code>code-line-numbers: true</code>. Even better, take a look at how to do <a href="https://quarto.org/docs/authoring/code-annotation.html#annotation-syntax">interactive code annotations</a>, as these are also supported on Real World Data Science. You can see an example here (try clicking on the numbers for the highlighting):</p>
<div class="cell">
<div class="sourceCode cell-code" id="annotated-cell-5"><pre class="sourceCode numberSource r code-annotation-code number-lines code-with-copy code-annotated"><code class="sourceCode r"><span id="annotated-cell-5-1"><a href="#annotated-cell-5-1"></a><span class="fu">library</span>(tidyverse)</span>
<span id="annotated-cell-5-2"><a href="#annotated-cell-5-2"></a><span class="fu">library</span>(palmerpenguins)</span>
<a class="code-annotation-anchor" data-target-cell="annotated-cell-5" data-target-annotation="1" onclick="event.preventDefault();" href="">1</a><span id="annotated-cell-5-3" class="code-annotation-target"><a href="#annotated-cell-5-3"></a>penguins <span class="sc">|></span></span>
<a class="code-annotation-anchor" data-target-cell="annotated-cell-5" data-target-annotation="2" onclick="event.preventDefault();" href="">2</a><span id="annotated-cell-5-4" class="code-annotation-target"><a href="#annotated-cell-5-4"></a> <span class="fu">mutate</span>(</span>
<span id="annotated-cell-5-5"><a href="#annotated-cell-5-5"></a> <span class="at">bill_ratio =</span> bill_depth_mm <span class="sc">/</span> bill_length_mm,</span>
<span id="annotated-cell-5-6"><a href="#annotated-cell-5-6"></a> <span class="at">bill_area =</span> bill_depth_mm <span class="sc">*</span> bill_length_mm</span>
<span id="annotated-cell-5-7"><a href="#annotated-cell-5-7"></a> )</span><div class="code-annotation-gutter-bg"></div><div class="code-annotation-gutter"></div></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<div class="cell-annotation">
<dl class="code-annotation-container-grid">
<dt data-target-cell="annotated-cell-5" data-target-annotation="1">1</dt>
<dd>
<span data-code-lines="3" data-code-annotation="1" data-code-cell="annotated-cell-5">Take <code>penguins</code>, and then,</span>
</dd>
<dt data-target-cell="annotated-cell-5" data-target-annotation="2">2</dt>
<dd>
<span data-code-lines="4,5,6,7" data-code-annotation="2" data-code-cell="annotated-cell-5">add new columns for the bill ratio and bill area.</span>
</dd>
</dl>
</div>
</div>
</section>
<section id="figures-and-their-layout" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="figures-and-their-layout">Figures and their layout</h2>
<p>You can also add images:</p>
<p><img src="https://realworlddatascience.net/images/rwds-logo-150px.png" class="img-fluid"></p>
<p>and resize them:</p>
<p><img src="https://realworlddatascience.net/images/rwds-logo-150px.png" class="img-fluid" style="width:10.0%"></p>
<p>and reposition them:</p>
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://realworlddatascience.net/images/rwds-logo-150px.png" class="img-fluid figure-img" style="width:10.0%"></p>
</figure>
</div>
<p>You can make use of Quarto’s options to arrange multiple images in a grid, and link to both URLs and local files. Also, you can add captions to images that contain links. Local images should be stored in the folder <code>images</code> and in <code>.png</code> format.</p>
<p>You can also cross-reference figures, such as <a href="#fig-layout">Figure 1</a>, or subfigures like <a href="#fig-repo">Figure 1 (c)</a>.</p>
<div id="fig-layout" class="quarto-layout-panel">
<figure class="figure">
<div class="quarto-layout-row quarto-layout-valign-top">
<div class="quarto-layout-cell quarto-layout-cell-subref" style="flex-basis: 33.3%;justify-content: center;">
<div id="fig-data" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="https://images.unsplash.com/photo-1526628953301-3e589a6a8b74?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2006&q=80" class="img-fluid figure-img" data-ref-parent="fig-layout"></p>
<figcaption class="figure-caption">(a) <a href="https://images.unsplash.com/photo-1526628953301-3e589a6a8b74?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2006&q=80">Data</a></figcaption>
</figure>
</div>
</div>
<div class="quarto-layout-cell quarto-layout-cell-subref" style="flex-basis: 33.3%;justify-content: center;">
<div id="fig-laptop" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="https://images.unsplash.com/photo-1538688273852-e29027c0c176?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2070&q=80" class="img-fluid figure-img" data-ref-parent="fig-layout"></p>
<figcaption class="figure-caption">(b) <a href="https://images.unsplash.com/photo-1538688273852-e29027c0c176?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=2070&q=80">Laptop</a></figcaption>
</figure>
</div>
</div>
<div class="quarto-layout-cell quarto-layout-cell-subref" style="flex-basis: 33.3%;justify-content: center;">
<div id="fig-repo" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<p><img src="images/repo_cover.png" class="img-fluid figure-img" data-ref-parent="fig-layout"></p>
<figcaption class="figure-caption">(c) <a href="https://dsecon.substack.com">Cover of The Repo Newsletter</a></figcaption>
</figure>
</div>
</div>
</div>
<p></p><figcaption class="figure-caption">Figure 1: Caption for the full figure.</figcaption><p></p>
</figure>
</div>
<p>Sometimes, you might want to add an image, graph, equation, table, or simple text in the margin of the page, to further substantiate a claim that you make. Here we put the RWDS logo in the margin.</p>
<div class="no-row-height column-margin column-container"><div class="">
<div class="quarto-figure quarto-figure-center">
<figure class="figure">
<p><img src="https://realworlddatascience.net/images/rwds-logo-150px.png" class="img-fluid figure-img"></p>
<figcaption class="figure-caption">RWDS logo in the margin.</figcaption>
</figure>
</div>
</div></div><div class="callout callout-style-simple callout-note">
<div class="callout-body d-flex">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-body-container">
<p>For more information on figures, see the <a href="https://quarto.org/docs/authoring/figures.html">Quarto documentation</a>.</p>
</div>
</div>
</div>
</section>
<section id="creating-diagrams" class="level2">
<h2 class="anchored" data-anchor-id="creating-diagrams">Creating diagrams</h2>
<p>Rather than creating diagrams in Canva, Figma, or PowerPoint and pasting them into your article as an image, consider using <a href="https://mermaid-js.github.io/mermaid/#/">Mermaid</a>. Note how the chunk options for Mermaid start with <code>%%|</code> and that you need to set the option <code>eval: true</code> and <code>echo: false</code> to only generate your graph and not the code that created it. <a href="#fig-mermaid">Figure 2</a> is an example of a reference to a diagram.</p>
<div class="cell" data-eval="true" data-layout-align="center">
<div class="cell-output-display">
<div id="fig-mermaid" class="quarto-figure quarto-figure-center anchored">
<figure class="figure">
<div>
<pre class="mermaid mermaid-js" data-label="fig-mermaid">flowchart LR
A[Hard edge] --> B(Round edge)
B --> C{Decision}
C --> D[Result one]
C --> E[Result two]
</pre>
</div>
<figcaption class="figure-caption">Figure 2: This is a caption for the diagram.</figcaption>
</figure>
</div>
</div>
</div>
<div class="callout callout-style-simple callout-note">
<div class="callout-body d-flex">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-body-container">
<p>For more information on diagrams, see the <a href="https://quarto.org/docs/authoring/diagrams.html">Quarto documentation</a>.</p>
</div>
</div>
</div>
</section>
<section id="interactive-elements" class="level2">
<h2 class="anchored" data-anchor-id="interactive-elements">Interactive elements</h2>
<section id="shiny" class="level3">
<h3 class="anchored" data-anchor-id="shiny">Shiny</h3>
<p>We welcome the inclusion of interactive elements such as Shiny apps in RWDS articles. So far, the easiest way to implement these apps is to host them on your own and embed them in this article as an HTML iframe object.</p>
<p>One example workflow could be:</p>
<ol type="1">
<li>Create a Shiny app and host it on your server, e.g. on <a href="https://www.shinyapps.io/">shinyapps.io</a> (free option).</li>
<li>You can then embed the app in your article as an <a href="https://support.posit.co/hc/en-us/articles/217592607-Can-I-embed-iframe-Shiny-apps-in-other-websites-from-RStudio-Connect-">HTML iframe</a>.</li>
</ol>
<p>The iframe could look like this (replace <code>www.your_shiny_dashboard</code> with the URL of your app):</p>
<div class="cell">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode html code-with-copy"><code class="sourceCode html"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a> <span class="kw"><iframe</span> <span class="er">src</span><span class="ot">=</span><span class="st">"www.your_shiny_dashboard"</span> <span class="er">style</span><span class="ot">=</span><span class="st">"border: none; width: 100%; height: 500px"</span> <span class="er">frameborder</span><span class="ot">=</span><span class="st">"0"</span><span class="kw">></iframe></span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p>Paste this code directly into your <code>.qmd</code> file to implement the HTML iframe.</p>
<p>You can find an example in the RWDS article, <a href="https://realworlddatascience.net/ideas/datasciencebites/posts/2023/03/02/basket-complementarity.html">Using ‘basket complementarity’ to make product recommendations</a>.</p>
</section>
<section id="webr" class="level3">
<h3 class="anchored" data-anchor-id="webr">webR</h3>
<p>This webR Quarto extension, from <a href="https://thecoatlessprofessor.com/about/">James Balamuta</a>, is very exciting. As Balamuta describes, it is “designed to empower you to run R code directly in your web browser using familiar reporting tools, all without the need for an external R server.”</p>
<p>Visit the <a href="https://quarto-webr.thecoatlessprofessor.com/">quarto-webr website</a> for details on how to make full use of this capability. And check out <a href="https://realworlddatascience.net/viewpoints/editors-blog/posts/2023/09/19/positconf-blog.html#dynamic-interactions-empowering-educators-and-researchers-with-interactive-quarto-documents-using-webr">a simple working example</a> on Real World Data Science.</p>
</section>
</section>
<section id="some-icing-on-the-cake" class="level2">
<h2 class="anchored" data-anchor-id="some-icing-on-the-cake">Some icing on the cake</h2>
<p>You can add a warning to your writing like this:</p>
<div class="callout callout-style-simple callout-warning">
<div class="callout-body d-flex">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-body-container">
<p>This is a warning!</p>
</div>
</div>
</div>
<p>If your remark is too benign for a warning, but still valuable information for the reader, consider a note:</p>
<div class="callout callout-style-simple callout-note">
<div class="callout-body d-flex">
<div class="callout-icon-container">
<i class="callout-icon"></i>
</div>
<div class="callout-body-container">
<p>Want to hear more from the RSS Data Science and AI Section? Sign up for its newsletter at <a href="https://rssdsaisection.substack.com/">rssdsaisection.substack.com</a>.</p>
</div>
</div>
</div>
<p>To add more media to your article, consider embedding a video:</p>
<div class="quarto-video ratio ratio-16x9"><iframe data-external="1" src="https://www.youtube.com/embed/wo9vZccmqwc" title="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
<!-- TODO: This leads to weird formatting of the rest of the article. Also: How does this work when hosted? -->
<!-- https://quarto.org/docs/interactive/shiny/ -->
<div class="article-btn">
<p><a href="url">Back to section homepage</a></p>
</div>
<div class="further-info">
<div class="grid">
<div class="g-col-12 g-col-md-12">
<dl>
<dt>About the author</dt>
<dd>
Author 1 is… and Author 2 is…
</dd>
</dl>
</div>
<div class="g-col-12 g-col-md-6">
<dl>
<dt>Copyright and licence</dt>
<dd>
© 2023 Author 1 and Author 2
</dd>
</dl>
<p><a href="http://creativecommons.org/licenses/by/4.0/?ref=chooser-v1" target="_blank" rel="license noopener noreferrer" style="display:inline-block;"> <img style="height:22px!important;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1"><img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;" src="https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1"></a> This article is licensed under a Creative Commons Attribution 4.0 (CC BY 4.0) <a href="http://creativecommons.org/licenses/by/4.0/?ref=chooser-v1" target="_blank" rel="license noopener noreferrer" style="display:inline-block;"> International licence</a>. Thumbnail photo credit and licence goes here.</p>
</div>
<div class="g-col-12 g-col-md-6">
<dl>
<dt>How to cite</dt>
<dd>
1, Author, and Author 2. 2023. “How to create an article for Real World Data Science.” Real World Data Science, Month Day, Year. <a href="url">URL</a>
</dd>
</dl>
</div>
</div>
</div>
</section>
<div id="quarto-appendix" class="default"><section class="quarto-appendix-contents" role="doc-bibliography"><h2 class="anchored quarto-appendix-heading">References</h2><div id="refs" class="references csl-bib-body hanging-indent" role="list">
<div id="ref-example-bibtexkey" class="csl-entry" role="listitem">
Doe, Jane. 2020. <span>“Great Paper.”</span> <em>Journal of Great Insight</em> 3 (Jan): 993–1022.
</div>
</div></section><section id="footnotes" class="footnotes footnotes-end-of-document" role="doc-endnotes"><h2 class="anchored quarto-appendix-heading">Footnotes</h2>
<ol>
<li id="fn1"><p>In case you want to give an extra reference or link to a source.<a href="#fnref1" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
<li id="fn2"><p>To render documents with embedded <code>Julia</code> code, follow the <a href="https://quarto.org/docs/computations/julia.html#installation">installation instructions</a> on the Quarto website.<a href="#fnref2" class="footnote-back" role="doc-backlink">↩︎</a></p></li>
</ol>
</section></div></main>
<!-- /main column -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
const toggleBodyColorMode = (bsSheetEl) => {
const mode = bsSheetEl.getAttribute("data-mode");
const bodyEl = window.document.querySelector("body");
if (mode === "dark") {
bodyEl.classList.add("quarto-dark");
bodyEl.classList.remove("quarto-light");
} else {
bodyEl.classList.add("quarto-light");
bodyEl.classList.remove("quarto-dark");
}
}
const toggleBodyColorPrimary = () => {
const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
if (bsSheetEl) {
toggleBodyColorMode(bsSheetEl);
}
}
toggleBodyColorPrimary();
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 clipboard = new window.ClipboardJS('.code-copy-button', {
text: function(trigger) {
const codeEl = trigger.previousElementSibling.cloneNode(true);
for (const childEl of codeEl.children) {
if (isCodeAnnotation(childEl)) {
childEl.remove();
}
}
return codeEl.innerText;
}
});
clipboard.on('success', 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();
});
function tippyHover(el, contentFn) {
const config = {
allowHTML: true,
content: contentFn,
maxWidth: 500,
delay: 100,
arrow: false,
appendTo: function(el) {
return el.parentElement;
},
interactive: true,
interactiveBorder: 10,
theme: 'quarto',
placement: 'bottom-start'
};
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);
return note.innerHTML;
});
}
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";
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;
};
// 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>