knitr::opts_chunk$set(
  collapse = T,
  comment = "#>",
  fig.path = "man/README-",
  out.width = "100%"
)

Data for Preceptor's Primer for
Bayesian Data Science

R-CMD-check

About this package

primer.data provides the data used in Preceptor's Primer for Bayesian Data Science and for the associated tutorials.

Installation

remotes::install_github("ppbds/primer.data")

Loading

After installing the package, it loads as any package should.

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.

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()

Citing primer.data

citation("primer.data")
# 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()


PPBDS/primer.data documentation built on April 9, 2024, 5:36 p.m.