stop

references:
- ISI, example 8.1, p.430

library(tidyverse)

simulation

data

stopped <- read.csv("Stop.csv")
str(stopped)
## 'data.frame':    316 obs. of  2 variables:
##  $ position: Factor w/ 3 levels "follow","lead",..: 3 3 3 3 3 3 3 3 3 3 ...
##  $ stop    : Factor w/ 2 levels "no","yes": 2 2 2 2 2 2 2 2 2 2 ...
tbl <- stopped %>%
  group_by(position, stop) %>%
  summarize(n = n())
tbl
## # A tibble: 6 x 3
## # Groups:   position [?]
##   position   stop     n
##     <fctr> <fctr> <int>
## 1   follow     no    22
## 2   follow    yes    76
## 3     lead     no     4
## 4     lead    yes    38
## 5   single     no    25
## 6   single    yes   151

Bar plot.

ggplot(tbl, aes(x = position, stop, y = n, fill = stop)) +
  geom_bar(stat = "identity", position = "fill") +
  scale_fill_manual(values = c("azure", "bisque")) +
  labs(title = "Smoking")