-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplotmaker.R
executable file
·77 lines (74 loc) · 3 KB
/
plotmaker.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
extract <- function(filename) {
connection <- file(filename, open="r")
lines <- readLines(connection)
close(connection)
total.headcount.line = lines[length(lines) - 1]
print(total.headcount.line)
total.headcount <- as.numeric(strsplit(total.headcount.line, "\t")[[1]][7])
total.degrees.line = lines[length(lines)]
total.degrees <- as.numeric(strsplit(total.degrees.line, "\t")[[1]][7])
return(c(total.headcount, total.degrees))
}
import <- function(school) {
long.school <- if(school == "cc") {
"Columbia College"
} else if(school == "en") {
"Columbia Engineering"
} else {
"General Studies"
}
range <- 2003:2012
jpeg(sprintf("Degrees and Headcounts by Year - %s.jpg", long.school))
par(mar = c(8,4,4,2) + 0.1)
a <- sapply(range, function(x) sprintf("data/%s-%d.tsv", school, x))
b <- sapply(a, function(x) extract(x))
print(b[1, ])
limits <- c(0.75 * min(b[1, ]), 1.25 * max(b[1,]))
plot(range, b[1, ], ylim = limits, type = "b", col = 'red',
xlab = "", ylab = "", pch = c(15), xaxt = "n")
par(new = T)
plot(range, b[2, ], ylim = limits, type = "b", col = 'blue',
xlab = "", ylab = "", pch = c(15), xaxt = "n")
title(sprintf("Degrees and Headcount by Year (%s)", long.school), ylab = "Count")
mtext("Graduating Class", side = 1, line = 6);
legend("topleft", c("Headcount", "Degrees"), col = c("red", "blue"),
lty = c(1, 1), pch = c(15, 15))
classes <- sapply(range, function(x) sprintf("%d-%d", x, x + 1))
axis(1, at = range, labels = classes, las = 2)
dev.off()
jpeg(sprintf("Achievement Factor - %s.jpg", long.school))
plot(range, b[1, ] / b[2, ], ylim = c(1, 1.5), type = "b", col = 'green',
xlab = "Year", ylab = "Ratio", pch = c(15),
main = sprintf("Achievement Factor (%s)", long.school))
dev.off()
}
achievement <- function() {
range <- 2003:2012
school = "cc"
a <- sapply(range, function(x) sprintf("data/%s-%d.tsv", school, x))
b <- sapply(a, function(x) extract(x))
jpeg("Achievement Factor.jpg")
plot(range, b[1, ] / b[2, ], ylim = c(1, 1.5), type = "b", col = 'green',
xlab = "Year", ylab = "Ratio", pch = c(15),
main = sprintf("Achievement Factor", long.school))
par(new = T)
school = "en"
a <- sapply(range, function(x) sprintf("data/%s-%d.tsv", school, x))
b <- sapply(a, function(x) extract(x))
plot(range, b[1, ] / b[2, ], ylim = c(1, 1.5), type = "b", col = 'red',
xlab = "Year", ylab = "Ratio", pch = c(15),
main = "Achievement Factor")
par(new = T)
school = "gs"
a <- sapply(range, function(x) sprintf("data/%s-%d.tsv", school, x))
b <- sapply(a, function(x) extract(x))
plot(range, b[1, ] / b[2, ], ylim = c(1, 1.5), type = "b", col = 'blue',
pch = c(15))
dev.off()
}
all <- function() {
import("cc")
import("en")
import("gs")
achievement()
}