knitr::opts_chunk$set(echo = TRUE, message = F, warning = F, fig.height = 6, comment = "", c)
options(knitr.duplicate.label = "allow")
library(ggsample)

Visualizing concepts is powerful...

--

True of sampling


Use cool/great GUI tools to do so...

# knitr::include_graphics("applet.png")

Then, we ask students to do actual analysis in reproducible way with code...

--

R, Tidyverse, ggplot2 are great tools

--

Remember what we talked about from the GUI applet. Those principles apply!

--

To correograph visual sampling experience in R/ggplot2 is currently time consuming, involved...


Enter ggsample!


r flipbookr::chunk_reveal('geom_point_lm_sample_7', title = '### geom_point_lm_sample')


r flipbookr::chunk_reveal('geom_point_lm_sample_7', title = '### geom_point_lm_sample', break_type = 7)

my_seed <- sample(1:100, 1)
library(ggplot2)
ggplot(data = cars) +
  aes(x = speed, y = dist) +
  geom_point() +
  geom_point_lm_sample(color = "darkred")

r flipbookr::chunk_reveal('facet_sample_2', title = '### facet_sample')

# mean from samples
library(ggplot2)
ggplot(data = cars) +
  aes(x = speed) +
  geom_rug(size = 2, alpha = .5, color = "magenta") +
  ggxmean::geom_x_mean(linetype = "dashed") +
  facet_sample(n_facets = 1, n_sampled = 20) +
  facet_sample(n_facets = 2, n_sampled = 20) +
  facet_sample(n_facets = 3, n_sampled = 20) +
  facet_sample(n_facets = 15, n_sampled = 20) +
  ggxmean::geom_x_mean_label()

r flipbookr::chunk_reveal('facet_sample_3', title = '### facet_sample')

# linear model from samples
set.seed(1323)
library(ggplot2)
ggplot(data = cars) +
  aes(x = speed) +
  aes(y = dist) +
  geom_point(color = "olivedrab4") +
  ggxmean::geom_lm() +
  labs(caption = "Population are observations from cars correlation study dataset") +
  facet_sample(n_sampled = 8) +
  labs(title =
     "16 draws, each a random sample of 8 observations from the population") +
  labs(subtitle = "Depending on our particular random sample...") +
  ggxmean::geom_lm_formula()

r flipbookr::chunk_reveal('facet_scramble_5', title = '### facet_scramble')

library(ggplot2)
set.seed(232)
ggplot(data = cars) +
  aes(x = speed) +
  aes(y = dist) +
  geom_rug() +
  geom_point(color = "springgreen4",
           alpha = .75) +
  facet_scramble(n_facets = 1) +
  facet_scramble(n_facets = 2) +
  facet_scramble(n_facets = 3) +
  ggxmean::geom_lm() +
  facet_scramble(n_facets = 12) +
  labs(title = "Disassociating variables")


EvaMaeRey/ggsample documentation built on June 6, 2024, 9:32 a.m.