@@ -338,10 +338,10 @@ We can visualize the population distribution of the price per night with a histo
338
338
options(pillar.sigfig = 5)
339
339
```
340
340
341
- ``` {r 11-example-means2, echo = TRUE, message = FALSE, warning = FALSE, fig.pos = "H", out.extra="", fig.cap = "Population distribution of price per night (Canadian dollars) for all Airbnb listings in Vancouver, Canada.", fig.height = 3.5, fig.width = 4.5}
341
+ ``` {r 11-example-means2, echo = TRUE, message = FALSE, warning = FALSE, fig.pos = "H", out.extra="", fig.cap = "Population distribution of price per night (dollars) for all Airbnb listings in Vancouver, Canada.", fig.height = 3.5, fig.width = 4.5}
342
342
population_distribution <- ggplot(airbnb, aes(x = price)) +
343
343
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
344
- labs(x = "Price per night (Canadian dollars)", y = "Count") +
344
+ labs(x = "Price per night (dollars)", y = "Count") +
345
345
theme(text = element_text(size = 12))
346
346
347
347
population_distribution
@@ -383,10 +383,10 @@ We can create a histogram to visualize the distribution of observations in the
383
383
sample (Figure \@ ref(fig:11-example-means-sample-hist)), and calculate the mean
384
384
of our sample.
385
385
386
- ``` {r 11-example-means-sample-hist, echo = TRUE, message = FALSE, warning = FALSE, fig.pos = "H", out.extra="", fig.cap = "Distribution of price per night (Canadian dollars) for sample of 40 Airbnb listings.", fig.height = 3.5, fig.width = 4.5}
386
+ ``` {r 11-example-means-sample-hist, echo = TRUE, message = FALSE, warning = FALSE, fig.pos = "H", out.extra="", fig.cap = "Distribution of price per night (dollars) for sample of 40 Airbnb listings.", fig.height = 3.5, fig.width = 4.5}
387
387
sample_distribution <- ggplot(one_sample, aes(price)) +
388
388
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
389
- labs(x = "Price per night (Canadian dollars)", y = "Count") +
389
+ labs(x = "Price per night (dollars)", y = "Count") +
390
390
theme(text = element_text(size = 12))
391
391
392
392
sample_distribution
@@ -434,7 +434,7 @@ sample_estimates
434
434
435
435
sampling_distribution_40 <- ggplot(sample_estimates, aes(x = sample_mean)) +
436
436
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
437
- labs(x = "Sample mean price per night (Canadian dollars)", y = "Count") +
437
+ labs(x = "Sample mean price per night (dollars)", y = "Count") +
438
438
theme(text = element_text(size = 12))
439
439
440
440
sampling_distribution_40
@@ -514,30 +514,30 @@ sample_estimates_500 <- rep_sample_n(airbnb, size = 500, reps = 20000) |>
514
514
## Sampling distribution n = 20
515
515
sampling_distribution_20 <- ggplot(sample_estimates_20, aes(x = sample_mean)) +
516
516
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
517
- labs(x = "Sample mean price per night\n(Canadian dollars)", y = "Count") +
517
+ labs(x = "Sample mean price per night ( dollars)", y = "Count") +
518
518
ggtitle("n = 20")
519
519
520
520
## Sampling distribution n = 50
521
521
sampling_distribution_50 <- ggplot(sample_estimates_50, aes(x = sample_mean)) +
522
522
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
523
523
ylab("Count") +
524
- xlab("Sample mean price per night\n(Canadian dollars)") +
524
+ xlab("Sample mean price per night ( dollars)") +
525
525
ggtitle("n = 50") +
526
526
xlim(min_x(sampling_distribution_20), max_x(sampling_distribution_20))
527
527
528
528
## Sampling distribution n = 100
529
529
sampling_distribution_100 <- ggplot(sample_estimates_100, aes(x = sample_mean)) +
530
530
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
531
531
ylab("Count") +
532
- xlab("Sample mean price per night\n(Canadian dollars)") +
532
+ xlab("Sample mean price per night ( dollars)") +
533
533
ggtitle("n = 100") +
534
534
xlim(min_x(sampling_distribution_20), max_x(sampling_distribution_20))
535
535
536
536
## Sampling distribution n = 500
537
537
sampling_distribution_500 <- ggplot(sample_estimates_500, aes(x = sample_mean)) +
538
538
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
539
539
ylab("Count") +
540
- xlab("Sample mean price per night\n(Canadian dollars)") +
540
+ xlab("Sample mean price per night ( dollars)") +
541
541
ggtitle("n = 500") +
542
542
xlim(min_x(sampling_distribution_20), max_x(sampling_distribution_20))
543
543
```
@@ -672,7 +672,7 @@ sample_10 <- airbnb |>
672
672
rep_sample_n(10)
673
673
sample_distribution_10 <- ggplot(sample_10, aes(price)) +
674
674
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
675
- xlab("Price per night (Canadian dollars)") +
675
+ xlab("Price per night (dollars)") +
676
676
ylab("Count") +
677
677
ggtitle("n = 10")
678
678
@@ -681,7 +681,7 @@ sample_20 <- airbnb |>
681
681
682
682
sample_distribution_20 <- ggplot(sample_20, aes(price)) +
683
683
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
684
- xlab("Price per night (Canadian dollars)") +
684
+ xlab("Price per night (dollars)") +
685
685
ylab("Count") +
686
686
ggtitle("n = 20")
687
687
@@ -690,7 +690,7 @@ sample_50 <- airbnb |>
690
690
691
691
sample_distribution_50 <- ggplot(sample_50, aes(price)) +
692
692
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
693
- xlab("Price per night (Canadian dollars)") +
693
+ xlab("Price per night (dollars)") +
694
694
ylab("Count") +
695
695
ggtitle("n = 50")
696
696
@@ -699,7 +699,7 @@ sample_100 <- airbnb |>
699
699
700
700
sample_distribution_100 <- ggplot(sample_100, aes(price)) +
701
701
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
702
- xlab("Price per night (Canadian dollars)") +
702
+ xlab("Price per night (dollars)") +
703
703
ylab("Count") +
704
704
ggtitle("n = 100")
705
705
@@ -708,7 +708,7 @@ sample_200 <- airbnb |>
708
708
709
709
sample_distribution_200 <- ggplot(sample_200, aes(price)) +
710
710
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
711
- xlab("Price per night (Canadian dollars)") +
711
+ xlab("Price per night (dollars)") +
712
712
ylab("Count") +
713
713
ggtitle("n = 200")
714
714
@@ -779,12 +779,12 @@ one_sample <- one_sample |>
779
779
ungroup() |> select(-replicate)
780
780
```
781
781
782
- ``` {r 11-bootstrapping1, echo = TRUE, message = FALSE, warning = FALSE, fig.pos = "H", out.extra="", fig.cap = "Histogram of price per night (Canadian dollars) for one sample of size 40.", fig.height = 3.5, fig.width = 4.5}
782
+ ``` {r 11-bootstrapping1, echo = TRUE, message = FALSE, warning = FALSE, fig.pos = "H", out.extra="", fig.cap = "Histogram of price per night (dollars) for one sample of size 40.", fig.height = 3.5, fig.width = 4.5}
783
783
one_sample
784
784
785
785
one_sample_dist <- ggplot(one_sample, aes(price)) +
786
786
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
787
- labs(x = "Price per night (Canadian dollars)", y = "Count") +
787
+ labs(x = "Price per night (dollars)", y = "Count") +
788
788
theme(text = element_text(size = 12))
789
789
790
790
one_sample_dist
@@ -810,7 +810,7 @@ boot1 <- one_sample |>
810
810
rep_sample_n(size = 40, replace = TRUE, reps = 1)
811
811
boot1_dist <- ggplot(boot1, aes(price)) +
812
812
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
813
- labs(x = "Price per night (Canadian dollars)", y = "Count") +
813
+ labs(x = "Price per night (dollars)", y = "Count") +
814
814
theme(text = element_text(size = 12))
815
815
816
816
boot1_dist
@@ -850,7 +850,7 @@ six_bootstrap_samples <- boot20000 |>
850
850
851
851
ggplot(six_bootstrap_samples, aes(price)) +
852
852
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
853
- labs(x = "Price per night (Canadian dollars)", y = "Count") +
853
+ labs(x = "Price per night (dollars)", y = "Count") +
854
854
facet_wrap(~replicate) +
855
855
theme(text = element_text(size = 12))
856
856
```
@@ -881,7 +881,7 @@ tail(boot20000_means)
881
881
882
882
boot_est_dist <- ggplot(boot20000_means, aes(x = mean)) +
883
883
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
884
- labs(x = "Sample mean price per night \n (Canadian dollars)", y = "Count") +
884
+ labs(x = "Sample mean price per night ( dollars)", y = "Count") +
885
885
theme(text = element_text(size = 12))
886
886
887
887
boot_est_dist
@@ -900,7 +900,7 @@ sample_estimates <- samples |>
900
900
sampling_dist <- ggplot(sample_estimates, aes(x = sample_mean)) +
901
901
geom_histogram(fill = "dodgerblue3", color = "lightgrey") +
902
902
ylab("Count") +
903
- xlab("Sample mean price per night \n (Canadian dollars)")
903
+ xlab("Sample mean price per night ( dollars)")
904
904
905
905
annotated_sampling_dist <- sampling_dist +
906
906
xlim(min_x(sampling_dist), max_x(sampling_dist)) +
0 commit comments