Created
February 25, 2019 23:56
-
-
Save dgrtwo/d590078aae86e24418a7cf5a9fb31ae3 to your computer and use it in GitHub Desktop.
Animation of die rolls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Code behind this tweet: https://twitter.com/drob/status/1100182329350336513 | |
library(tidyverse) | |
library(gganimate) | |
# Setup | |
options(gganimate.nframes = 200) | |
set.seed(2019) | |
simulation <- tibble(roll = 1:10000) %>% | |
mutate(result = sample(6, n(), replace = TRUE)) %>% | |
crossing(nrolls = seq(10, 10000, 10)) %>% | |
filter(roll <= nrolls) %>% | |
count(nrolls, result) | |
ggplot(simulation, aes(result, n, fill = factor(result))) + | |
geom_col(position = "identity", show.legend = FALSE) + | |
transition_manual(nrolls) + | |
view_follow() + | |
scale_x_continuous(breaks = 1:6) + | |
labs(y = "# of rolls with this result", | |
title = "Distribution of results after { current_frame } rolls of a six-sided die") |
please can you tell me how can i extract tweets and their replies about a specific thing and not person
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One question please. Is there a reason you didn't pipe your data
simulation
into the call toggplot()
?