diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/anchor-4.2.2/anchor.min.js b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/anchor-4.2.2/anchor.min.js similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/anchor-4.2.2/anchor.min.js rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/anchor-4.2.2/anchor.min.js diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/bowser-1.9.3/bowser.min.js b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/bowser-1.9.3/bowser.min.js similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/bowser-1.9.3/bowser.min.js rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/bowser-1.9.3/bowser.min.js diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/distill-2.2.21/template.v2.js b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/distill-2.2.21/template.v2.js similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/distill-2.2.21/template.v2.js rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/distill-2.2.21/template.v2.js diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/header-attrs-2.14/header-attrs.js b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/header-attrs-2.14/header-attrs.js similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/header-attrs-2.14/header-attrs.js rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/header-attrs-2.14/header-attrs.js diff --git a/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/header-attrs-2.25/header-attrs.js b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/header-attrs-2.25/header-attrs.js new file mode 100644 index 0000000..dd57d92 --- /dev/null +++ b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/header-attrs-2.25/header-attrs.js @@ -0,0 +1,12 @@ +// Pandoc 2.9 adds attributes on both header and div. We remove the former (to +// be compatible with the behavior of Pandoc < 2.8). +document.addEventListener('DOMContentLoaded', function(e) { + var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); + var i, h, a; + for (i = 0; i < hs.length; i++) { + h = hs[i]; + if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 + a = h.attributes; + while (a.length > 0) h.removeAttribute(a[0].name); + } +}); diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/jquery-3.6.0/jquery-3.6.0.js b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/jquery-3.6.0/jquery-3.6.0.js similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/jquery-3.6.0/jquery-3.6.0.js rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/jquery-3.6.0/jquery-3.6.0.js diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/jquery-3.6.0/jquery-3.6.0.min.js b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/jquery-3.6.0/jquery-3.6.0.min.js similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/jquery-3.6.0/jquery-3.6.0.min.js rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/jquery-3.6.0/jquery-3.6.0.min.js diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/jquery-3.6.0/jquery-3.6.0.min.map b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/jquery-3.6.0/jquery-3.6.0.min.map similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/jquery-3.6.0/jquery-3.6.0.min.map rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/jquery-3.6.0/jquery-3.6.0.min.map diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/popper-2.6.0/popper.min.js b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/popper-2.6.0/popper.min.js similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/popper-2.6.0/popper.min.js rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/popper-2.6.0/popper.min.js diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy-bundle.umd.min.js b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy-bundle.umd.min.js similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy-bundle.umd.min.js rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy-bundle.umd.min.js diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy-light-border.css b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy-light-border.css similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy-light-border.css rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy-light-border.css diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy.css b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy.css similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy.css rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy.css diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy.umd.min.js b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy.umd.min.js similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy.umd.min.js rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/tippy-6.2.7/tippy.umd.min.js diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/webcomponents-2.0.0/webcomponents.js b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/webcomponents-2.0.0/webcomponents.js similarity index 100% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3_files/webcomponents-2.0.0/webcomponents.js rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class3_files/webcomponents-2.0.0/webcomponents.js diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3.Rmd b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class4.Rmd similarity index 99% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3.Rmd rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class4.Rmd index ee6be32..2fb2da3 100644 --- a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3.Rmd +++ b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class4.Rmd @@ -1,5 +1,5 @@ --- -title: "Class 3: Reshaping data into a tidy format" +title: "Class 4: Reshaping data into a tidy format" author: - name: "Kent Riemondy" url: https://github.com/kriemo diff --git a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3.html b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class4.html similarity index 91% rename from _posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3.html rename to _posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class4.html index 43d0ef5..090fcc2 100644 --- a/_posts/2022-11-15-class-3-reshaping-data-into-a-tidy-format/class3.html +++ b/_posts/2023-12-01-class-4-reshaping-data-into-a-tidy-format/class4.html @@ -88,34 +88,34 @@ -
The wide matrix-like format is very useful and a common format used for statistics and machine learning. Matrices can take advantage of optimized numerical routines and are the data representation of mathematical matrices. We will work with matrices later in class, particularly with their use to generate heatmaps.
Representing data in a matrix has a few practical implications:
@@ -1576,7 +1602,7 @@The long format of this data simplifies the many columns of a matrix into a 3 column data.frame containing 3 variables (country
, year
, and gdp
).
# A tibble: 6 × 4
country year cases population
- <chr> <int> <int> <int>
+ <chr> <dbl> <dbl> <dbl>
1 Afghanistan 1999 745 19987071
2 Afghanistan 2000 2666 20595360
3 Brazil 1999 37737 172006362
@@ -1627,7 +1653,7 @@ Tidy data format
# A tibble: 3 × 3
country `1999` `2000`
-* <chr> <int> <int>
+ <chr> <dbl> <dbl>
1 Afghanistan 745 2666
2 Brazil 37737 80488
3 China 212258 213766
@@ -1639,7 +1665,7 @@ Tidy data format
# A tibble: 3 × 3
country `1999` `2000`
-* <chr> <int> <int>
+ <chr> <dbl> <dbl>
1 Afghanistan 19987071 20595360
2 Brazil 172006362 174504898
3 China 1272915272 1280428583
@@ -1687,7 +1713,7 @@ Reshaping wide data to long
# A tibble: 6 × 3
country name value
- <chr> <chr> <int>
+ <chr> <chr> <dbl>
1 Afghanistan 1999 745
2 Afghanistan 2000 2666
3 Brazil 1999 37737
@@ -1699,7 +1725,7 @@ Reshaping wide data to long
# A tibble: 6 × 3
country name value
- <chr> <chr> <int>
+ <chr> <chr> <dbl>
1 Afghanistan 1999 745
2 Afghanistan 2000 2666
3 Brazil 1999 37737
@@ -1720,7 +1746,7 @@ Reshaping long data to wide
# A tibble: 6 × 4
country year cases population
- <chr> <int> <int> <int>
+ <chr> <dbl> <dbl> <dbl>
1 Afghanistan 1999 745 19987071
2 Afghanistan 2000 2666 20595360
3 Brazil 1999 37737 172006362
@@ -1743,7 +1769,7 @@ Separate
# A tibble: 6 × 4
country year cases pop
- <chr> <int> <chr> <chr>
+ <chr> <dbl> <chr> <chr>
1 Afghanistan 1999 745 19987071
2 Afghanistan 2000 2666 20595360
3 Brazil 1999 37737 172006362
@@ -1797,7 +1823,7 @@ Exercises
8 Afghanistan 1806 683
9 Afghanistan 1807 683
10 Afghanistan 1808 683
-# … with 48,935 more rows
+# ℹ 48,935 more rows
gdp_tidy <- pivot_longer(gdp_data,
cols = -country,
@@ -1818,7 +1844,7 @@ Exercises
8 Afghanistan 1806 683
9 Afghanistan 1807 683
10 Afghanistan 1808 683
-# … with 48,935 more rows
+# ℹ 48,935 more rows
- Which country had the highest GDP per person in 1985?
@@ -1832,13 +1858,13 @@ Exercises
country `1799` `1800` `1801` `1802` `1803` `1804` `1805` `1806` `1807` `1808`
<chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 Brunei 1710 1710 1710 1710 1710 1710 1710 1710 1710 1710
-# … with 241 more variables: `1809` <dbl>, `1810` <dbl>, `1811` <dbl>,
-# `1812` <dbl>, `1813` <dbl>, `1814` <dbl>, `1815` <dbl>, `1816` <dbl>,
-# `1817` <dbl>, `1818` <dbl>, `1819` <dbl>, `1820` <dbl>, `1821` <dbl>,
-# `1822` <dbl>, `1823` <dbl>, `1824` <dbl>, `1825` <dbl>, `1826` <dbl>,
-# `1827` <dbl>, `1828` <dbl>, `1829` <dbl>, `1830` <dbl>, `1831` <dbl>,
-# `1832` <dbl>, `1833` <dbl>, `1834` <dbl>, `1835` <dbl>, `1836` <dbl>,
-# `1837` <dbl>, `1838` <dbl>, `1839` <dbl>, `1840` <dbl>, `1841` <dbl>, …
+# ℹ 241 more variables: `1809` <dbl>, `1810` <dbl>, `1811` <dbl>, `1812` <dbl>,
+# `1813` <dbl>, `1814` <dbl>, `1815` <dbl>, `1816` <dbl>, `1817` <dbl>,
+# `1818` <dbl>, `1819` <dbl>, `1820` <dbl>, `1821` <dbl>, `1822` <dbl>,
+# `1823` <dbl>, `1824` <dbl>, `1825` <dbl>, `1826` <dbl>, `1827` <dbl>,
+# `1828` <dbl>, `1829` <dbl>, `1830` <dbl>, `1831` <dbl>, `1832` <dbl>,
+# `1833` <dbl>, `1834` <dbl>, `1835` <dbl>, `1836` <dbl>, `1837` <dbl>,
+# `1838` <dbl>, `1839` <dbl>, `1840` <dbl>, `1841` <dbl>, `1842` <dbl>, …
# using the long tidy data
gdp_tidy %>%
@@ -1907,7 +1933,7 @@ Exercises
8 Monaco 3454.
9 Uruguay 3255.
10 Denmark 3253
-# … with 185 more rows
+# ℹ 185 more rows
Binds/Joins
column binds
@@ -1926,7 +1952,7 @@ column binds
library(dplyr)
tbl1 <- tibble(x = 1:3)
tbl2 <- tibble(y = 3:5)
-bind_cols(tbl1, tbl2)
+bind_cols(tbl1, tbl2)
# A tibble: 3 × 2
x y
@@ -1946,7 +1972,7 @@ row binds
one <- starwars[1:4, 1:4]
two <- starwars[9:12, 1:4]
-bind_rows(one, two)
+bind_rows(one, two)
# A tibble: 8 × 4
name height mass hair_color
@@ -1965,7 +1991,7 @@ row binds
# A tibble: 8 × 4
name height mass hair_color
@@ -1979,7 +2005,7 @@ row binds
7 Anakin Skywalker 188 84 blond
8 Wilhuff Tarkin 180 NA auburn, grey
# A tibble: 8 × 5
source_table name height mass hair_color
@@ -2081,21 +2107,21 @@ Zeroes, NA
, NaN
and starwars
# A tibble: 87 × 14
- name height mass hair_…¹ skin_…² eye_c…³ birth…⁴ sex gender homew…⁵
- <chr> <int> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr> <chr>
- 1 Luke Skywa… 172 77 blond fair blue 19 male mascu… Tatooi…
- 2 C-3PO 167 75 <NA> gold yellow 112 none mascu… Tatooi…
- 3 R2-D2 96 32 <NA> white,… red 33 none mascu… Naboo
- 4 Darth Vader 202 136 none white yellow 41.9 male mascu… Tatooi…
- 5 Leia Organa 150 49 brown light brown 19 fema… femin… Aldera…
- 6 Owen Lars 178 120 brown,… light blue 52 male mascu… Tatooi…
- 7 Beru White… 165 75 brown light blue 47 fema… femin… Tatooi…
- 8 R5-D4 97 32 <NA> white,… red NA none mascu… Tatooi…
- 9 Biggs Dark… 183 84 black light brown 24 male mascu… Tatooi…
-10 Obi-Wan Ke… 182 77 auburn… fair blue-g… 57 male mascu… Stewjon
-# … with 77 more rows, 4 more variables: species <chr>, films <list>,
-# vehicles <list>, starships <list>, and abbreviated variable names
-# ¹hair_color, ²skin_color, ³eye_color, ⁴birth_year, ⁵homeworld
+ name height mass hair_color skin_color eye_color birth_year sex gender
+ <chr> <int> <dbl> <chr> <chr> <chr> <dbl> <chr> <chr>
+ 1 Luke Sk… 172 77 blond fair blue 19 male mascu…
+ 2 C-3PO 167 75 <NA> gold yellow 112 none mascu…
+ 3 R2-D2 96 32 <NA> white, bl… red 33 none mascu…
+ 4 Darth V… 202 136 none white yellow 41.9 male mascu…
+ 5 Leia Or… 150 49 brown light brown 19 fema… femin…
+ 6 Owen La… 178 120 brown, gr… light blue 52 male mascu…
+ 7 Beru Wh… 165 75 brown light blue 47 fema… femin…
+ 8 R5-D4 97 32 <NA> white, red red NA none mascu…
+ 9 Biggs D… 183 84 black light brown 24 male mascu…
+10 Obi-Wan… 182 77 auburn, w… fair blue-gray 57 male mascu…
+# ℹ 77 more rows
+# ℹ 5 more variables: homeworld <chr>, species <chr>, films <list>,
+# vehicles <list>, starships <list>
filter
with is.na()
You can identify variables with NA
values by combining filter()
and is.na()
.
NA
valuesNA
valuesLet’s replace the NA vaues in hair_color
with a string missing data
.
NA
valuesWe can also replace with values from another column, such as species
.
NA
valuesifelse
is a base R function that operates on vectors and is useful when you want to replace single values.
Lastly, it may be beneficial to replace the NA values with a summary value representative of the data. This is an example of data “imputation”.
@@ -2260,7 +2286,7 @@R version 4.2.0 (2022-04-22)
-Platform: x86_64-apple-darwin17.0 (64-bit)
-Running under: macOS Big Sur/Monterey 10.16
+R version 4.3.1 (2023-06-16)
+Platform: aarch64-apple-darwin20 (64-bit)
+Running under: macOS Monterey 12.2.1
Matrix products: default
-BLAS: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
-LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
+BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
+LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
+time zone: America/Denver
+tzcode source: internal
+
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
-[1] forcats_0.5.1 stringr_1.4.1 dplyr_1.0.10 purrr_0.3.5
-[5] tibble_3.1.8 ggplot2_3.3.6 tidyverse_1.3.1 tidyr_1.2.0
-[9] readr_2.1.2
+ [1] lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1 dplyr_1.1.3
+ [5] purrr_1.0.2 tibble_3.2.1 ggplot2_3.4.4 tidyverse_2.0.0
+ [9] tidyr_1.3.0 readr_2.1.4
loaded via a namespace (and not attached):
- [1] lubridate_1.8.0 assertthat_0.2.1 digest_0.6.30 utf8_1.2.2
- [5] R6_2.5.1 cellranger_1.1.0 backports_1.4.1 reprex_2.0.1
- [9] evaluate_0.16 httr_1.4.4 highr_0.9 pillar_1.8.1
-[13] rlang_1.0.6 readxl_1.4.0 rstudioapi_0.13 jquerylib_0.1.4
-[17] rmarkdown_2.14 bit_4.0.4 munsell_0.5.0 broom_0.8.0
-[21] compiler_4.2.0 modelr_0.1.8 xfun_0.32 pkgconfig_2.0.3
-[25] htmltools_0.5.2 downlit_0.4.2 tidyselect_1.2.0 fansi_1.0.3
-[29] crayon_1.5.2 tzdb_0.3.0 dbplyr_2.2.1 withr_2.5.0
-[33] grid_4.2.0 jsonlite_1.8.3 gtable_0.3.0 lifecycle_1.0.3
-[37] DBI_1.1.3 magrittr_2.0.3 scales_1.2.0 cli_3.4.1
-[41] stringi_1.7.8 vroom_1.5.7 cachem_1.0.6 fs_1.5.2
-[45] xml2_1.3.3 bslib_0.3.1 ellipsis_0.3.2 generics_0.1.3
-[49] vctrs_0.4.1 distill_1.5 tools_4.2.0 bit64_4.0.5
-[53] glue_1.6.2 hms_1.1.2 parallel_4.2.0 fastmap_1.1.0
-[57] yaml_2.3.6 colorspace_2.0-3 rvest_1.0.2 memoise_2.0.1
-[61] knitr_1.39 haven_2.5.0 sass_0.4.1
+ [1] sass_0.4.7 utf8_1.2.4 generics_0.1.3 stringi_1.8.1
+ [5] distill_1.6 hms_1.1.3 digest_0.6.33 magrittr_2.0.3
+ [9] timechange_0.2.0 evaluate_0.23 grid_4.3.1 fastmap_1.1.1
+[13] jsonlite_1.8.7 fansi_1.0.5 scales_1.2.1 jquerylib_0.1.4
+[17] cli_3.6.1 rlang_1.1.2 crayon_1.5.2 bit64_4.0.5
+[21] munsell_0.5.0 withr_2.5.2 cachem_1.0.8 yaml_2.3.7
+[25] tools_4.3.1 parallel_4.3.1 tzdb_0.4.0 memoise_2.0.1
+[29] colorspace_2.1-0 vctrs_0.6.4 R6_2.5.1 lifecycle_1.0.4
+[33] bit_4.0.5 vroom_1.6.4 pkgconfig_2.0.3 pillar_1.9.0
+[37] bslib_0.5.1 gtable_0.3.4 glue_1.6.2 xfun_0.41
+[41] tidyselect_1.2.0 highr_0.10 rstudioapi_0.15.0 knitr_1.45
+[45] htmltools_0.5.7 rmarkdown_2.25 compiler_4.3.1 downlit_0.4.3
`,e.githubCompareUpdatesUrl&&(t+=`View all changes to this article since it was first published.`),t+=` + If you see mistakes or want to suggest changes, please create an issue on GitHub.
+ `);const n=e.journal;return'undefined'!=typeof n&&'Distill'===n.title&&(t+=` +Diagrams and text are licensed under Creative Commons Attribution CC-BY 4.0 with the source available on GitHub, unless noted otherwise. The figures that have been reused from other sources don’t fall under this license and can be recognized by a note in their caption: “Figure from …”.
+ `),'undefined'!=typeof e.publishedDate&&(t+=` +For attribution in academic contexts, please cite this work as
+${e.concatenatedAuthors}, "${e.title}", Distill, ${e.publishedYear}.+
BibTeX citation
+${m(e)}+ `),t}var An=Math.sqrt,En=Math.atan2,Dn=Math.sin,Mn=Math.cos,On=Math.PI,Un=Math.abs,In=Math.pow,Nn=Math.LN10,jn=Math.log,Rn=Math.max,qn=Math.ceil,Fn=Math.floor,Pn=Math.round,Hn=Math.min;const zn=['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],Bn=['Jan.','Feb.','March','April','May','June','July','Aug.','Sept.','Oct.','Nov.','Dec.'],Wn=(e)=>10>e?'0'+e:e,Vn=function(e){const t=zn[e.getDay()].substring(0,3),n=Wn(e.getDate()),i=Bn[e.getMonth()].substring(0,3),a=e.getFullYear().toString(),d=e.getUTCHours().toString(),r=e.getUTCMinutes().toString(),o=e.getUTCSeconds().toString();return`${t}, ${n} ${i} ${a} ${d}:${r}:${o} Z`},$n=function(e){const t=Array.from(e).reduce((e,[t,n])=>Object.assign(e,{[t]:n}),{});return t},Jn=function(e){const t=new Map;for(var n in e)e.hasOwnProperty(n)&&t.set(n,e[n]);return t};class Qn{constructor(e){this.name=e.author,this.personalURL=e.authorURL,this.affiliation=e.affiliation,this.affiliationURL=e.affiliationURL,this.affiliations=e.affiliations||[]}get firstName(){const e=this.name.split(' ');return e.slice(0,e.length-1).join(' ')}get lastName(){const e=this.name.split(' ');return e[e.length-1]}}class Gn{constructor(){this.title='unnamed article',this.description='',this.authors=[],this.bibliography=new Map,this.bibliographyParsed=!1,this.citations=[],this.citationsCollected=!1,this.journal={},this.katex={},this.publishedDate=void 0}set url(e){this._url=e}get url(){if(this._url)return this._url;return this.distillPath&&this.journal.url?this.journal.url+'/'+this.distillPath:this.journal.url?this.journal.url:void 0}get githubUrl(){return this.githubPath?'https://github.com/'+this.githubPath:void 0}set previewURL(e){this._previewURL=e}get previewURL(){return this._previewURL?this._previewURL:this.url+'/thumbnail.jpg'}get publishedDateRFC(){return Vn(this.publishedDate)}get updatedDateRFC(){return Vn(this.updatedDate)}get publishedYear(){return this.publishedDate.getFullYear()}get publishedMonth(){return Bn[this.publishedDate.getMonth()]}get publishedDay(){return this.publishedDate.getDate()}get publishedMonthPadded(){return Wn(this.publishedDate.getMonth()+1)}get publishedDayPadded(){return Wn(this.publishedDate.getDate())}get publishedISODateOnly(){return this.publishedDate.toISOString().split('T')[0]}get volume(){const e=this.publishedYear-2015;if(1>e)throw new Error('Invalid publish date detected during computing volume');return e}get issue(){return this.publishedDate.getMonth()+1}get concatenatedAuthors(){if(2
tag. We found the following text: '+t);const n=document.createElement('span');n.innerHTML=e.nodeValue,e.parentNode.insertBefore(n,e),e.parentNode.removeChild(e)}}}}).observe(this,{childList:!0})}}var Ti='undefined'==typeof window?'undefined'==typeof global?'undefined'==typeof self?{}:self:global:window,_i=f(function(e,t){(function(e){function t(){this.months=['jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec'],this.notKey=[',','{','}',' ','='],this.pos=0,this.input='',this.entries=[],this.currentEntry='',this.setInput=function(e){this.input=e},this.getEntries=function(){return this.entries},this.isWhitespace=function(e){return' '==e||'\r'==e||'\t'==e||'\n'==e},this.match=function(e,t){if((void 0==t||null==t)&&(t=!0),this.skipWhitespace(t),this.input.substring(this.pos,this.pos+e.length)==e)this.pos+=e.length;else throw'Token mismatch, expected '+e+', found '+this.input.substring(this.pos);this.skipWhitespace(t)},this.tryMatch=function(e,t){return(void 0==t||null==t)&&(t=!0),this.skipWhitespace(t),this.input.substring(this.pos,this.pos+e.length)==e},this.matchAt=function(){for(;this.input.length>this.pos&&'@'!=this.input[this.pos];)this.pos++;return!('@'!=this.input[this.pos])},this.skipWhitespace=function(e){for(;this.isWhitespace(this.input[this.pos]);)this.pos++;if('%'==this.input[this.pos]&&!0==e){for(;'\n'!=this.input[this.pos];)this.pos++;this.skipWhitespace(e)}},this.value_braces=function(){var e=0;this.match('{',!1);for(var t=this.pos,n=!1;;){if(!n)if('}'==this.input[this.pos]){if(0 =k&&(++x,i=k);if(d[x]instanceof n||d[T-1].greedy)continue;w=T-x,y=e.slice(i,k),v.index-=i}if(v){g&&(h=v[1].length);var S=v.index+h,v=v[0].slice(h),C=S+v.length,_=y.slice(0,S),L=y.slice(C),A=[x,w];_&&A.push(_);var E=new n(o,u?a.tokenize(v,u):v,b,v,f);A.push(E),L&&A.push(L),Array.prototype.splice.apply(d,A)}}}}}return d},hooks:{all:{},add:function(e,t){var n=a.hooks.all;n[e]=n[e]||[],n[e].push(t)},run:function(e,t){var n=a.hooks.all[e];if(n&&n.length)for(var d,r=0;d=n[r++];)d(t)}}},i=a.Token=function(e,t,n,i,a){this.type=e,this.content=t,this.alias=n,this.length=0|(i||'').length,this.greedy=!!a};if(i.stringify=function(e,t,n){if('string'==typeof e)return e;if('Array'===a.util.type(e))return e.map(function(n){return i.stringify(n,t,e)}).join('');var d={type:e.type,content:i.stringify(e.content,t,n),tag:'span',classes:['token',e.type],attributes:{},language:t,parent:n};if('comment'==d.type&&(d.attributes.spellcheck='true'),e.alias){var r='Array'===a.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(d.classes,r)}a.hooks.run('wrap',d);var l=Object.keys(d.attributes).map(function(e){return e+'="'+(d.attributes[e]||'').replace(/"/g,'"')+'"'}).join(' ');return'<'+d.tag+' class="'+d.classes.join(' ')+'"'+(l?' '+l:'')+'>'+d.content+''+d.tag+'>'},!t.document)return t.addEventListener?(t.addEventListener('message',function(e){var n=JSON.parse(e.data),i=n.language,d=n.code,r=n.immediateClose;t.postMessage(a.highlight(d,a.languages[i],i)),r&&t.close()},!1),t.Prism):t.Prism;var d=document.currentScript||[].slice.call(document.getElementsByTagName('script')).pop();return d&&(a.filename=d.src,document.addEventListener&&!d.hasAttribute('data-manual')&&('loading'===document.readyState?document.addEventListener('DOMContentLoaded',a.highlightAll):window.requestAnimationFrame?window.requestAnimationFrame(a.highlightAll):window.setTimeout(a.highlightAll,16))),t.Prism}();e.exports&&(e.exports=n),'undefined'!=typeof Ti&&(Ti.Prism=n),n.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://i,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/?[\da-z]{1,8};/i},n.hooks.add('wrap',function(e){'entity'===e.type&&(e.attributes.title=e.content.replace(/&/,'&'))}),n.languages.xml=n.languages.markup,n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:{pattern:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,greedy:!0},property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,function:/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},n.languages.css.atrule.inside.rest=n.util.clone(n.languages.css),n.languages.markup&&(n.languages.insertBefore('markup','tag',{style:{pattern:/(
+
+
+ ${e.map(l).map((e)=>`
`)}}const Mi=`
+d-citation-list {
+ contain: layout style;
+}
+
+d-citation-list .references {
+ grid-column: text;
+}
+
+d-citation-list .references .title {
+ font-weight: 500;
+}
+`;class Oi extends HTMLElement{static get is(){return'd-citation-list'}connectedCallback(){this.hasAttribute('distill-prerendered')||(this.style.display='none')}set citations(e){x(this,e)}}var Ui=f(function(e){var t='undefined'==typeof window?'undefined'!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{}:window,n=function(){var e=/\blang(?:uage)?-(\w+)\b/i,n=0,a=t.Prism={util:{encode:function(e){return e instanceof i?new i(e.type,a.util.encode(e.content),e.alias):'Array'===a.util.type(e)?e.map(a.util.encode):e.replace(/&/g,'&').replace(/e.length)break tokenloop;if(!(y instanceof n)){c.lastIndex=0;var v=c.exec(y),w=1;if(!v&&f&&x!=d.length-1){if(c.lastIndex=i,v=c.exec(e),!v)break;for(var S=v.index+(g?v[1].length:0),C=v.index+v[0].length,T=x,k=i,p=d.length;T
+
+`);class Ni extends ei(Ii(HTMLElement)){renderContent(){if(this.languageName=this.getAttribute('language'),!this.languageName)return void console.warn('You need to provide a language attribute to your
Footnotes
+
+`,!1);class Fi extends qi(HTMLElement){connectedCallback(){super.connectedCallback(),this.list=this.root.querySelector('ol'),this.root.style.display='none'}set footnotes(e){if(this.list.innerHTML='',e.length){this.root.style.display='';for(const t of e){const e=document.createElement('li');e.id=t.id+'-listing',e.innerHTML=t.innerHTML;const n=document.createElement('a');n.setAttribute('class','footnote-backlink'),n.textContent='[\u21A9]',n.href='#'+t.id,e.appendChild(n),this.list.appendChild(e)}}else this.root.style.display='none'}}const Pi=ti('d-hover-box',`
+
+
+