-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathREADME.Rmd
More file actions
119 lines (77 loc) · 3.4 KB
/
README.Rmd
File metadata and controls
119 lines (77 loc) · 3.4 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
---
output: github_document
---
<!-- README is generated from README.Rmd, edit ONLY this file if needed. But, after you edit it, you NEED TO KNIT IT BY HAND in order to create the new README.md, which is the thing which is actually used. -->
```{r, include=FALSE}
knitr::opts_chunk$set(
collapse = T,
comment = "#>",
fig.path = "man/README-",
out.width = "100%"
)
```
# Data for *Preceptor's Primer for <br/> Bayesian Data Science* <img src="man/figures/ulysses_hex_data.png" align = "right" width="160">
<!-- badges: start -->
[](https://github.com/PPBDS/primer.data/actions)
<!-- badges: end -->
## About this package
`primer.data` provides the data used in *[Preceptor's Primer for Bayesian Data Science](https://ppbds.github.io/primer)* and for the [associated tutorials](https://ppbds.github.io/primer.tutorials).
## Installation
```r
remotes::install_github("ppbds/primer.data")
```
## Loading
After installing the package, it loads as any package should.
```{r loading, message=F}
library(tidyverse)
library(primer.data)
qscores
```
## Using the data
Once the library is loaded and you have confirmed that it can be accessed in your local environment, the data sets can be called as objects and used like any other data you would otherwise read in and assign to an object manually. See the following example of a plot using `primary.data::nobel`.
```{r quick.plot, eval=FALSE}
library(tidyverse)
library(primer.data)
nobel |>
group_by(born_country, year) |>
summarize(prizes = n()) |>
mutate(cum_prize = cumsum(prizes)) |>
ungroup() |>
filter(born_country %in% c("USA", "United Kingdom",
"Germany", "France",
"Poland", "Sweden",
"Japan")) |>
mutate(born_country = factor(born_country, levels = c("USA", "United Kingdom",
"Germany", "France",
"Sweden", "Poland",
"Japan"))) |>
ggplot(., aes(x = year, y = cum_prize, color = factor(born_country))) +
geom_line() +
geom_vline(aes(xintercept = 1945), color = "darkgrey") +
geom_text(aes(x = 1941,
y = 100,
label = "End of WW2"),
color = "darkgrey",
angle = 90,
vjust = 1.2,
size = 3) +
scale_x_continuous(limits = c(1900, 2020), expand = expand_scale(0, 1)) +
labs(title = "Nobel Prizes Over Time by Origin of Laureate",
subtitle = "Number of U.S. laureates has grown at higher pace since 1945",
y = "Prizes (Cumulative)",
x = "Year",
color = "Country") +
theme_light()
```
<!-- TW: It is also possible to have this plot created by the code chunk itself. However, it is way to large and adjusting the dimensions causes errors. I don't know why. So for the time being, including a .png file is the better solution. -->
<img src= "man/figures/readme_plot.png" align="center">
## Citing primer.data
```{r citation, warning=FALSE}
citation("primer.data")
```
```{r build.site, include=FALSE, message=FALSE}
# DK: Add some comments to explain what is going on here. What does build_home()
# do and why is build_site() commented out?
# pkgdown::build_site()
pkgdown::build_home()
```