setwd("~/online_communities/coldcallbot/data/") library(ggplot2) library(data.table) gs <- read.delim("student_information.tsv") d <- gs[,c(2,4)] colnames(d) <- c("student.num", "unique.name") call.list <- do.call("rbind", lapply(list.files(".", pattern="^call_list-.*tsv$"), function (x) {read.delim(x, stringsAsFactors=FALSE)[,1:4]})) colnames(call.list) <- gsub("_", ".", colnames(call.list)) table(call.list$unique_name[call.list$answered]) ## drop calls where the person wasn't present call.list.full <- call.list call.list[!call.list$answered,] call.list <- call.list[call.list$answered,] call.counts <- data.frame(table(call.list$unique.name)) colnames(call.counts) <- c("unique.name", "num.calls") d <- merge(d, call.counts, all.x=TRUE, all.y=TRUE, by="unique.name"); d