-
Notifications
You must be signed in to change notification settings - Fork 0
/
laCour.R
58 lines (42 loc) · 1.57 KB
/
laCour.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
library(ggplot2)
library(reshape2)
mat1 <- as.matrix(read.csv(file = "data/ml.csv"))
rownames(mat1) <- NULL
colnames(mat1) <- NULL
a1 <- paste(seq_along(c("Yes", "No")), ": ", c("Yes", "No"), sep="")
a1 <-
c("I hear you have some work to do. Do you wish to enter Michael Lacour Mode?",
"", a1, "")
b1 <- paste(seq_along(c("Yes", "No")), ": ", c("Yes", "No"), sep="")
b1 <-
c("Would you like to see the replication data for this?",
"", b1, "")
writeLines(a1)
pick <- readline("Selection: ")
if (pick == "No") {
cat("Hmm, that's not very nice of you.")
options(prompt="I AM A HOMOPHOBE AND THIS IS MY CODE > ")
} else {
cat("OK LET'S DO THIS. I hear you have to write a book chapter on culture and democracy.
Sounds like hard work. But why do the hard work when the founder of
beautifuldataviz.com can do it for you! Well have I ever got a present for you!")
Sys.sleep(2)
culture <- rnorm(50, 0, 1)
democracy <- 0.5 * culture + rnorm(50, 0, 0.2)
print(qplot(y = democracy, x = culture) + geom_smooth())
Sys.sleep(2)
cat("Pretty neat. My boutique statistical analysis skills and data collection
show that culture causes democracy!")
Sys.sleep(2)
writeLines(b1)
pick2 <- readline("Selection: ")
if (pick2 == "Yes") {
cat("Err, one second.")
Sys.sleep(2)
q(save = "no")
} else {
print(ggplot(melt(mat1), aes(Var1,Var2, fill=value)) + geom_raster() + scale_y_reverse() +
scale_fill_gradient(low="darkblue", high="white", guide = F) + ggtitle("Good Job!!") +
theme_bw() + xlab("") + ylab(""))
}
}