-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshiny.html
1278 lines (1207 loc) · 79.9 KB
/
shiny.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
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en"><head>
<script src="shiny_files/libs/clipboard/clipboard.min.js"></script>
<script src="shiny_files/libs/quarto-html/tabby.min.js"></script>
<script src="shiny_files/libs/quarto-html/popper.min.js"></script>
<script src="shiny_files/libs/quarto-html/tippy.umd.min.js"></script>
<link href="shiny_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="shiny_files/libs/quarto-html/light-border.css" rel="stylesheet">
<link href="shiny_files/libs/quarto-html/quarto-syntax-highlighting-dark-474c6d7e63be50eb6972897072b39b27.css" rel="stylesheet" id="quarto-text-highlighting-styles"><meta charset="utf-8">
<meta name="generator" content="quarto-1.6.36">
<meta name="author" content="Tony Galván">
<meta name="dcterms.date" content="2024-12-05">
<title>Get Your Shiny On</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="shiny_files/libs/revealjs/dist/reset.css">
<link rel="stylesheet" href="shiny_files/libs/revealjs/dist/reveal.css">
<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 { 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 { display: inline-block; 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
{ color: #f8f8f2; }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span { color: #f8f8f2; } /* Normal */
code span.al { color: #f07178; background-color: #2a0f15; font-weight: bold; } /* Alert */
code span.an { color: #d4d0ab; } /* Annotation */
code span.at { color: #00e0e0; } /* Attribute */
code span.bn { color: #d4d0ab; } /* BaseN */
code span.bu { color: #abe338; } /* BuiltIn */
code span.cf { color: #ffa07a; font-weight: bold; } /* ControlFlow */
code span.ch { color: #abe338; } /* Char */
code span.cn { color: #ffd700; } /* Constant */
code span.co { color: #f8f8f2; font-style: italic; } /* Comment */
code span.cv { color: #ffd700; } /* CommentVar */
code span.do { color: #f8f8f2; } /* Documentation */
code span.dt { color: #ffa07a; } /* DataType */
code span.dv { color: #d4d0ab; } /* DecVal */
code span.er { color: #f07178; text-decoration: underline; } /* Error */
code span.ex { color: #00e0e0; font-weight: bold; } /* Extension */
code span.fl { color: #d4d0ab; } /* Float */
code span.fu { color: #ffa07a; } /* Function */
code span.im { color: #abe338; } /* Import */
code span.in { color: #d4d0ab; } /* Information */
code span.kw { color: #ffa07a; font-weight: bold; } /* Keyword */
code span.op { color: #ffa07a; } /* Operator */
code span.ot { color: #00e0e0; } /* Other */
code span.pp { color: #dcc6e0; } /* Preprocessor */
code span.re { color: #00e0e0; background-color: #f8f8f2; } /* RegionMarker */
code span.sc { color: #abe338; } /* SpecialChar */
code span.ss { color: #abe338; } /* SpecialString */
code span.st { color: #abe338; } /* String */
code span.va { color: #00e0e0; } /* Variable */
code span.vs { color: #abe338; } /* VerbatimString */
code span.wa { color: #dcc6e0; } /* Warning */
</style>
<link rel="stylesheet" href="shiny_files/libs/revealjs/dist/theme/quarto-0ea1c6122771d87abf6f0ed7683d49ef.css">
<link href="shiny_files/libs/revealjs/plugin/quarto-line-highlight/line-highlight.css" rel="stylesheet">
<link href="shiny_files/libs/revealjs/plugin/reveal-menu/menu.css" rel="stylesheet">
<link href="shiny_files/libs/revealjs/plugin/reveal-menu/quarto-menu.css" rel="stylesheet">
<link href="shiny_files/libs/revealjs/plugin/quarto-support/footer.css" rel="stylesheet">
<style type="text/css">
.reveal div.sourceCode {
margin: 0;
overflow: auto;
}
.reveal div.hanging-indent {
margin-left: 1em;
text-indent: -1em;
}
.reveal .slide:not(.center) {
height: 100%;
}
.reveal .slide.scrollable {
overflow-y: auto;
}
.reveal .footnotes {
height: 100%;
overflow-y: auto;
}
.reveal .slide .absolute {
position: absolute;
display: block;
}
.reveal .footnotes ol {
counter-reset: ol;
list-style-type: none;
margin-left: 0;
}
.reveal .footnotes ol li:before {
counter-increment: ol;
content: counter(ol) ". ";
}
.reveal .footnotes ol li > p:first-child {
display: inline-block;
}
.reveal .slide ul,
.reveal .slide ol {
margin-bottom: 0.5em;
}
.reveal .slide ul li,
.reveal .slide ol li {
margin-top: 0.4em;
margin-bottom: 0.2em;
}
.reveal .slide ul[role="tablist"] li {
margin-bottom: 0;
}
.reveal .slide ul li > *:first-child,
.reveal .slide ol li > *:first-child {
margin-block-start: 0;
}
.reveal .slide ul li > *:last-child,
.reveal .slide ol li > *:last-child {
margin-block-end: 0;
}
.reveal .slide .columns:nth-child(3) {
margin-block-start: 0.8em;
}
.reveal blockquote {
box-shadow: none;
}
.reveal .tippy-content>* {
margin-top: 0.2em;
margin-bottom: 0.7em;
}
.reveal .tippy-content>*:last-child {
margin-bottom: 0.2em;
}
.reveal .slide > img.stretch.quarto-figure-center,
.reveal .slide > img.r-stretch.quarto-figure-center {
display: block;
margin-left: auto;
margin-right: auto;
}
.reveal .slide > img.stretch.quarto-figure-left,
.reveal .slide > img.r-stretch.quarto-figure-left {
display: block;
margin-left: 0;
margin-right: auto;
}
.reveal .slide > img.stretch.quarto-figure-right,
.reveal .slide > img.r-stretch.quarto-figure-right {
display: block;
margin-left: auto;
margin-right: 0;
}
</style>
</head>
<body class="quarto-dark">
<div class="reveal">
<div class="slides">
<section id="title-slide" data-notes="Hi everyone! My name is Tony Galvan, and I’m thrilled to welcome you to this session, ‘Get Your Shiny On: Turning R Code into Interactive Gold!’ Today, we’re going to embark on a journey where we transform static data into dynamic, interactive stories using Shiny. Imagine you’re a storyteller, but instead of words, you use data. Shiny is the magic wand that brings your data stories to life, making them engaging and interactive. Whether you’re building dashboards, apps, or experimenting with machine learning models, Shiny opens up a world of possibilities. Before we dive into the magic of Shiny, let’s do a quick roll call. In the chat, could everyone share where they’re tuning in from? It’s always fascinating to see the diverse locations represented in these sessions. Also, make sure you’ve got RStudio open and ready to go. This is going to be a hands-on session, and we’ll be coding together. By the end of this session, you’ll have the confidence to start building your own Shiny apps and tell your own data stories." class="quarto-title-block center">
<h1 class="title">Get Your Shiny On</h1>
<p class="subtitle">Turning R Code into Interactive Gold!</p>
<div class="quarto-title-authors">
<div class="quarto-title-author">
<div class="quarto-title-author-name">
Tony Galván
</div>
</div>
</div>
<p class="date">2024-12-05</p>
</section>
<section id="life-changing-stories" class="slide level2">
<h2>Life Changing Stories <!-- slide_02 --></h2>
<div class="columns">
<div class="column" style="width:50%;">
<p><a href="https://en.wikipedia.org/wiki/Rudy_(film)"><img data-src="https://upload.wikimedia.org/wikipedia/en/f/f1/Rudy_%281993_movie_poster%29.jpg" width="393"></a></p>
</div><div class="column" style="width:50%;">
<p><a href="https://youtu.be/eBJmj2cJrpE?si=Kod3aOJ0J2DVwAbx"><img data-src="images/clipboard-2848714017.png"></a></p>
</div></div>
<aside class="notes">
<p>Stories have a unique power to inspire and transform our lives. Today, I want to share two stories that changed my life.</p>
<p>The first story takes us back to October 1993. I was a junior in high school, and my football team was in the midst of an incredible run to the CIF championship in Southern California. Around that time, the movie Rudy was released. For those who haven’t seen it, please raise your hand so that we can all shame you. Rudy is the true story of a young man who dreams of playing football at Notre Dame despite all odds. The movie’s message of perseverance and following your dreams struck a chord with me. It was so inspiring that it prompted me to apply to Notre Dame—a school I had never considered before. And as they say, the rest is history.</p>
<p>The second story from a TEDx talk on YouTube video called ‘Big Data for the Common Good’ by Nitesh Chawla, a professor at Notre Dame. He argues that by paying attention to the facts and circumstances of people’s daily lives, we can significantly improve health and wellness. He talks about how tracking personal data on a large scale can help us move from insufficient healthcare to abundant health. This idea of using data for the greater good resonated deeply with me.</p>
<p>This video was instrumental in convincing my wife that I should pursue a Master’s in Data Science at Notre Dame, despite having two small children under 7 and holding down a full-time job. It was a challenging decision, but the story’s message about the power of data to make a difference made it clear that this was the right path for me.</p>
<p>These stories illustrate the power of well-told narratives to inspire action and change lives. And that’s exactly what Shiny allows us to do—tell better, more engaging stories with our data, machine learning models, and more.</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="my-journey-as-a-double-domer" class="slide level2">
<h2>My Journey as a Double Domer <!-- slide_03 --></h2>
<h3 id="university-of-notre-dame"><span style="color: #74c947">University of Notre Dame</span></h3>
<div class="columns">
<div class="column" style="width:60%;">
<ul>
<li>1999 B.B.A. Management Information Systems</li>
<li>2019 M.S. Data Science</li>
</ul>
</div><div class="column" style="width:40%;">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="images/now_and_then.jpg" class="quarto-figure quarto-figure-center"></p>
</figure>
</div>
</div></div>
<aside class="notes">
<p>You know, they say good things come in pairs, and that’s certainly true for my diplomas from Notre Dame. I’m a proud Double Domer, having graduated not once, but twice. The first time was back in 1999 with a Bachelor of Business Administration in Management Information Systems, and then I made my triumphant return in 2019 to earn a Master of Science in Data Science.</p>
<p>On this slide, you’ll see two photos that are pretty special to me. The top photo is from 1997 when I was a Student Manager for the Notre Dame football team, working under legendary coaches Lou Holtz and Urban Meyer. And yes, I also worked under the not-so-legendary coach Bob Davie. It was an incredible experience that taught me a lot about teamwork and perseverance.</p>
<p>The bottom photo is from my 2019 graduation. This time, I was lucky enough to share the day with my wife, kids, and extended family, all proudly wearing matching ‘Double Domer’ t-shirts. It was a moment of celebration and reflection on the journey we had all been through together.</p>
<p>Notre Dame didn’t just give me degrees—it gave me a mission to fight for good, lifelong friendships, and relationships that I cherish to this day. It’s a place where I learned to bleed blue and gold, and it instilled in me a passion for continuous learning and making a positive impact in the world.</p>
<p>And that passion for learning and making a difference is what I’m here to share with you today.</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="what-im-up-to-these-days" class="slide level2">
<h2>What I’m Up to These Days <!-- slide_04 --></h2>
<div class="columns">
<div class="column" style="width:50%;">
<h3 id="acorns"><span style="color: #74c947">Acorns</span></h3>
<ul>
<li>Data Analyst</li>
<li>Analytics Engineer</li>
</ul>
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="https://sqy7rm.media.zestyio.com/Acorns-Logo.svg" class="quarto-figure quarto-figure-center" height="200"></p>
</figure>
</div>
</div><div class="column" style="width:50%;">
<h3 id="tidy-tuesday"><span style="color: #74c947">Tidy Tuesday</span></h3>
<ul>
<li>Tuesdays @ 11AM PST on <a href="https://notredame.zoom.us/j/93246968828?pwd=T2k0QUFKNkxvMkV2ekZrejdpdTJIdz09" target="_blank">Zoom</a></li>
</ul>
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/static/tt_logo.png" class="quarto-figure quarto-figure-center"></p>
</figure>
</div>
</div></div>
<aside class="notes">
<p>So, what am I up to these days? Well, I work as an Analytics Engineer and Data Analyst at Acorns. My day-to-day involves wrangling data, building dashboards, and automating workflows. Basically, I’m a professional data problem solver — except my puzzles occasionally yell at me in the form of cryptic error messages.</p>
<p>Outside of work, I run weekly Tidy Tuesday sessions. These are casual get-togethers where we take random datasets and try to uncover insights—or at least find a halfway decent visualization. It’s part data exploration, part group therapy for R users.</p>
<p>Tidy Tuesday is where I’ve really leveled up my data science game. It’s been a playground for learning, a laboratory for failed experiments, and a reminder that even the most boring datasets can shine with a little creativity. It’s also where I discovered that debugging is way more tolerable when someone else is suffering alongside you.</p>
<p>Today, I’m excited to share some of the lessons I’ve learned through work, Tidy Tuesday, and a whole lot of trial and error. Let’s jump in and see how Shiny can add a whole new dimension to your data science toolkit!</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="what-is-shiny" class="slide level2">
<h2>What is Shiny? <!-- slide_05 --></h2>
<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="" aria-hidden="true" tabindex="-1"></a><span class="fu">install.packages</span>(<span class="st">"shiny"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<aside class="notes">
<p>Alright, now that you know a bit about me, it’s time to focus on the real star of today’s show: Shiny!</p>
<p>Before we dive into the details, let me ask you a quick question: how familiar are you with Shiny? Drop your answer in the chat—are you a:</p>
<p>Shiny newbie (nothing at all), Homework hero (just what we did for class), Casual tinkerer (a little work experience), Or a Shiny master (you eat reactive programming for breakfast)? While you’re sharing, let’s make sure everyone’s ready to roll. Open up RStudio and install Shiny by running this code snippet: install.packages(“shiny”)</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
<div class="fragment">
<ul>
<li>Transforms static R code into dynamic, interactive experiences</li>
<li>No need for HTML, CSS, or JavaScript</li>
<li>Reactive: Automatically updates outputs when inputs change</li>
</ul>
<aside class="notes">
<p>So, what is Shiny? In a nutshell, it’s an R package that lets you build interactive web applications right from R. No HTML, CSS, or JavaScript knowledge required—it’s like a shortcut to web development greatness.</p>
<p>With Shiny, you can create dashboards, visualizations, and even full-fledged web apps. And the best part? It’s reactive, meaning your app automatically updates when inputs change. It’s like magic, but with fewer wands and more parentheses.</p>
<p>We’re going to get hands-on with Shiny today, and by the end of this session, you’ll be ready to build your own interactive masterpieces. So, what do you say—ready to get your Shiny on?</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</div>
</section>
<section id="anatomy-of-a-shiny-app" class="slide level2 smaller">
<h2>Anatomy of a Shiny App <!-- slide_06 --></h2>
<div class="cell">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(shiny)</span>
<span id="cb2-2"><a href="" aria-hidden="true" tabindex="-1"></a>ui <span class="ot"><-</span> ... <span class="co"># UI elements go here</span></span>
<span id="cb2-3"><a href="" aria-hidden="true" tabindex="-1"></a>server <span class="ot"><-</span> <span class="cf">function</span>(input, output) {</span>
<span id="cb2-4"><a href="" aria-hidden="true" tabindex="-1"></a> ... <span class="co"># Server logic goes here</span></span>
<span id="cb2-5"><a href="" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb2-6"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">shinyApp</span>(ui, server)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<aside class="notes">
<p>Alright, we’ve got Shiny installed — congrats! You’re officially ready to build something awesome. But before we jump into coding, let’s break down the basic anatomy of a Shiny app. Think of it as a crash course in app biology.</p>
<p>First up, there are three main components:</p>
<p>UI (User Interface): This is like the shiny (pun intended) hotel lobby — it’s what users see and interact with. Buttons, sliders, and text boxes live here, welcoming your users like a charming front desk concierge. Server: Behind the scenes, this is where the real magic happens. If the UI is the lobby, the server is the overworked hotel staff making sure the Wi-Fi, room service, and weirdly specific guest requests all work seamlessly. shinyApp: This is the matchmaker that brings the UI and server together, turning your code into a fully functional app.</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
<div class="fragment">
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="shiny_files/figure-revealjs/ShinyUIServer-1.png" class="quarto-figure quarto-figure-center" width="960"></p>
</figure>
</div>
</div>
</div>
<aside class="notes">
<p>Now, check out the diagram on the slide. It’s like the flowchart version of a rom-com:</p>
<p>Inputs from the UI go to the server. Imagine your user clicking a button or entering text—it’s like placing an order at a coffee shop. Outputs flow back from the server to the UI. This is your latte (or chart, or table) being served in all its glory. This back-and-forth makes Shiny apps reactive. The server is always listening for changes in inputs and updating the outputs, creating that smooth, interactive experience.</p>
<p>So how does all this magic work? When you run a Shiny app locally, it sets up a mini web server on your computer. Your machine becomes both the chef and the diner, cooking up data and serving it to yourself.</p>
<p>If you publish your app to a web server, things get fancier. The web server hosts your app, and anyone with an internet connection can use it. It’s like opening your own restaurant—except no health inspections.</p>
<p>Before you roll up your sleeves and build your first Shiny app, let’s take a look at some examples to see what’s possible. From holiday countdown timers to CIA factbook visualizations, Shiny apps can be as simple or complex as you want. Let’s dive in and see what sparks your creativity!</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</div>
</section>
<section id="tidy-tuesday-examples" class="slide level2">
<h2>Tidy Tuesday Examples <!-- slide_07 --></h2>
<div class="columns">
<div class="column" style="width:50%;">
<p><a href="https://gdatascience.shinyapps.io/holiday-timer/" target="_blank">Holiday Countdown Timer</a></p>
<p><img data-src="images/clipboard-1124655419.png"></p>
</div><div class="column" style="width:50%;">
<p><a href="https://gdatascience.shinyapps.io/cia_factbook/" target="_blank">CIA Factbook Country Cluster Explorer</a></p>
<p><img data-src="images/clipboard-1508160099.png"></p>
</div></div>
<aside class="notes">
<p>Now, I want to show you a couple of Shiny apps I’ve created during my Tidy Tuesday sessions. These projects were a fun way to explore data, sharpen my skills, and sometimes—even unintentionally—discover bugs!</p>
<p>Holiday Timer This app is a simple countdown timer for upcoming holidays. It shows the days, minutes, and seconds remaining until the next big event. Fun fact: there’s a timezone bug that skews the countdown by a few hours. I never got around to debugging it, but hey—it’s a feature, not a flaw, right?</p>
<p>2014 CIA Factbook Country Cluster Explorer This app uses data from the CIA Factbook to group countries based on various metrics with k-means clustering. Users can explore scatter plots of different variables, and the app color-codes the points by their cluster.</p>
<p>When I first built this app, it was clear to me that two clusters were the best choice—simple, explainable, and meaningful. But, sometimes in the real world, stakeholders want to see all of the data and clustering options for themselves. Enter Shiny! With its dynamic interactivity, the app allows users to experiment with different numbers of clusters and immediately see the results while keeping you out of endless back-and-forths.</p>
<p>Both of these apps started as experiments, and they taught me a lot about Shiny’s capabilities—and its quirks.</p>
<p>Now, I’m excited to see what you will create as we get hands-on. But first, let’s go step-by-step and build something interactive together.</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="create-a-shiny-app" class="slide level2">
<h2>Create a Shiny App <!-- slide_08 --></h2>
<div class="columns">
<div class="column" style="width:50%;">
<p>File > New File</p>
<ul>
<li>Shiny Web App</li>
</ul>
<div class="quarto-figure quarto-figure-left">
<figure>
<p><img data-src="images/clipboard-1611009231.png" class="quarto-figure quarto-figure-left" height="350"></p>
</figure>
</div>
</div><div class="column" style="width:50%;">
<p>Application name:</p>
<ul>
<li><strong>old_faithful</strong></li>
</ul>
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="images/clipboard-4002331887.png" class="quarto-figure quarto-figure-center"></p>
</figure>
</div>
</div></div>
<aside class="notes">
<p>Alright, it’s time to get our hands dirty and create our first Shiny app using R Studio. Follow these steps with me:</p>
<ol type="1">
<li><p>Open R Studio.</p></li>
<li><p>Go to the top menu and click on <strong>File</strong>.</p></li>
<li><p>Select <strong>New File</strong> from the dropdown menu.</p></li>
<li><p>Choose <strong>Shiny Web App</strong> from the options.</p></li>
<li><p>A dialog box will appear. Enter the Application Name as <strong>‘old_faithful’</strong>.</p></li>
<li><p>For Application Type, select <strong>‘Single File (app.R)’</strong>. This option is great for simple apps and is perfect for our first Shiny app.</p></li>
<li><p>Click the <strong>‘Browse’</strong> button to choose the directory where you want to save your app.</p></li>
<li><p>Click the <strong>‘Create’</strong> button.</p></li>
</ol>
<p>And just like that, R Studio will generate a basic Shiny app template for you. This template includes a simple user interface and server logic that we can build upon.</p>
<p>Let’s take a moment to explore what R Studio has created for us. You’ll see two main sections in the <strong>‘app.R’</strong> file: the UI and server components. The UI section defines the layout of the app, while the server section contains the logic to make the app interactive.</p>
<p>By following these steps, you’ve just created the foundation of your first Shiny app. Now, let’s dive into the code and start customizing it to make it our own!</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="run-the-shiny-app" class="slide level2">
<h2>Run the Shiny App</h2>
<img data-src="images/run_shiny.png" class="quarto-figure quarto-figure-center r-stretch"><aside class="notes">
<p>Now that we’ve created our first Shiny app, it’s time to see it in action! Here’s how you can run your Shiny app in R Studio:</p>
<p>In R Studio, locate the ‘Run App’ button, which is usually at the top right corner of the script editor. Click on the ‘Run App’ button. When you click this button, R Studio does something pretty cool behind the scenes. It sets up a local web server on your machine. This local server is what makes your Shiny app interactive and responsive.</p>
<p>Once the server is up and running, your app will launch in a new window. This window is where you can interact with your app, see the outputs, and test the functionality.</p>
<p>So, what’s happening behind the scenes? Here’s a quick rundown:</p>
<ul>
<li><p>R Studio starts a local web server that hosts your Shiny app. This server handles all the communication between the UI and server components of your app.</p></li>
<li><p>As you interact with the app (e.g., entering data, clicking buttons), the server processes these inputs and updates the outputs in real-time.</p></li>
<li><p>The app runs in a web browser window, giving you a preview of how it will look and behave when deployed on a web server. By running your app locally, you can develop and test it before sharing it with others. It’s a great way to ensure everything works as expected and to make any necessary tweaks.</p></li>
</ul>
<p>Ready to give it a try? Click that ‘Run App’ button and watch your Shiny app come to life!</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="old-faithful-geyser-data" class="slide level2">
<h2>Old Faithful Geyser Data <!-- slide_09 --></h2>
<div class="cell">
<div class="cell-output-display">
<div class="form-group shiny-input-container">
<label class="control-label" id="bins-label" for="bins">Number of bins:</label>
<input class="js-range-slider" id="bins" data-skin="shiny" data-min="1" data-max="50" data-from="30" data-step="1" data-grid="true" data-grid-num="9.8" data-grid-snap="false" data-prettify-separator="," data-prettify-enabled="true" data-keyboard="true" data-data-type="number">
</div>
</div>
<div class="cell-output-display">
<div class="shiny-plot-output html-fill-item" id="distPlot" style="width:100%;height:400px;"></div>
</div>
</div>
<aside class="notes">
<p>Now that we’ve run our Shiny app, let’s take a closer look at what it does and how it works. Our app is a simple yet powerful example that visualizes the Old Faithful Geyser data. Here’s what you’ll see:</p>
<ul>
<li><p>The app has a clear and descriptive title at the top: ‘Old Faithful Geyser Data’. This lets users know exactly what the app is about.</p></li>
<li><p>Below the title, there’s a slider input labeled ‘Number of bins’. This slider allows users to adjust the number of bins in the histogram. The range is from 1 to 50, with a default value set to 30. This interactivity lets users explore the data in different levels of granularity.</p></li>
<li><p>The main feature of the app is a histogram plot of the Old Faithful Geyser eruption durations. This plot is generated using base R graphics. As users adjust the slider, the histogram updates in real-time to reflect the new number of bins, providing an immediate visual feedback.</p></li>
</ul>
<p>So, how does this all work together? When you move the slider, the input value is sent to the server. The server then recalculates the histogram with the specified number of bins and sends the updated plot back to the UI. This seamless interaction is what makes Shiny apps so engaging and dynamic.</p>
<p>By exploring this app, you can see how Shiny makes it easy to add interactivity to your data visualizations. It’s a great starting point for building more complex and customized applications.</p>
<p>Ready to build on this foundation and create something even more exciting? Let’s dive deeper into Shiny’s capabilities!</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="shiny-layouts" class="slide level2">
<h2>Shiny Layouts <!-- slide_10 --></h2>
<div class="cell">
<div class="sourceCode cell-code" id="cb3" data-code-line-numbers="1-4,11"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href=""></a><span class="fu">fluidPage</span>(</span>
<span id="cb3-2"><a href=""></a> <span class="fu">titlePanel</span>(<span class="st">"Old Faithful Geyser Data"</span>),</span>
<span id="cb3-3"><a href=""></a> <span class="fu">sidebarLayout</span>(</span>
<span id="cb3-4"><a href=""></a> <span class="fu">sidebarPanel</span>(</span>
<span id="cb3-5"><a href=""></a> <span class="fu">sliderInput</span>(</span>
<span id="cb3-6"><a href=""></a> <span class="at">inputId =</span> <span class="st">"bins"</span>,</span>
<span id="cb3-7"><a href=""></a> <span class="at">label =</span> <span class="st">"Number of bins:"</span>,</span>
<span id="cb3-8"><a href=""></a> ... <span class="co"># Other arguments (e.g., min, max, value)</span></span>
<span id="cb3-9"><a href=""></a> )</span>
<span id="cb3-10"><a href=""></a> ),</span>
<span id="cb3-11"><a href=""></a> <span class="fu">mainPanel</span>(</span>
<span id="cb3-12"><a href=""></a> <span class="fu">plotOutput</span>(<span class="st">"distPlot"</span>)</span>
<span id="cb3-13"><a href=""></a> )</span>
<span id="cb3-14"><a href=""></a> )</span>
<span id="cb3-15"><a href=""></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p><a href="https://shiny.posit.co/r/layouts/" target="_blank">Shiny Layout Gallery</a></p>
<aside class="notes">
<p>Let’s talk about the foundation of any Shiny app: the layout. A good layout isn’t just about looking pretty—it’s what makes your app intuitive and easy to use. If the layout is the stage, your data is the star, and Shiny helps set the scene beautifully.</p>
<p>The most popular layout in Shiny is fluidPage. It’s like the stretchy yoga pants of app design—it adapts effortlessly to different screen sizes, from desktops to mobile phones. Whether your users are on a giant monitor or squinting at their phone, fluidPage keeps your app looking sharp.</p>
<p>For apps that need tabs, navbarPage is a solid choice. It’s perfect for breaking down complex content into bite-sized, navigable pieces. If you’re designing an app with controls on the side—like sliders or input boxes—sidebarLayout is your go-to.</p>
<p>Take a look at this simple code snippet:</p>
<p>Line 1: fluidPage() is the main wrapper that defines a responsive, single-page layout. Everything you see in the app will live inside this. Line 2: titlePanel() is the header—it’s like your app’s welcome mat, setting the tone with a title. Line 3: sidebarLayout() creates the structure for a side panel and main content area. Think of it like a two-column newspaper: controls on one side, results on the other. Line 4: Inside sidebarLayout(), sidebarPanel() is where the controls go—sliders, buttons, dropdowns, and anything your user interacts with. Line 11: mainPanel() is for the main attraction—charts, tables, or whatever outputs your app is generating. The magic of Shiny layouts is how flexible and intuitive they are. Not sure where to start? Check out Shiny’s layout gallery, which is packed with examples to spark your creativity.</p>
<p>And here’s the key takeaway: a thoughtful layout doesn’t just make your app look polished—it makes it more effective, drawing your audience into the story you’re telling with your data.</p>
<p>Now, let’s dive into the interactive elements that bring these layouts to life.</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="shiny-widgets" class="slide level2">
<h2>Shiny Widgets <!-- slide_11 --></h2>
<div class="cell">
<div class="sourceCode cell-code" id="cb4" data-code-line-numbers="5-9"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href=""></a><span class="fu">fluidPage</span>(</span>
<span id="cb4-2"><a href=""></a> <span class="fu">titlePanel</span>(<span class="st">"Old Faithful Geyser Data"</span>),</span>
<span id="cb4-3"><a href=""></a> <span class="fu">sidebarLayout</span>(</span>
<span id="cb4-4"><a href=""></a> <span class="fu">sidebarPanel</span>(</span>
<span id="cb4-5"><a href=""></a> <span class="fu">sliderInput</span>(</span>
<span id="cb4-6"><a href=""></a> <span class="at">inputId =</span> <span class="st">"bins"</span>,</span>
<span id="cb4-7"><a href=""></a> <span class="at">label =</span> <span class="st">"Number of bins:"</span>,</span>
<span id="cb4-8"><a href=""></a> ... <span class="co"># Other arguments (e.g., min, max, value)</span></span>
<span id="cb4-9"><a href=""></a> )</span>
<span id="cb4-10"><a href=""></a> ),</span>
<span id="cb4-11"><a href=""></a> <span class="fu">mainPanel</span>(</span>
<span id="cb4-12"><a href=""></a> <span class="fu">plotOutput</span>(<span class="st">"distPlot"</span>)</span>
<span id="cb4-13"><a href=""></a> )</span>
<span id="cb4-14"><a href=""></a> )</span>
<span id="cb4-15"><a href=""></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p><a href="https://shiny.posit.co/r/gallery/widgets/widget-gallery/" target="_blank">Shiny Widgets Gallery</a></p>
<aside class="notes">
<p>Now that we’ve nailed the layout, it’s time to make your app interactive. This is where widgets come in—the elements that let users interact with your app.</p>
<p>Widgets in Shiny are like the controls on a dashboard: they take user input and feed it to your server, which updates the outputs in real time. Here are some of the most common widgets:</p>
<ul>
<li>sliderInput: Ideal for selecting values within a range, like filtering data.</li>
<li>radioButtons: Perfect for choosing between predefined options.</li>
<li>textInput: Allows users to enter custom text, great for dynamic queries.</li>
<li>And of course, there are dropdowns, checkboxes, and buttons to cover all your interaction needs.</li>
</ul>
<p>For example, let’s break down the sliderInput widget:</p>
<p>This creates a slider that controls the number of bins in a histogram. The inputId links it to the server, the label is what users see, and the min, max, and value define its range and default setting.</p>
<p>Shiny’s widget gallery is your go-to resource for exploring all the available widgets and learning how to implement them.</p>
<p>Now, as we get hands-on with widgets in our apps, don’t worry too much about making things perfect. Focus on getting something interactive up and running. And remember, the cleaner look you’ll learn on the next slide can really help showcase the functionality of these widgets.</p>
<p>Let’s move on and bring some style to all this interactivity!</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="bootstrap-theme" class="slide level2">
<h2>Bootstrap Theme <!-- slide_12 --></h2>
<div class="cell">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(bslib)</span>
<span id="cb5-2"><a href="" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-3"><a href="" aria-hidden="true" tabindex="-1"></a>ui <span class="ot"><-</span> <span class="fu">fluidPage</span>(</span>
<span id="cb5-4"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">theme =</span> <span class="fu">bs_theme</span>(<span class="at">bootswatch =</span> <span class="st">"darkly"</span>),</span>
<span id="cb5-5"><a href="" aria-hidden="true" tabindex="-1"></a> ...</span>
<span id="cb5-6"><a href="" aria-hidden="true" tabindex="-1"></a>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<img data-src="images/clipboard-158655481.png" class="r-stretch"><p><a href="https://bootswatch.com/" target="_blank">Bootswatch Theme Gallery</a></p>
<aside class="notes">
<p>So, your Shiny app is working great, but let’s be honest—does it look great? Sometimes, all it takes to upgrade your app from boring to amazing is a cleaner, more polished design. That’s where the {bslib} package comes in.</p>
<p>{bslib} lets you use the bs_theme() function to apply a Bootswatch theme to your Shiny app. With just one line of code, you can give your app a whole new vibe—no CSS wizardry required.</p>
<p>Here’s an example using the Darkly theme:</p>
<p>The Darkly theme gives your app a sleek, moody aesthetic—perfect for data visualizations that feel bold and modern.</p>
<p>Want more options? Visit the Bootswatch gallery to explore a variety of themes, including:</p>
<ul>
<li>Cerulean for a clean, professional look.</li>
<li>Flatly for something modern and polished.</li>
<li>Lumen if you’re going for bright and clean.</li>
</ul>
<p>Here’s the fun part: Using {bslib} is my little Easter egg for you. It’s one of those simple but powerful tools that can instantly take your app to the next level. You don’t need to change any functionality—just swap in a theme, and suddenly your app feels more professional and engaging.</p>
<p>It’s amazing how much a clean, cohesive design can elevate the user experience. So, while everyone’s busy perfecting the backend, don’t forget to make your frontend shine, too.</p>
<p>Let’s experiment with this and give your apps a stylish boost!</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="old-faithful-geyser-app" class="slide level2">
<h2>Old Faithful Geyser App <!-- slide_13 --></h2>
<h3 id="eruption-duration-vs.-waiting-time"><span style="color: #74c947">Eruption Duration vs. Waiting Time</span></h3>
<div class="layout-sidebar layout-sidebar-left">
<div class="cell panel-sidebar">
<div class="cell-output-display">
<div class="form-group shiny-input-container">
<label class="control-label" id="duration-label" for="duration">Eruption Duration (minutes):</label>
<input class="js-range-slider" id="duration" data-skin="shiny" data-type="double" data-min="1.6" data-max="5.1" data-from="1.6" data-to="5.1" data-step="0.05" data-grid="true" data-grid-num="10" data-grid-snap="false" data-prettify-separator="," data-prettify-enabled="true" data-keyboard="true" data-drag-interval="true" data-data-type="number">
</div>
</div>
<div class="cell-output-display">
<div class="form-group shiny-input-container">
<label class="control-label" id="waiting-label" for="waiting">Waiting Time (minutes):</label>
<input class="js-range-slider" id="waiting" data-skin="shiny" data-type="double" data-min="43" data-max="96" data-from="43" data-to="96" data-step="1" data-grid="true" data-grid-num="8.83333333333333" data-grid-snap="false" data-prettify-separator="," data-prettify-enabled="true" data-keyboard="true" data-drag-interval="true" data-data-type="number">
</div>
</div>
</div>
<div class="cell panel-fill">
<div class="cell-output-display">
<div class="plotly html-widget html-widget-output shiny-report-size shiny-report-theme html-fill-item" id="scatterPlot" style="width:100%;height:400px;"></div>
</div>
</div>
</div>
<aside class="notes">
<p>Alright, it’s time for a challenge! We’re going to take the default Old Faithful histogram app that comes with Shiny and transform it into something much more interactive and powerful.</p>
<p>Here’s the goal: adapt the default app to create an interactive scatter plot of the Old Faithful dataset, showing eruption durations on the x-axis and waiting times on the y-axis. We’ll be enhancing it with:</p>
<ul>
<li>Sliders to filter values on both axes.</li>
<li>Plot interactivity using ggplot2 for visuals and Plotly for zooming, panning, and hovering.</li>
</ul>
<p>Once your group gets the basics working, you can earn bonus points by tackling these advanced challenges:</p>
<ol type="1">
<li>Add a dropdown: Allow users to choose a color for the points on the scatter plot.</li>
<li>Dynamic title: Update the plot title based on the slider values.</li>
<li>Summary table: Display average, minimum, and maximum values for the filtered data.</li>
<li>Styling: Use custom CSS or themes to make the app look polished and professional.</li>
</ol>
<p>We’ll break into small groups, and each group will work on adapting the default app into this enhanced version. I’ve included all the hints and documentation you’ll need, but feel free to ask me for help if you get stuck.</p>
<p>Remember, this is a creative and collaborative exercise. Even if you’re new to Shiny, give it a try and see how much progress your group can make.</p>
<p>At the end, we’ll come back together to showcase what you’ve built and discuss what you learned. Good luck—let’s get coding!</p>
<style type="text/css">
span.MJX_Assistive_MathML {
position:absolute!important;
clip: rect(1px, 1px, 1px, 1px);
padding: 1px 0 0 0!important;
border: 0!important;
height: 1px!important;
width: 1px!important;
overflow: hidden!important;
display:block!important;
}</style></aside>
</section>
<section id="questions" class="slide level2">
<h2>Questions? <!-- slide_14 --></h2>
<ul>
<li><a href="https://www.linkedin.com/in/anthony-raul-galvan" target="_blank">LinkedIn.com/in/anthony-raul-galvan</a></li>
<li><a href="mailto:[email protected]" target="_blank">Email: [email protected]</a></li>
</ul>
<p>
<script type="application/shiny-prerendered" data-context="server">
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white',
xlab = 'Waiting time to next eruption (in mins)',
main = 'Histogram of waiting times')
})
</script>
<script type="application/shiny-prerendered" data-context="server">
library(plotly)
library(ggplot2)
library(dplyr)
output$scatterPlot <-
renderPlotly({
ggplotly(
faithful |>
filter(
eruptions >= input$duration[1],
eruptions <= input$duration[2],
waiting >= input$waiting[1],
waiting <= input$waiting[2]
) |>
ggplot(aes(x = eruptions, y = waiting)) +
geom_point(
color = "#74c947"
) +
geom_smooth(
method = "lm", formula = y ~ x,
se = FALSE,
color = "#9471f6",
lty = 2
) +
labs(
x = "Eruption Duration (minutes)",
y = "Waiting Time (minutes)"
) +
theme_light() +
theme(
panel.background = element_rect(
fill = "#363f41",
color = "#363f41"
),
panel.border = element_rect(
color = "#363f41"
),
plot.background = element_rect(
fill = "#363f41",
color = "#363f41"
),
text = element_text(
family = "Avenir Next",
color = "white"
),
axis.text = element_text(
family = "Avenir Next",
color = "white"
),
panel.grid = element_blank(),
axis.ticks = element_blank()
)
)
})
</script>
<script type="application/shiny-prerendered" data-context="server-extras">
ojs_define <- function(..., .session = shiny::getDefaultReactiveDomain()) {
quos <- rlang::enquos(...)
vars <- rlang::list2(...)
nm <- names(vars)
if (is.null(nm)) {
nm <- rep_len("", length(vars))
}
mapply(function(q, nm, val) {
# Infer name, if possible
if (nm == "") {
tryCatch({
nm <- rlang::as_name(q)
}, error = function(e) {
code <- paste(collapse = "\n", deparse(rlang::f_rhs(q)))
stop("ojs_define() could not create a name for the argument: ", code)
})
}
.session$output[[nm]] <- val
outputOptions(.session$output, nm, suspendWhenHidden = FALSE)
.session$sendCustomMessage("ojs-export", list(name = nm))
NULL
}, quos, nm, vars, SIMPLIFY = FALSE, USE.NAMES = FALSE)
invisible()
}
</script>
</p>
<!--html_preserve-->
<script type="application/shiny-prerendered" data-context="dependencies">
{"type":"list","attributes":{},"value":[{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["ionrangeslider-javascript"]},{"type":"character","attributes":{},"value":["2.3.1"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["www/shared/ionrangeslider"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["js/ion.rangeSlider.min.js"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["shiny"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["1.9.1"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["strftime"]},{"type":"character","attributes":{},"value":["0.9.2"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["www/shared/strftime"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["strftime-min.js"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["shiny"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["1.9.1"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["ionrangeslider-css"]},{"type":"character","attributes":{},"value":["2.3.1"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["www/shared/ionrangeslider"]}]},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["css/ion.rangeSlider.css"]},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["shiny"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["1.9.1"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["htmltools-fill"]},{"type":"character","attributes":{},"value":["0.5.8.1"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["fill"]}]},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["fill.css"]},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["htmltools"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["0.5.8.1"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["ionrangeslider-javascript"]},{"type":"character","attributes":{},"value":["2.3.1"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["www/shared/ionrangeslider"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["js/ion.rangeSlider.min.js"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["shiny"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["1.9.1"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["strftime"]},{"type":"character","attributes":{},"value":["0.9.2"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["www/shared/strftime"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["strftime-min.js"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["shiny"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["1.9.1"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["ionrangeslider-css"]},{"type":"character","attributes":{},"value":["2.3.1"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["www/shared/ionrangeslider"]}]},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["css/ion.rangeSlider.css"]},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["shiny"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["1.9.1"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["ionrangeslider-javascript"]},{"type":"character","attributes":{},"value":["2.3.1"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["www/shared/ionrangeslider"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["js/ion.rangeSlider.min.js"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["shiny"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["1.9.1"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["strftime"]},{"type":"character","attributes":{},"value":["0.9.2"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["www/shared/strftime"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["strftime-min.js"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["shiny"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["1.9.1"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["ionrangeslider-css"]},{"type":"character","attributes":{},"value":["2.3.1"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["www/shared/ionrangeslider"]}]},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["css/ion.rangeSlider.css"]},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["shiny"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["1.9.1"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["htmltools-fill"]},{"type":"character","attributes":{},"value":["0.5.8.1"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["fill"]}]},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["fill.css"]},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["htmltools"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["0.5.8.1"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["htmlwidgets"]},{"type":"character","attributes":{},"value":["1.6.4"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["www"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["htmlwidgets.js"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["htmlwidgets"]},{"type":"logical","attributes":{},"value":[true]},{"type":"character","attributes":{},"value":["1.6.4"]}]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["name","version","src","meta","script","stylesheet","head","attachment","package","all_files","pkgVersion"]},"class":{"type":"character","attributes":{},"value":["html_dependency"]}},"value":[{"type":"character","attributes":{},"value":["plotly-binding"]},{"type":"character","attributes":{},"value":["4.10.4"]},{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["file"]}},"value":[{"type":"character","attributes":{},"value":["htmlwidgets"]}]},{"type":"NULL"},{"type":"character","attributes":{},"value":["plotly.js"]},{"type":"NULL"},{"type":"NULL"},{"type":"NULL"},{"type":"character","attributes":{},"value":["plotly"]},{"type":"logical","attributes":{},"value":[false]},{"type":"character","attributes":{},"value":["4.10.4"]}]}]}
</script>
<!--/html_preserve-->
<!--html_preserve-->
<script type="application/shiny-prerendered" data-context="execution_dependencies">
{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["packages"]}},"value":[{"type":"list","attributes":{"names":{"type":"character","attributes":{},"value":["packages","version"]},"class":{"type":"character","attributes":{},"value":["data.frame"]},"row.names":{"type":"integer","attributes":{},"value":[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]}},"value":[{"type":"character","attributes":{},"value":["base","bslib","cachem","cli","colorspace","compiler","data.table","datasets","digest","dplyr","evaluate","fansi","farver","fastmap","forcats","generics","ggplot2","glue","graphics","grDevices","grid","gtable","hms","htmltools","htmlwidgets","httpuv","httr","jquerylib","jsonlite","knitr","labeling","later","lazyeval","lifecycle","lubridate","magrittr","memoise","methods","mime","munsell","pillar","pkgconfig","plotly","promises","purrr","R6","Rcpp","readr","rlang","rmarkdown","rstudioapi","sass","scales","shiny","stats","stringi","stringr","tibble","tidyr","tidyselect","tidyverse","timechange","tools","tzdb","utf8","utils","vctrs","viridisLite","withr","xfun","xtable","yaml"]},{"type":"character","attributes":{},"value":["4.4.1","0.8.0","1.1.0","3.6.3","2.1-1","4.4.1","1.16.0","4.4.1","0.6.37","1.1.4","1.0.1","1.0.6","2.1.2","1.2.0","1.0.0","0.1.3","3.5.1","1.8.0","4.4.1","4.4.1","4.4.1","0.3.6","1.1.3","0.5.8.1","1.6.4","1.6.15","1.4.7","0.1.4","1.8.9","1.48","0.4.3","1.3.2","0.2.2","1.0.4","1.9.3","2.0.3","2.0.1","4.4.1","0.12","0.5.1","1.9.0","2.0.3","4.10.4","1.3.0","1.0.2","2.5.1","1.0.13-1","2.1.5","1.1.4","2.29","0.16.0","0.4.9","1.3.0","1.9.1","4.4.1","1.8.4","1.5.1","3.2.1","1.3.1","1.2.1","2.0.0","0.3.0","4.4.1","0.4.0","1.2.4","4.4.1","0.6.5","0.4.2","3.0.2","0.48","1.8-4","2.3.10"]}]}]}
</script>
<!--/html_preserve-->
</section>
</div>
<div class="quarto-auto-generated-content" style="display: none;">
<div class="footer footer-default">
</div>
</div></div>
<script>window.backupDefine = window.define; window.define = undefined;</script>
<script src="shiny_files/libs/revealjs/dist/reveal.js"></script>
<!-- reveal.js plugins -->
<script src="shiny_files/libs/revealjs/plugin/quarto-line-highlight/line-highlight.js"></script>
<script src="shiny_files/libs/revealjs/plugin/pdf-export/pdfexport.js"></script>
<script src="shiny_files/libs/revealjs/plugin/reveal-menu/menu.js"></script>
<script src="shiny_files/libs/revealjs/plugin/reveal-menu/quarto-menu.js"></script>
<script src="shiny_files/libs/revealjs/plugin/quarto-support/support.js"></script>
<script src="shiny_files/libs/revealjs/plugin/notes/notes.js"></script>
<script src="shiny_files/libs/revealjs/plugin/search/search.js"></script>
<script src="shiny_files/libs/revealjs/plugin/zoom/zoom.js"></script>
<script src="shiny_files/libs/revealjs/plugin/math/math.js"></script>
<script>window.define = window.backupDefine; window.backupDefine = undefined;</script>
<script>
// Full list of configuration options available at:
// https://revealjs.com/config/
Reveal.initialize({
'controlsAuto': true,
'previewLinksAuto': false,
'pdfSeparateFragments': false,
'autoAnimateEasing': "ease",
'autoAnimateDuration': 1,
'autoAnimateUnmatched': true,
'jumpToSlide': true,
'menu': {"side":"left","useTextContentForMissingTitles":true,"markers":false,"loadIcons":false,"custom":[{"title":"Tools","icon":"<i class=\"fas fa-gear\"></i>","content":"<ul class=\"slide-menu-items\">\n<li class=\"slide-tool-item active\" data-item=\"0\"><a href=\"#\" onclick=\"RevealMenuToolHandlers.fullscreen(event)\"><kbd>f</kbd> Fullscreen</a></li>\n<li class=\"slide-tool-item\" data-item=\"1\"><a href=\"#\" onclick=\"RevealMenuToolHandlers.speakerMode(event)\"><kbd>s</kbd> Speaker View</a></li>\n<li class=\"slide-tool-item\" data-item=\"2\"><a href=\"#\" onclick=\"RevealMenuToolHandlers.overview(event)\"><kbd>o</kbd> Slide Overview</a></li>\n<li class=\"slide-tool-item\" data-item=\"3\"><a href=\"#\" onclick=\"RevealMenuToolHandlers.togglePdfExport(event)\"><kbd>e</kbd> PDF Export Mode</a></li>\n<li class=\"slide-tool-item\" data-item=\"4\"><a href=\"#\" onclick=\"RevealMenuToolHandlers.toggleScrollView(event)\"><kbd>r</kbd> Scroll View Mode</a></li>\n<li class=\"slide-tool-item\" data-item=\"5\"><a href=\"#\" onclick=\"RevealMenuToolHandlers.keyboardHelp(event)\"><kbd>?</kbd> Keyboard Help</a></li>\n</ul>"}],"openButton":true},
'smaller': false,
// Display controls in the bottom right corner
controls: false,
// Help the user learn the controls by providing hints, for example by
// bouncing the down arrow when they first encounter a vertical slide
controlsTutorial: false,
// Determines where controls appear, "edges" or "bottom-right"
controlsLayout: 'edges',
// Visibility rule for backwards navigation arrows; "faded", "hidden"
// or "visible"
controlsBackArrows: 'faded',
// Display a presentation progress bar
progress: true,
// Display the page number of the current slide
slideNumber: false,
// 'all', 'print', or 'speaker'
showSlideNumber: 'all',
// Add the current slide number to the URL hash so that reloading the
// page/copying the URL will return you to the same slide
hash: true,
// Start with 1 for the hash rather than 0
hashOneBasedIndex: false,
// Flags if we should monitor the hash and change slides accordingly
respondToHashChanges: true,
// Push each slide change to the browser history
history: true,
// Enable keyboard shortcuts for navigation
keyboard: true,
// Enable the slide overview mode
overview: true,
// Disables the default reveal.js slide layout (scaling and centering)
// so that you can use custom CSS layout
disableLayout: false,
// Vertical centering of slides
center: false,
// Enables touch navigation on devices with touch input
touch: true,
// Loop the presentation
loop: false,
// Change the presentation direction to be RTL
rtl: false,
// see https://revealjs.com/vertical-slides/#navigation-mode
navigationMode: 'linear',
// Randomizes the order of slides each time the presentation loads
shuffle: false,
// Turns fragments on and off globally
fragments: true,
// Flags whether to include the current fragment in the URL,
// so that reloading brings you to the same fragment position
fragmentInURL: false,
// Flags if the presentation is running in an embedded mode,
// i.e. contained within a limited portion of the screen
embedded: false,
// Flags if we should show a help overlay when the questionmark
// key is pressed
help: true,
// Flags if it should be possible to pause the presentation (blackout)
pause: true,
// Flags if speaker notes should be visible to all viewers
showNotes: false,
// Global override for autoplaying embedded media (null/true/false)
autoPlayMedia: null,
// Global override for preloading lazy-loaded iframes (null/true/false)
preloadIframes: null,
// Number of milliseconds between automatically proceeding to the
// next slide, disabled when set to 0, this value can be overwritten
// by using a data-autoslide attribute on your slides
autoSlide: 0,
// Stop auto-sliding after user input
autoSlideStoppable: true,
// Use this method for navigation when auto-sliding
autoSlideMethod: null,
// Specify the average time in seconds that you think you will spend
// presenting each slide. This is used to show a pacing timer in the
// speaker view
defaultTiming: null,
// Enable slide navigation via mouse wheel
mouseWheel: false,
// The display mode that will be used to show slides
display: 'block',
// Hide cursor if inactive
hideInactiveCursor: true,
// Time before the cursor is hidden (in ms)
hideCursorTime: 5000,
// Opens links in an iframe preview overlay
previewLinks: false,
// Transition style (none/fade/slide/convex/concave/zoom)
transition: 'none',