Skip to content

Instantly share code, notes, and snippets.

@Akiyah
Last active January 3, 2016 16:19
Show Gist options
  • Select an option

  • Save Akiyah/8488756 to your computer and use it in GitHub Desktop.

Select an option

Save Akiyah/8488756 to your computer and use it in GitHub Desktop.
スターバックスでトールサイズのタンブラーにショートサイズのホットコーヒーを入れてもらった記録をグラフにしてみた
data <- c(
404,468,449,435,421,438,432,453,400,425,486,410,401,
423,458,422,406,458,397,453,452,395,425,
361,466,368,460,363,509,414,439,
437,
385,442,406,402,371,429,402,453,389,413,412,481,
385,406,402,422,414,484
)
data <- data - 189 # タンブラーの重さを除く
length(data)
mean(data)
sd(data)
library(ggplot2)
g <- ggplot(data.frame(value=data), aes(x=value))
g <- g + geom_histogram(binwidth=10)
g <- g + ggtitle("スターバックスで持参のトールタンブラーにショートを入れてもらったら")
g <- g + annotate("text",
label=paste0("サンプル:", length(data), ", 標準偏差:", round(sd(data), digits=1), "ml"),
x=220, y=10)
g <- g + geom_vline(xintercept=c(mean(data)), color="green")
g <- g + annotate("text",
label=paste0("平均=", round(mean(data), digits=1), "ml"),
x=mean(data), y=1, colour="green")
g <- g + geom_vline(xintercept=c(200), color="orange")
g <- g + annotate("text",
label="紙コップのショート=約200ml",
x=200, y=0.5, colour="orange")
plot(g)
ggsave(file="starbucks.png", plot=g, dpi=100, width=8, height=8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment