Data
load("./red_and_black_170829_data.RData")
class_roll0829 <- class_roll
class_roll <- read.xlsx("../data/class_roll0901.xlsx",
sheetIndex = 1,
startRow = 2,
endRow = 180,
colIndex = c(3:7, 9),
colClasses = rep("character", 6),
stringsAsFactors = FALSE)
class_roll0831 <- read.xlsx("../data/class_roll0831.xlsx",
sheetIndex = 1,
startRow = 2,
endRow = 182,
colIndex = c(3:7, 9),
colClasses = rep("character", 6),
stringsAsFactors = FALSE)
names(class_roll) <- c("dept", "id", "name", "year", "e.mail", "cell.no")
names(class_roll0831) <- c("dept", "id", "name", "year", "e.mail", "cell.no")
class_roll0829$mark1 <- "0829"
class_roll0831$mark2 <- "0831"
class_roll$mark3 <- "0901"
class_roll.merged.0831 <- merge(class_roll0829, class_roll0831, all = TRUE)
class_roll.merged <- merge(class_roll.merged.0831, class_roll, all = TRUE)
pander(class_roll.merged[, 7:10])
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
NA |
NA |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
NA |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| NA |
NA |
NA |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| NA |
NA |
NA |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
NA |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
NA |
| Black |
0829 |
NA |
NA |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| NA |
NA |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| NA |
NA |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| NA |
NA |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| NA |
NA |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
NA |
| Black |
0829 |
0831 |
NA |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
NA |
NA |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| NA |
NA |
NA |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| NA |
NA |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| NA |
NA |
0831 |
0901 |
| Black |
0829 |
NA |
NA |
| Red |
0829 |
NA |
NA |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| NA |
NA |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
NA |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| NA |
NA |
NA |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
NA |
| NA |
NA |
NA |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
NA |
NA |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| NA |
NA |
NA |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| NA |
NA |
0831 |
0901 |
| NA |
NA |
0831 |
NA |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
NA |
NA |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
NA |
| Black |
0829 |
NA |
NA |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
NA |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
NA |
NA |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Red |
0829 |
0831 |
0901 |
| Black |
0829 |
0831 |
0901 |
| NA |
NA |
NA |
0901 |
| Black |
0829 |
0831 |
0901 |
| NA |
NA |
NA |
0901 |
pander(class_roll.merged[is.na(class_roll.merged$mark3), 7:10])
| 10 |
Red |
0829 |
NA |
NA |
| 21 |
Black |
0829 |
0831 |
NA |
| 34 |
Black |
0829 |
0831 |
NA |
| 38 |
Red |
0829 |
0831 |
NA |
| 39 |
Black |
0829 |
NA |
NA |
| 65 |
Red |
0829 |
0831 |
NA |
| 66 |
Black |
0829 |
0831 |
NA |
| 73 |
Red |
0829 |
NA |
NA |
| 82 |
Black |
0829 |
NA |
NA |
| 83 |
Red |
0829 |
NA |
NA |
| 93 |
Black |
0829 |
0831 |
NA |
| 106 |
Red |
0829 |
0831 |
NA |
| 119 |
Black |
0829 |
NA |
NA |
| 144 |
NA |
NA |
0831 |
NA |
| 149 |
Red |
0829 |
NA |
NA |
| 160 |
Red |
0829 |
0831 |
NA |
| 161 |
Black |
0829 |
NA |
NA |
| 184 |
Black |
0829 |
0831 |
NA |
| 190 |
Red |
0829 |
NA |
NA |
table(class_roll.merged[is.na(class_roll.merged$mark3), 7:10]$group)
##
## Red Black
## 9 9
id0829 <- class_roll0829$id
id0831 <- class_roll0831$id
id0901 <- class_roll$id
stay0831 <- intersect(id0829, id0831)
length(stay0831)
## [1] 171
stay0901 <- intersect(id0831, id0901)
length(stay0901)
## [1] 170
stay <- intersect(intersect(id0829, id0831), id0901)
stay02 <- intersect(id0829, id0901)
stay == stay02
## [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [15] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [29] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [43] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [57] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [71] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [85] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [99] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [113] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [127] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [141] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
## [155] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
new_id <- setdiff(id0901, stay)
class_roll.stay <- subset(class_roll0829, id %in% stay)
class_roll.new <- subset(class_roll, id %in% new_id)
# pander(class_roll.stay)
# pander(class_roll.new)
str(class_roll)
## 'data.frame': 178 obs. of 7 variables:
## $ dept : chr "컴퓨터공학과" "전자공학과" "언어청각학부" "융합소프트웨어학과" ...
## $ id : chr "20175101" "20145203" "20173903" "20165301" ...
## $ name : chr "강동인" "강민영" "강정수" "강종근" ...
## $ year : chr "1" "2" "1" "2" ...
## $ e.mail : chr "kdi6316@naver.com" "rf3935@naver.com" "jungsu009@naver.com" "whdrms1859@naver.com" ...
## $ cell.no: chr "010-2494-6316" "010-3975-1808" "010-6700-2931" "010-2300-3921" ...
## $ mark3 : chr "0901" "0901" "0901" "0901" ...
Randomization New Kids Only
set.seed(1)
N <- nrow(class_roll.new)
class_roll.new$group <- sample(1:N) %% 2 + 1
class_roll.new$group <- factor(class_roll.new$group,
labels = c("Red", "Black"))
class_roll.new <- class_roll.new[, c(1:6, 8, 7)]
names(class_roll.new)[8] <- "mark"
names(class_roll.stay)[8] <- "mark"
red.id <- which(class_roll.new$group == "Red")
black.id <- which(class_roll.new$group == "Black")
class_roll <- rbind(class_roll.stay, class_roll.new)
Randomization for All
set.seed(15)
N <- nrow(class_roll)
class_roll$group <- sample(1:N) %% 2 + 1
class_roll$group <- factor(class_roll$group,
labels = c("Red", "Black"))
red.id <- which(class_roll$group == "Red")
black.id <- which(class_roll$group == "Black")
학번
ID.16 <- factor(ifelse(substr(class_roll$id, 1, 4) >= 2016,
"younger.16", "older.16"),
levels = c("younger.16", "older.16"))
pander(table("16학번 기준" = ID.16,
"그룹" = class_roll$group))
| younger.16 |
48 |
48 |
| older.16 |
41 |
41 |
# table("16학번 기준" = ID.16,
# "그룹" = class_roll$group)
ID.15 <- factor(ifelse(substr(class_roll$id, 1, 4) >= 2015,
"younger.15", "older.15"),
levels = c("younger.15", "older.15"))
pander(table("15학번 기준" = ID.15,
"그룹" = class_roll$group))
| younger.15 |
55 |
57 |
| older.15 |
34 |
32 |
ID.14 <- factor(ifelse(substr(class_roll$id, 1, 4) >= 2014,
"younger.14", "older.14"),
levels = c("younger.14", "older.14"))
pander(table("14학번 기준" = ID.14,
"그룹" = class_roll$group))
| younger.14 |
73 |
73 |
| older.14 |
16 |
16 |
ID.13 <- factor(ifelse(substr(class_roll$id, 1, 4) >= 2013,
"younger.13", "older.13"),
levels = c("younger.13", "older.13"))
pander(table("13학번 기준" = ID.13,
"그룹" = class_roll$group))
| younger.13 |
79 |
81 |
| older.13 |
10 |
8 |
학번 홀짝
odd.even <- as.numeric(class_roll$id) %% 2
pander(table("odd_even" = odd.even,
"Group"= class_roll$group))
e-mail 서비스업체
e.mail.list <- strsplit(class_roll$e.mail, "@",
fixed = TRUE)
mail.com <- mapply(`[`, e.mail.list, 2)
pander(table("e-mail" = mail.com,
"그룹" = class_roll$group))
| daum.net |
3 |
2 |
| gmail.com |
4 |
4 |
| hanmail.net |
4 |
6 |
| icloud.com |
0 |
1 |
| nate.com |
3 |
6 |
| naver.com |
75 |
70 |
성씨 분포
f.name <- substring(class_roll$name,
first = 1,
last = 1)
pander(table("Family Name" = f.name,
"Group" = class_roll$group))
| 강 |
1 |
3 |
| 고 |
3 |
0 |
| 구 |
2 |
0 |
| 권 |
2 |
1 |
| 김 |
21 |
24 |
| 남 |
1 |
1 |
| 노 |
0 |
1 |
| 문 |
1 |
0 |
| 민 |
0 |
1 |
| 박 |
5 |
8 |
| 반 |
0 |
1 |
| 방 |
0 |
1 |
| 배 |
1 |
0 |
| 백 |
1 |
2 |
| 성 |
0 |
1 |
| 소 |
1 |
0 |
| 손 |
0 |
2 |
| 송 |
1 |
1 |
| 신 |
2 |
0 |
| 안 |
0 |
1 |
| 양 |
1 |
2 |
| 엄 |
1 |
0 |
| 오 |
1 |
0 |
| 원 |
1 |
0 |
| 유 |
0 |
2 |
| 윤 |
3 |
3 |
| 이 |
14 |
16 |
| 임 |
0 |
3 |
| 장 |
2 |
0 |
| 전 |
3 |
1 |
| 정 |
1 |
2 |
| 조 |
4 |
2 |
| 진 |
1 |
0 |
| 채 |
1 |
0 |
| 천 |
0 |
1 |
| 최 |
7 |
5 |
| 하 |
1 |
0 |
| 한 |
3 |
0 |
| 함 |
0 |
2 |
| 현 |
0 |
1 |
| 홍 |
2 |
0 |
| 황 |
1 |
1 |
많이 나오는 성씨
f.name.f <- factor(ifelse(f.name %in% c("김", "이", "박"),
f.name, "기타"),
levels = c("김", "이", "박", "기타"))
pander(table("Group" = class_roll$group,
"Family Name" = f.name.f))
| Red |
21 |
14 |
5 |
49 |
| Black |
24 |
16 |
8 |
41 |
학과
# pander(class_roll)
pander(table("그룹" = class_roll$group,
"학과" = class_roll$dept))
| Red |
2 |
7 |
4 |
0 |
1 |
0 |
0 |
1 |
5 |
2 |
1 |
3 |
4 |
0 |
6 |
1 |
1 |
3 |
6 |
5 |
0 |
4 |
1 |
4 |
10 |
2 |
2 |
0 |
9 |
0 |
5 |
0 |
| Black |
2 |
8 |
4 |
1 |
2 |
1 |
2 |
0 |
2 |
3 |
0 |
4 |
0 |
1 |
6 |
0 |
0 |
3 |
11 |
2 |
1 |
0 |
0 |
4 |
16 |
1 |
2 |
1 |
5 |
1 |
4 |
2 |