Skip to content

Instantly share code, notes, and snippets.

@kohske
Created January 9, 2019 01:27
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 kohske/1bd2443f794bc255db3abd0302dd7713 to your computer and use it in GitHub Desktop.
Save kohske/1bd2443f794bc255db3abd0302dd7713 to your computer and use it in GitHub Desktop.
---
title: "heikinn-eno-kaiki"
author: "kohske"
output: html_document
editor_options:
chunk_output_type: console
---
```{r}
library(plyr)
library(reshape2)
library(ggplot2)
set.seed(42)
N = 100
d = data.frame(ID = seq_len(N), testA = runif(N, 0, 1), testB = runif(N, 0, 1))
d$cat = cut(d$testA, breaks = 5)
d2 = ddply(d, .(cat), summarise, testA = mean(testA), testB = mean(testB))
d2$odds =(d2$testB/(1-d2$testB))/(d2$testA/(1-d2$testA))
d2$oddsN = d2$odds/max(d2$odds)
d3 = melt(d2)
ggplot(subset(d3, variable != "odds"), aes(cat, value, colour = variable)) +
geom_point() +
geom_line(aes(group=variable)) +
theme_bw()
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment