Skip to content

Instantly share code, notes, and snippets.

@geotheory
Forked from Dpananos/binning.R
Created March 10, 2021 02:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geotheory/5ff81331a257d5e99616052ae3923ca0 to your computer and use it in GitHub Desktop.
Save geotheory/5ff81331a257d5e99616052ae3923ca0 to your computer and use it in GitHub Desktop.
library(tidyverse)
set.seed(7)
N = 1000
x = rnorm(N)
p = plogis(0.2*x - 0.8)
y = rbinom(N, 1, p)
tibble(x, y) %>%
mutate(z = cut_number(x, 5)) %>%
ggplot(aes(z, y))+
stat_summary()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment