Skip to content

Instantly share code, notes, and snippets.

@steveharoz
Created June 14, 2019 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save steveharoz/ce6c2eca36b321e83a7d14900cbad6f0 to your computer and use it in GitHub Desktop.
Save steveharoz/ce6c2eca36b321e83a7d14900cbad6f0 to your computer and use it in GitHub Desktop.
library(tidyverse)
data = tribble(
~Site, ~Participants, ~Victims, ~Percent_Victims,
"Bordeaux", 137, 12, 8.8,
"Lille", 131, 9, 6.9,
"Lorraine", 268, 37, 13.8,
"Paris", 239, 23, 9.6,
"Rennes", 324, 33, 10.2,
"Rhone-Alpes", 219, 13, 5.9,
"Rocquencourt (Siege)", 82, 8, 9.8,
"Saclay", 204, 7, 3.4,
"Sophia", 219, 28, 12.8
)
data %>%
rowwise() %>%
mutate( lo = PropCIs::exactci(Victims, Participants, .95)$conf.int[[1]],
hi = PropCIs::exactci(Victims, Participants, .95)$conf.int[[2]],
lo99 = PropCIs::exactci(Victims, Participants, .99)$conf.int[[1]],
hi99 = PropCIs::exactci(Victims, Participants, .99)$conf.int[[2]],
lo50 = PropCIs::exactci(Victims, Participants, .5)$conf.int[[1]],
hi50 = PropCIs::exactci(Victims, Participants, .5)$conf.int[[2]],
Percent_Victims = Victims / Participants) %>%
ungroup() %>%
arrange(lo) %>%
mutate(Site = fct_inorder(Site, ordered = TRUE)) %>%
ggplot() +
aes(x = Site, y = Percent_Victims) +
geom_point(size = 4) +
geom_segment(aes(x=Site, xend=Site, y=lo, yend=hi), size = 1) +
geom_segment(aes(x=Site, xend=Site, y=lo50, yend=hi50), size = 2) +
geom_segment(aes(x=Site, xend=Site, y=lo99, yend=hi99), size = 0.33) +
scale_y_continuous(labels = function(y) paste0(y*100, "%")) +
labs(x = NULL, y = NULL, title = "Inria phishing victims") +
coord_flip() +
theme_light(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment