Skip to content

Commit 63d798c

Browse files
committed
port over changes from DSC385
1 parent bed4901 commit 63d798c

File tree

8 files changed

+384
-136
lines changed

8 files changed

+384
-136
lines changed

_freeze/slides/visualizing-uncertainty/execute-results/html.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

_site/datasets/pottery.R

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
library(archdata)
2+
library(here)
3+
data('RBPottery')
4+
5+
write_csv(RBPottery, here("datasets", "pottery.csv"))
6+
7+
8+
library(tidyverse)
9+
library(broom)
10+
11+
pca_fit <- RBPottery |>
12+
select(where(is.numeric)) |> # retain only numeric columns
13+
scale() |> # scale to zero mean and unit variance
14+
prcomp()
15+
16+
pca_fit |>
17+
# add PCs to the original dataset
18+
augment(RBPottery) |>
19+
ggplot(aes(.fittedPC1, .fittedPC2)) +
20+
geom_point(aes(color = Region))
21+
22+
arrow_style <- arrow(
23+
angle = 20, length = grid::unit(8, "pt"),
24+
ends = "first", type = "closed"
25+
)
26+
27+
pca_fit |>
28+
# extract rotation matrix
29+
tidy(matrix = "rotation") |>
30+
pivot_wider(
31+
names_from = "PC", values_from = "value",
32+
names_prefix = "PC"
33+
) |>
34+
mutate(
35+
# order of variables is:
36+
# Al2O3, Fe2O3, MgO, CaO, Na2O, K2O, TiO2, MnO, BaO
37+
hjust = c(1.05, -.05, -.05, 0.5, 0.5, -.05, 1.05, -.05, 1.05),
38+
vjust = c(0.5, 0.5, 0.5, -.1, -.1, 0.8, 0.5, 0.2, 0)
39+
) |>
40+
ggplot(aes(PC1, PC2)) +
41+
geom_segment(
42+
xend = 0, yend = 0,
43+
arrow = arrow_style
44+
) +
45+
geom_text(aes(label = column, hjust = hjust, vjust = vjust)) +
46+
coord_fixed(
47+
xlim = c(-.7, 0.7),
48+
ylim = c(-.5, .7)
49+
)

