-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.qmd
More file actions
1583 lines (1073 loc) · 51 KB
/
Copy pathindex.qmd
File metadata and controls
1583 lines (1073 loc) · 51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
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
---
format:
revealjs:
slide-number: true
# preview-links: true
# code-link: true
highlight-style: a11y
chalkboard: true
# self-contained: true
# scrollable: true
theme:
- meds-slides-styles.scss
engine: knitr
execute:
eval: true
---
## {#title-slide data-menu-title="Title Slide" background="#053660"}
```{r}
#| eval: true
#| echo: false
today <- format(Sys.time(), "%b %d, %Y")
```
[Teach Me How to Google]{.custom-title}
[*The case for debugging & search skills in the age of AI + tips on how to do so effectively*]{.custom-subtitle2}
:::: {.columns}
::: {.column width="50%"}
[**Published:** October 11, 2021]{.body-text-s .baby-blue-text}
:::
::: {.column width="50%"}
[**Last updated:** `r today`]{.body-text-s .baby-blue-text}
:::
::::
<hr class="hr-teal">
:::: {.columns}
::: {.column width="50%"}
[Sam Shanny-Csik |]{.custom-subtitle2}<br>
[*Lecturer & Data Training Coordinator*]{.custom-subtitle3}
:::
::: {.column width="50%"}
[Master of Environmental Data Science |]{.custom-subtitle2}<br>
[*Bren School of Environmental Science & Management*]{.custom-subtitle3}
:::
::::
<br>
::: {.title-footer}
Slides & source code available on [GitHub {{< fa brands github title="GitHub Octocat logo" >}}](https://github.com/UCSB-MEDS/teach-me-how-to-google){target="_blank"}
:::
---
## {#elephant data-menu-title="Elephant in the room"}
[Let's address the elephant in the room . . .]{.slide-title}
<hr>
:::: {.columns}
::: {.column width="50%"}
```{r}
#| eval: true
#| echo: false
#| out-width: "100%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "elephant.png"))
```
::: {.center-text .body-text-s .gray-text}
Image source: [Wikipedia](https://en.wikipedia.org/wiki/Elephant_in_the_room){target="_blank"}
:::
:::
::: {.column width="50%"}
<br>
<br>
- Generative AI tools (e.g. ChatGPT) are *everywhere* now (and maybe you're already using them!)
- Even Google provides an AI summery with each query
- Does it even pay to "Google," in the traditional sense, anymore?
:::
::::
. . .
::: {.center-text .body-text-l}
**We argue, YES!**
:::
<!-- ---
I asked ChatGPT what it would tell new data science students about the importance and utility of using Google vs. ChatGPT (or related GenAI tools) in the early stages of a learning journey. It's response:
"Think of Google as your first stop for researching and understanding the problem, and GenAI as a helpful assistant for brainstorming or clarifying once you know what you’re asking." -->
---
## {#MIT1 data-menu-title="MIT study 1"}
[Evidence suggests that overreliance on ChatGPT can erode critical thinking skills]{.slide-title2}
<hr>
:::: {.columns}
::: {.column width="40%"}
```{r}
#| eval: true
#| echo: false
#| out-width: "100%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "kosmyna-etal-2025.png"))
```
:::
::: {.column width="60%"}
[{{< fa robot title="robot head" >}} **Group 1:**]{.teal-text} could use ChatGPT
<br>
[{{< fa brands google title="Google G" >}} **Group 2:**]{.teal-text} could use Google
<br>
[{{< fa brain title="brain" >}} **Group 3:**]{.teal-text} only their brains!
:::
::::
::: {.footer}
[Kosmyna et al. 2025 (Preprint)](https://arxiv.org/pdf/2506.08872v1){target="_blank"} & [summary article by Time](https://time.com/7295195/ai-chatgpt-google-learning-school/){target="_blank"}
:::
---
## {#AI-group data-menu-title="AI Group"}
[Evidence suggests that overreliance on ChatGPT can erode critical thinking skills]{.slide-title2}
<hr>
:::: {.columns}
::: {.column width="40%"}
```{r}
#| eval: true
#| echo: false
#| out-width: "100%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "kosmyna-etal-2025.png"))
```
:::
::: {.column width="60%"}
[{{< fa robot title="robot head" >}} **Group 1:**]{.teal-text} could use ChatGPT
- [low brain engagement]{.body-text-s}
- ["souless," lacked originality]{.body-text-s}
- [copy / pasting by 3rd essay]{.body-text-s}
[{{< fa brands google title="Google G" >}} **Group 2:**]{.teal-text} could use Google
<br>
[{{< fa brain title="brain" >}} **Group 3:**]{.teal-text} only their brains!
:::
::::
::: {.footer}
[Kosmyna et al. 2025 (Preprint)](https://arxiv.org/pdf/2506.08872v1){target="_blank"} & [summary article by Time](https://time.com/7295195/ai-chatgpt-google-learning-school/){target="_blank"}
:::
---
## {#brain-group data-menu-title="Brain Group"}
[Evidence suggests that overreliance on ChatGPT can erode critical thinking skills]{.slide-title2}
<hr>
:::: {.columns}
::: {.column width="40%"}
```{r}
#| eval: true
#| echo: false
#| out-width: "100%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "kosmyna-etal-2025.png"))
```
:::
::: {.column width="60%"}
[{{< fa robot title="robot head" >}} **Group 1:**]{.teal-text} could use ChatGPT
- [low brain engagement]{.body-text-s}
- ["souless," lacked originality]{.body-text-s}
- [copy / pasting by 3rd essay]{.body-text-s}
[{{< fa brands google title="Google G" >}} **Group 2:**]{.teal-text} could use Google
<br>
[{{< fa brain title="brain" >}} **Group 3:**]{.teal-text} only their brains!
- [high neural connectivity]{.body-text-s}
- [engaged / curious]{.body-text-s}
- [claimed ownership & expressed higher satisfaction]{.body-text-s}
:::
::::
::: {.footer}
[Kosmyna et al. 2025 (Preprint)](https://arxiv.org/pdf/2506.08872v1){target="_blank"} & [summary article by Time](https://time.com/7295195/ai-chatgpt-google-learning-school/){target="_blank"}
:::
---
## {#google-group data-menu-title="Google Group"}
[Evidence suggests that overreliance on ChatGPT can erode critical thinking skills]{.slide-title2}
<hr>
:::: {.columns}
::: {.column width="40%"}
```{r}
#| eval: true
#| echo: false
#| out-width: "100%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "kosmyna-etal-2025.png"))
```
:::
::: {.column width="60%"}
[{{< fa robot title="robot head" >}} **Group 1:**]{.teal-text} could use ChatGPT
- [low brain engagement]{.body-text-s}
- ["souless," lacked originality]{.body-text-s}
- [copy / pasting by 3rd essay]{.body-text-s}
[{{< fa brands google title="Google G" >}} **Group 2:**]{.teal-text} could use Google
- [also high levels of brain activity and satisfaction!]{.body-text-s}
[{{< fa brain title="brain" >}} **Group 3:**]{.teal-text} only their brains!
- [high neural connectivity]{.body-text-s}
- [engaged / curious]{.body-text-s}
- [claimed ownership & expressed higher satisfaction]{.body-text-s}
:::
::::
::: {.footer}
[Kosmyna et al. 2025 (Preprint)](https://arxiv.org/pdf/2506.08872v1){target="_blank"} & [summary article by Time](https://time.com/7295195/ai-chatgpt-google-learning-school/){target="_blank"}
:::
::: {.notes}
"The brain-only group, conversely, showed the highest neural connectivity, especially in alpha, theta and delta bands, which are associated with creativity ideation, memory load, and semantic processing."
:::
---
## {#group-change data-menu-title="Group change"}
[Evidence suggests that overreliance on ChatGPT can erode critical thinking skills]{.slide-title2}
<hr>
<br>
[After 3 essays, everyone was asked to re-write one of their previous essays, [but [{{< fa robot title="robot head" >}} **Group 1**]{.teal-text} *could no longer use* ChatGPT,]{.fragment .fade-in} [while [{{< fa brands google title="Google G" >}} **Group 2**]{.teal-text} **&** [{{< fa brain title="brain" >}} **Group 3**]{.teal-text} *could now use* ChatGPT]{.fragment .fade-in}]{.body-text-m}
<br>
::: {.incremental}
- [{{< fa robot title="robot head" >}} **Group 1:**]{.teal-text} difficulty remembering, weaker alpha & theta brain waves (creative ideation & memory load); suggests that they **didn't integrate work into their memory networks**
<br>
- [{{< fa brands google title="Google G" >}} **Group 2:**]{.teal-text} performed well, significant increase in brain connectivity across all bands; suggests that **if used properly, AI can enhance learning as opposed to diminishing it**
:::
::: {.footer}
[Kosmyna et al. 2025 (Preprint)](https://arxiv.org/pdf/2506.08872v1){target="_blank"} & [summary article by Time](https://time.com/7295195/ai-chatgpt-google-learning-school/){target="_blank"}
:::
---
## {#paper-concolusion data-menu-title="Paper conclusion"}
<br>
<br>
<br>
>[*"The **LLM** undeniably **reduced the friction** involved in answering participants' questions compared to the Search Engine. However, this convenience **came at a cognitive cost**, diminishing users' inclination to critically evaluate the LLM's output or ”opinions” (probabilistic answers based on the training datasets). This highlights a concerning evolution of the **'echo chamber' effect**: rather than disappearing, it has adapted to **shape user exposure through algorithmically curated content**. What is ranked as “top” is ultimately influenced by the priorities of the LLM's shareholders."*]{.body-text-m}
::: {.footer}
[Kosmyna et al. 2025 (Preprint)](https://arxiv.org/pdf/2506.08872v1){target="_blank"}
:::
---
## {#lee-etal-2025 data-menu-title="Lee et al. 2025"}
[Other motivating findings]{.slide-title}
<hr>
>[*"Moreover, while GenAI can improve worker efficiency, it **can inhibit critical engagement with work and can potentially lead to long-term overreliance on the tool and diminished skill for independent problem-solving**. **Higher confidence in GenAI’s ability to perform a task is related to less critical thinking effort.** When using GenAI tools, the **effort invested in critical thinking shifts from information gathering to information verification; from problem-solving to AI response integration; and from task execution to task stewardship.** Knowledge workers face new challenges in critical thinking as they incorporate GenAI into their knowledge workflows."*]{.body-text-m}
::: {.footer}
[Lee et al. 2025 (Proceedings of the 2025 CHI conference on human factors in computing systems)](https://dl.acm.org/doi/pdf/10.1145/3706598.3713778){target="_blank"}
:::
---
## {#lehmann-etal-2025 data-menu-title="Lehmann et al. 2025"}
[Other motivating findings]{.slide-title}
<hr>
<br>
>[*"Students who substitute some of their learning activities with LLMs (e.g., by generating solutions to exercises) increase the volume of topics they can learn about but decrease their understanding of each topic. Students who complement their learning activities with LLMs (e.g., by asking for explanations) do not increase topic volume but do increase their understanding. We also observe that **LLMs widen the gap between students with low and high prior knowledge**."*]{.body-text-m}
::: {.footer}
[Lehmann et al. 2025](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4941259){target="_blank"}
:::
---
## {#heiss-analogy data-menu-title="Lehmann et al. 2025"}
[And one final good analogy]{.slide-title}
<hr>
<br>
>[*"**Using LLMs requires a good baseline knowledge** of R [or other languages] to actually be useful. A good analogy for this is with recipes. ChatGPT is really confident at spitting out plausible-looking recipes. A few months ago, for fun, I asked it to give me a cookie recipe. I got back something with flour, eggs, sugar, and all other standard-looking ingredients, but it also said to include 3/4 cup of baking powder. **That’s wild and obviously wrong, but I only knew that because I’ve made cookies before.**"*]{.body-text-m}
::: {.footer}
From [Andrew Heiss](https://www.andrewheiss.com/){target="_blank"}'s course [guidelines on AI use](https://datavizs25.classes.andrewheiss.com/resource/ai-bs.html#ref-LehmannCorneliusSting:2025){target="_blank"}.
:::
---
## {#meds-calendar data-menu-title="MEDS calendar"}
[GenAI in the MEDS calendar]{.slide-title}
<hr>
| Term | Incorporation of GenAI |
|--------|-----------------------------------------------------------------------------------------------|
| SUMMER | **Establish context**<br>Student use is discourage |
| FALL | **Critical interrogation**<br>Instructors demonstrate examples of use and discuss pros / cons |
| WINTER | **Guided Use**<br>Workshops early in quarter<br>Instructors model use |
| SPRING | **Supported Use**<br>Instructors model use |
<br>
. . .
**You're here because you want to learn!** ChatGPT (and related tools) will certainly become a part of your workflow[, but in this early stage of MEDS, we want you to **focus on core competencies and critical thinking skills**, including an understanding of how to properly use tools, design workflows, write and organize code, and troubleshoot problems.]{.fragment .fade-in}
. . .
***To do that most effectively, you need to commit to active learning processes and approaches.***
---
## {#welcome data-menu-title="Welcome"}
[Welcome to data science, where questions are aplenty!]{.slide-title2}
<hr>
:::: {.columns}
::: {.column width="50%"}
<br>
- You will become increasingly more comfortable with **not immediately knowing** the answers to all your coding problems (*even* when using GenAI tools). It's all part of the job.
<br>
- Googling can be difficult, and it is a **skill** that **requries practice**. But you can and will get better at it over time.
:::
::: {.column width="50%"}
```{r}
#| eval: true
#| echo: false
#| out-width: "80%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "questions.gif"))
```
::: {.center-text .body-text-s .gray-text}
-Me, everytime I sit down to program
:::
:::
::::
---
## {#frustration data-menu-title="Frustration"}
[It doesn't mean you won't still feel like this at times:]{.slide-title2}
<hr>
```{r}
#| eval: true
#| echo: false
#| out-width: "100%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "ron_swanson.gif"))
```
::: {.center-text .body-text-s .gray-text}
-Me still, about half the times I sit down to program
:::
---
## {#goal data-menu-title="Goal"}
[But the goal is to be a bit more at peace with that feeling...and have the confidence that you can find your way]{.slide-title3}
<hr>
```{r}
#| eval: true
#| echo: false
#| out-width: "100%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "how_much_i_know.jpeg"))
```
::: {.center-text .body-text-s .gray-text}
Artwork by [Allison Horst](https://allisonhorst.com/){target="_blank"}
:::
---
## {#when-to-google data-menu-title="When to Google"}
[I typically find myself turning to Google because:]{.slide-title2}
<hr>
<br>
[[{{< fa exclamation-triangle title="an exclamation point in a triangle">}}]{.teal-text} I got an error and need help fixing it]{.body-text-m}
<br>
[[{{< fa question-circle title="a question mark in a circle">}}]{.teal-text} I know what I want my code to do, but I have no idea how to actually pull it off]{.body-text-m}
<br>
. . .
[[{{< fa flushed title="a flushed face with wide eyes">}}]{.teal-text} Sometimes, it's both of these things happening at the same time]{.body-text-m}
<!-- ---
## {#use-sass data-menu-title="## Use Sass ##" background="#053660"}
<div class="vertical-center">
<div class="custom-subtitle center-text">{{< fa exclamation-triangle title="an exclamation point in a triangle">}} I got an error and need help fixing it</div>
</div> -->
---
## {#lentgh data-menu-title="Lentgh"}
[We've all been here before:]{.slide-title}
<hr>
```{r}
#| eval: true
#| echo: false
#| out-width: "100%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "alligator.png"))
```
::: {.center-text .body-text-s .gray-text}
Artwork by [Allison Horst](https://allisonhorst.com/){target="_blank"}
:::
---
## {#narrow-down data-menu-title="Narrow down"}
[Pause, exhale, narrow down your potential Google search]{.slide-title2}
<hr>
. . .
[[{{< fa power-off title="power button" >}}]{.teal-text} Restart R]{.body-text-m}
. . .
<br>
[[{{< fa lightbulb title="lightbulb" >}}]{.teal-text} Check the easy stuff]{.body-text-m}
. . .
<br>
[[{{< fa exclamation-triangle title="exclamation point in a triangle" >}}]{.teal-text} Read that error message]{.body-text-m}
. . .
<br>
[[{{< fa magnifying-glass title="magnifying glass" >}}]{.teal-text} Try to islate the problem]{.body-text-m}
. . .
<br>
[[{{< fa file-alt title="a file" >}}]{.teal-text} Double-check the documentation]{.body-text-m}
. . .
<br>
[[{{< fa people-arrows title="two people with an arrow pointing to each of them" >}}]{.teal-text} Talk about it out loud]{.body-text-m}
---
## {#restart-r data-menu-title="Restart R"}
[{{< fa power-off title="power button" >}} Restart R]{.slide-title}
<hr>
>*"Restart R often, especially when things get weird...We install and update packages from R, which is a little bit like working on your airplane engine while you're flying."*
::: {.right-align-text .gray-text .body-text-s}
-Jenny Bryan, in her 2020 rstudio::conf keynote, [Object of type ‘closure’ is not subsettable](https://posit.co/resources/videos/object-of-type-closure-is-not-subsettable/){target="_blank"}
:::
<br>
. . .
Similarly, going to sleep and trying again tomorrow is a legitimate (and often impactful) strategy -- think of it as restarting your own internal computer (i.e. your brain).
```{r}
#| eval: true
#| echo: false
#| out-width: "60%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "tweet-kvaughn.png"))
```
---
## {#check-easy-stuff data-menu-title="Check the easy stuff"}
[{{< fa lightbulb title="lightbulb" >}} Check the easy stuff]{.slide-title}
<hr>
```{r}
#| eval: true
#| echo: false
#| out-width: "60%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "debug_bingo.png"))
```
::: {.footer}
Source: This [tweet](https://x.com/cogscimom/status/1354508785365078016?ref_src=twsrc%5Etfw){target="_blank"} by @cogscimom
:::
---
## {#error-message-helpful1 data-menu-title="Error message (helpful 1)"}
[{{< fa exclamation-triangle title="exclamation point in a triangle" >}} Read that error message]{.slide-title}
<hr>
```{r}
#| eval: true
#| echo: true
# load packages ----
library(tidyverse) # a collection of data wrangling & visualization packages
library(palmerpenguins) # contains the 'penguins' data set
# print out the first three rows of the penguins data frame ----
head(penguins, 3)
```
<br>
. . .
```{r}
#| eval: true
#| echo: true
# what unique values are in the species column of the penguins data frame? ----
unique(penguins$species)
```
---
## {#error-message-helpful2 data-menu-title="Error message (helpful 2)"}
[{{< fa exclamation-triangle title="exclamation point in a triangle" >}} Read that error message]{.slide-title}
<hr>
```{r}
#| eval: true
#| echo: true
#| error: true
# create a new data frame with just rows (observations) containing "Gentoo" penguins ----
gentoo <- penguins |>
filter(species = "Gentoo")
```
<br>
::: {.center-text .body-text-m}
**Returns a helpful error message with a potential fix!**
:::
---
## {#error-message-unhelpful data-menu-title="Error message (unhelpful)"}
[{{< fa exclamation-triangle title="exclamation point in a triangle" >}} Read that error message]{.slide-title}
<hr>
```{r}
#| eval: true
#| echo: true
# create data object, named 'dat' ----
dat <- data.frame(x = 1, y = 2)
dat
```
<br>
. . .
```{r}
#| eval: true
#| echo: true
#| error: true
# extract column 'x' from your data object (oops, we forgot we named it 'dat' and not 'df') ----
df$x
```
. . .
<br>
>*"Your first “object of type ‘closure’ is not subsettable” error message is a big milestone for an R user. Congratulations, if there was any lingering doubt, you now know that you are officially programming!"*
::: {.right-align-text .gray-text .body-text-s}
-Jenny Bryan, in her 2020 rstudio::conf keynote, [Object of type ‘closure’ is not subsettable](https://posit.co/resources/videos/object-of-type-closure-is-not-subsettable/){target="_blank"}
:::
::: {.body-text-xs .center-text}
This error often arises when you attempt to subset a function (i.e. treat a function in a way that it is shouldn't be; a "closure" is a type of function in R). Here, we forgot that we called called our object `dat`, and not `df`. `df()` also happens to be a function that gives you the density of the 'F' distribution and we are attempting to subset (i.e. extract) a column (`x`) from it.
:::
---
## {#error-message-resources data-menu-title="Error message (resources)"}
[{{< fa exclamation-triangle title="exclamation point in a triangle" >}} Read that error message]{.slide-title}
<hr>
::: {.center-text .body-text-m}
**Error messages provide helpful context and information, even if they seem unhelpful on the surface!**
:::
<br>
:::: {.columns}
::: {.column width="50%"}
You'll become more familiar with common error messages the more time you spend coding, but it can be helpful to explore some resources for deciphering the big ones:
- [Common R Error Messages](https://www.programmingr.com/r-error-messages/){target="_blank"}
- [Common R Programming Errors Faced by Beginners](https://www.r-bloggers.com/2016/06/common-r-programming-errors-faced-by-beginners/){target="_blank"}
- [How to: Interpret Common Errors in R](https://warin.ca/posts/rcourse-howto-interpretcommonerrors/){target="_blank"}
- [R Error Message Cheat Sheet](http://varianceexplained.org/courses/errors/){target="_blank"}
:::
::: {.column width="50%"}
```{r}
#| eval: true
#| echo: false
#| out-width: "100%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "horst-error-teaching.png"))
```
::: {.center-text .body-text-s .gray-text}
Artwork by [Allison Horst](https://allisonhorst.com/){target="_blank"}
:::
:::
::::
---
## {#isolate-problem1 data-menu-title="Isolate the problem 1"}
[{{< fa magnifying-glass title="magnifying glass" >}} Try to isolate the problem]{.slide-title}
<hr>
It can be overwhelming to figure out where an error or issue is occurring in a large chunk of code. A small example:
```{r}
#| eval: true
#| echo: true
#| error: true
# load libraries ----
library(dplyr)
library(palmerpenguins)
# wrangle data ----
penguins_new <- penguins |>
select(species, sex, bill_length_mm) |>
filter(species == "Adelie") |>
reorder(bill_length_mm)
```
. . .
<br>
**Running all lines together can make it difficult which line(s) is responsible for this error** (and imagine dealing with much longer, more complex code chunks!).
. . .
<br>
**Instead, run line-by-line to isolate where the problem is occurring** so that you can begin investigating from there.
---
## {#isolate-problem2 data-menu-title="Isolate the problem 2"}
[{{< fa magnifying-glass title="magnifying glass" >}} Try to isolate the problem]{.slide-title}
<hr>
Run line-by-line until you hit the error:
```{r}
#| eval: true
#| echo: true
penguins_new <- penguins |>
select(species, sex, bill_length_mm) # |>
# filter(species == "Adelie") |>
# reorder(bill_length_mm)
```
**Works!**
. . .
```{r}
#| eval: true
#| echo: true
penguins_new <- penguins |>
select(species, sex, bill_length_mm) |>
filter(species == "Adelie") # |>
# reorder(bill_length_mm)
```
**Works!**
. . .
```{r}
#| eval: true
#| echo: true
#| error: true
penguins_new <- penguins |>
select(species, sex, bill_length_mm) |>
filter(species == "Adelie") |>
reorder(bill_length_mm)
```
**Doesn't work... let's look into what `reorder()` is / does...**
<!-- ::: {.footer}
**Tip:** comment / uncomment lines of code using the keyboard shortcut `Cmd` / `Ctrl` + `shift` + `C`
::: -->
---
## {#isolate-problem3 data-menu-title="Isolate the problem 3"}
[{{< fa magnifying-glass title="magnifying glass" >}} Try to isolate the problem]{.slide-title}
<hr>
Searching for `reorder()` (either by looking up documentation -- more on that in a moment -- or Googling it) reveals that **it's not actually a function** {{< fa face-grin-beam-sweat title="a grinning face with a sweat droplet" >}}
. . .
Googling, "[R tidyverse reorder values high to low](https://www.google.com/search?q=R+tidyverse+reorder+values+high+to+low&sca_esv=558984878&ei=KlPkZOzoK8TFkPIPqf2ikAI&ved=0ahUKEwjspZqwz--AAxXEIkQIHam-CCIQ4dUDCBA&uact=5&oq=R+tidyverse+reorder+values+high+to+low&gs_lp=Egxnd3Mtd2l6LXNlcnAiJlIgdGlkeXZlcnNlIHJlb3JkZXIgdmFsdWVzIGhpZ2ggdG8gbG93MgUQIRigATIFECEYoAEyBRAhGKsCSJ4fUPECWJ4dcAF4AJABAJgBqwGgAdAOqgEENC4xMrgBA8gBAPgBAcICChAAGEcY1gQYsAPCAgUQABiiBOIDBBgAIEGIBgGQBgg&sclient=gws-wiz-serp){target="_blank"}," leads us to the [`{dplyr}` documentation](https://dplyr.tidyverse.org/reference/arrange.html){target="_blank"} for the `arrange()` function, which allows us to sort values in descending order when coupled with `desc()`:
```{r}
#| eval: true
#| echo: true
penguins_new <- penguins |>
select(species, sex, bill_length_mm) |>
filter(species == "Adelie") |>
arrange(desc(bill_length_mm))
head(penguins_new, 4)
```
::: {.footer}
**It can be easy to confuse or mistake function names, particularly as you're just starting to learn a langauge or new packages** (e.g. `forcats::fct_reorder()` is used to reorder *factor* levels, but here, we're looking to reorder *numeric values* in the `bill_length_mm` column).
:::
---
## {#read-documentation1 data-menu-title="Double-check documentation 1"}
[{{< fa file-alt title="a file" >}} Double-check the documentation]{.slide-title}
<hr>
**Documentation provides *critical* info for understanding how to correctly use a package or function**
:::: {.columns}
::: {.column width="50%"}
- written by the people who actually developed the tools you're using
- describes inputs, outputs, how a function can be modified to acheive a particular outcome
- demonstrates standards
- often includes reproducible examples
**Pull up documentation for a loaded function by typing `?function_name` in your console. E.g.**
```{r}
#| eval: false
#| echo: true
#| code-line-numbers: false
?dplyr::filter
```
:::
::: {.column width="50%"}
```{r}
#| eval: true
#| echo: false
#| out-width: "100%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "filter-doc.png"))
```
:::
::::
. . .
::: {.center-text}
*Open up RStudio and practice pulling up the documentation for `filter()`*
:::
---
## {#read-documentation2 data-menu-title="Double-check documentation 2"}
[{{< fa file-alt title="a file" >}} Double-check the documentation]{.slide-title}
<hr>
<br>
[**With the person(s) next to you, explore the documentation and consider the following (and be prepared to share out):**]{.body-text-m}
- What is the `filter()` function used for? Where did you locate this information?
- What do the `.data` and `...` arguments do? How easy or difficult of a time did you have understanding the descriptions?
- Try running a few of the Examples in your console. How do these help (or not help) you better understand how the `filter()` function works?
```{r}
countdown::countdown(
minutes = 4,
# left = 0, right = 0,
# Fanfare when it's over
play_sound = TRUE,
color_border = "#FFFFFF",
color_text = "#7aa81e",
color_running_background = "#7aa81e",
color_running_text = "#FFFFFF",
color_finished_background = "#ffa07a",
color_finished_text = "#FFFFFF",
font_size = "2em",
)
```
---
## {#read-documentation3 data-menu-title="Double-check documentation 3"}
[{{< fa file-alt title="a file" >}} Double-check the documentation]{.slide-title}
<hr>
**Vignettes are long-form guides / tutorials for R packages.** These can offer helpful (and often less jargony) examples and explanations for how to use various functions. Check for a vignette by typing `vignette("package_name")` in your console. E.g. if we want to learn more about how to use `filter()`, which comes from the `{dplyr}` package:
```{r}
#| eval: false
#| echo: true
#| code-line-numbers: false
vignette("dplyr")
```
:::: {.columns}
::: {.column width="50%"}
```{r}
#| eval: true
#| echo: false
#| out-width: "80%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "dplyr-vignette.png"))
```
:::
::: {.column width="50%"}
```{r}
#| eval: true
#| echo: false
#| out-width: "80%"
#| fig-align: "center"
knitr::include_graphics(here::here("images", "filter-vignette.png"))
```
:::
::::
::: {.footer}
Not all packages will have a vignette. Vignettes do exist for some Python libraries as well.
:::
<!-- ---
## {#read-documentation4 data-menu-title="Double-check documentation 4"}
[{{< fa file-alt title="a file" >}} Double-check the documentation]{.slide-title}
<hr>
<br> -->
<!-- **Why is reading documentation so important (rather than just asking AI to fix your problem)?**
- It's the single most accurate source of truth
- You will rarely use a single function in isolation -- more often stringing together numerous functions to achieve a larger tast -- but you need to know how individual pieces work before you can effectively get all pieces working with one another
- GenAI tends to provide easy / fast approaches or fixes, but these can lead to difficulties in scaling or a lack of nuanced understanding (in addition to potentially being wrong!)
<br>
. . .
**Read documentation first > seek clarification using videos / tutorials / GenAI (later in the academic year {{< fa face-smile-wink title="a winking smiling face">}}) second.** -->
---
## {#talk-out-loud1 data-menu-title="Talk out loud 1"}
[{{< fa people-arrows title="two people with an arrow pointing to each of them" >}} Talk about it out loud]{.slide-title}