_site/datasets/pottery.csv

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
ID,Kiln,Region,Al2O3,Fe2O3,MgO,CaO,Na2O,K2O,TiO2,MnO,BaO
2+
GA1,Gloucester,Gloucester,18.8,9.52,2,0.79,0.4,3.2,1.01,0.077,0.015
3+
GA2,Gloucester,Gloucester,16.9,7.33,1.65,0.84,0.4,3.05,0.99,0.067,0.018
4+
GA3,Gloucester,Gloucester,18.2,7.64,1.82,0.77,0.4,3.07,0.98,0.087,0.014
5+
GA4,Gloucester,Gloucester,17.4,7.48,1.71,1.01,0.4,3.16,0.03,0.084,0.017
6+
GA5,Gloucester,Gloucester,16.9,7.29,1.56,0.76,0.4,3.05,1,0.063,0.019
7+
GB1,Gloucester,Gloucester,17.8,7.24,1.83,0.92,0.43,3.12,0.93,0.061,0.019
8+
GB2,Gloucester,Gloucester,18.8,7.45,2.06,0.87,0.25,3.26,0.98,0.072,0.017
9+
GB3,Gloucester,Gloucester,16.5,7.05,1.81,1.73,0.33,3.2,0.95,0.066,0.019
10+
GB4,Gloucester,Gloucester,18,7.42,2.06,1,0.28,3.37,0.96,0.072,0.017
11+
GB5,Gloucester,Gloucester,15.8,7.15,1.62,0.71,0.38,3.25,0.93,0.062,0.017
12+
GC1,Gloucester,Gloucester,14.6,6.87,1.67,0.76,0.33,3.06,0.91,0.055,0.012
13+
GC2,Gloucester,Gloucester,13.7,5.83,1.5,0.66,0.13,2.25,0.75,0.034,0.012
14+
GC3,Gloucester,Gloucester,14.6,6.76,1.63,1.48,0.2,3.02,0.87,0.055,0.016
15+
GC4,Gloucester,Gloucester,14.8,7.07,1.62,1.44,0.24,3.03,0.86,0.08,0.016
16+
GD1,Gloucester,Gloucester,17.1,7.79,1.99,0.83,0.46,3.13,0.93,0.09,0.02
17+
GD2,Gloucester,Gloucester,16.8,7.86,1.86,0.84,0.46,2.93,0.94,0.094,0.02
18+
GD3,Gloucester,Gloucester,15.8,7.65,1.94,0.81,0.83,3.33,0.96,0.112,0.019
19+
GD4,Gloucester,Gloucester,18.6,7.85,2.33,0.87,0.38,3.17,0.98,0.081,0.018
20+
GD5,Gloucester,Gloucester,16.9,7.87,1.83,1.31,0.53,3.09,0.95,0.092,0.023
21+
GE1,Gloucester,Gloucester,18.9,7.58,2.05,0.83,0.13,3.29,0.98,0.072,0.015
22+
GE2,Gloucester,Gloucester,18,7.5,1.94,0.69,0.12,3.14,0.93,0.035,0.017
23+
GE3,Gloucester,Gloucester,17.8,7.28,1.92,0.81,0.18,3.15,0.9,0.067,0.017
24+
C01,Llanedeyrn,Wales,14.4,7,4.3,0.15,0.51,4.25,0.79,0.16,0.019
25+
CO2,Llanedeyrn,Wales,13.8,7.08,3.43,0.12,0.17,4.14,0.77,0.144,0.02
26+
CO3,Llanedeyrn,Wales,14.6,7.09,3.88,0.13,0.2,4.36,0.81,0.124,0.019
27+
C04,Llanedeyrn,Wales,11.5,6.37,5.64,0.16,0.14,3.89,0.69,0.087,0.009
28+
CO5,Llanedeyrn,Wales,13.8,7.06,5.34,0.2,0.2,4.31,0.71,0.101,0.021
29+
C06,Llanedeyrn,Wales,10.9,6.26,3.47,0.17,0.22,3.4,0.66,0.109,0.01
30+
C07,Llanedeyrn,Wales,10.1,4.26,4.26,0.2,0.18,3.32,0.59,0.149,0.017
31+
C08,Llanedeyrn,Wales,11.6,5.78,5.91,0.18,0.16,3.7,0.65,0.082,0.015
32+
C09,Llanedeyrn,Wales,11.1,5.49,4.52,0.29,0.3,4.03,0.63,0.08,0.016
33+
C10,Llanedeyrn,Wales,13.4,6.92,7.23,0.28,0.2,4.54,0.69,0.163,0.017
34+
C11,Llanedeyrn,Wales,12.4,6.13,5.69,0.22,0.54,4.65,0.7,0.159,0.015
35+
C12,Llanedeyrn,Wales,13.1,6.64,5.51,0.31,0.24,4.89,0.72,0.094,0.017
36+
C13,Llanedeyrn,Wales,12.7,6.69,4.45,0.2,0.22,4.7,0.73,0.394,0.024
37+
C14,Llanedeyrn,Wales,12.5,6.44,3.94,0.22,0.23,0.81,0.75,0.177,0.019
38+
GO1,Caldicot,Wales,11.6,5.39,3.77,0.29,0.06,4.51,0.56,0.11,0.015
39+
G02,Caldicot,Wales,11.8,5.44,3.94,0.3,0.04,4.64,0.59,0.085,0.013
40+
T11,Islands Thorns,New Forest,18.3,1.28,0.67,0.03,0.03,1.96,0.65,0.001,0.014
41+
T12,Islands Thorns,New Forest,15.8,2.39,0.63,0.01,0.04,1.94,1.29,0.001,0.014
42+
T13,Islands Thorns,New Forest,18,1.5,0.67,0.01,0.06,2.11,0.92,0.001,0.016
43+
T14,Islands Thorns,New Forest,18,1.88,0.68,0.01,0.04,2,1.11,0.006,0.022
44+
T16,Islands Thorns,New Forest,20.8,1.51,0.72,0.07,0.1,2.37,1.26,0.002,0.016
45+
A11,Ashley Rails,New Forest,17.7,1.12,0.56,0.06,0.06,2.06,0.79,0.001,0.013
46+
Al2,Ashley Rails,New Forest,18.3,1.14,0.67,0.06,0.05,2.11,0.89,0.006,0.019
47+
A16,Ashley Rails,New Forest,16.7,0.92,0.53,0.01,0.05,1.76,0.91,0.004,0.013
48+
A18,Ashley Rails,New Forest,14.8,2.74,0.67,0.03,0.05,2.15,1.34,0.003,0.015
49+
A26,Ashley Rails,New Forest,19.1,1.64,0.6,0.1,0.03,1.75,1.04,0.007,0.018

_site/search.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6957,6 +6957,13 @@
69576957
"section": "Hypothetical Outcome Plots again help develop intuition",
69586958
"text": "Hypothetical Outcome Plots again help develop intuition\n\n\n\n\n\n\nFuel efficiency versus displacement, for 32 cars (1973–74 models). Source: Motor Trend, 1974"
69596959
},
6960+
{
6961+
"objectID": "slides/visualizing-uncertainty.html#getting-the-data",
6962+
"href": "slides/visualizing-uncertainty.html#getting-the-data",
6963+
"title": "Visualizing Uncertainty",
6964+
"section": "Getting the data",
6965+
"text": "Getting the data\n\nThe gapminder dataset:\n\n\n\nlibrary(gapminder)\n\ngapminder\n\n# A tibble: 1,704 × 6\n country continent year lifeExp pop gdpPercap\n &lt;fct&gt; &lt;fct&gt; &lt;int&gt; &lt;dbl&gt; &lt;int&gt; &lt;dbl&gt;\n 1 Afghanistan Asia 1952 28.8 8425333 779.\n 2 Afghanistan Asia 1957 30.3 9240934 821.\n 3 Afghanistan Asia 1962 32.0 10267083 853.\n 4 Afghanistan Asia 1967 34.0 11537966 836.\n 5 Afghanistan Asia 1972 36.1 13079460 740.\n 6 Afghanistan Asia 1977 38.4 14880372 786.\n 7 Afghanistan Asia 1982 39.9 12881816 978.\n 8 Afghanistan Asia 1987 40.8 13867957 852.\n 9 Afghanistan Asia 1992 41.7 16317921 649.\n10 Afghanistan Asia 1997 41.8 22227415 635.\n# ℹ 1,694 more rows"
6966+
},
69606967
{
69616968
"objectID": "slides/visualizing-uncertainty.html#making-a-plot-with-error-bars",
69626969
"href": "slides/visualizing-uncertainty.html#making-a-plot-with-error-bars",

0 commit comments

Comments
 (0)