makeFigures = function(){ source("SpreadsheetDrawingCode.R") library("TableToLongForm") data(TCData) hcls = hcl(seq(0, 240, length = 3)) ## StatsNZ curTab = "StatsNZLabourForce" highmat = matrix(list(NA), nrow = nrow(TCData[[curTab]]), ncol = ncol(TCData[[curTab]])) highmat[3, 2] = list(hcls[1]) highmat[2, 2] = list(hcls[1]) highmat[5, 1] = list(hcls[2]) highmat[4, 9] = list(hcls[2]) highmat[5, 9] = list(hcls[3]) drawTableFront(TCData[[curTab]], rows = 1:14, cols = 1:11, pdfout = paste0(curTab, ".pdf"), highmat = highmat) #drawTableFront(TCData[[curTab]], pdfout = paste0(curTab, "_full.pdf")) conv = TableToLongForm(TCData[[curTab]]) convdraw = rbind(gsub("UNKNOWN", NA, colnames(conv)), conv) highmat = matrix(list(NA), nrow = nrow(convdraw), ncol = ncol(convdraw)) highmat[2, 1:3] = list(hcls[2]) highmat[1, 11] = list(hcls[2]) highmat[2, 11] = list(hcls[3]) drawTableFront(convdraw, rows = 1:14, cols = 1:11, pdfout = paste0(curTab, "converted.pdf"), highmat = highmat) ## Diagnostic output ## Following line produces a diagnostics text file ## saved as StatsNZLabourForce.TCRunout ## a few lines from this are used in the article convfull = TableToLongForm(TCData[[curTab]], fulloutput = TRUE, diagnostics = curTab) ## Following line produces same output as this command in the article ## > TableToLongForm(LabourForce, fulloutput = TRUE)[["colplist"]] print(convfull$colplist) ## NZQA curTab = "NZQAScholarships" drawTableFront(TCData[[curTab]], rows = 1:25, cols = 1:13, pdfout = paste0(curTab, ".pdf")) #drawTableFront(TCData[[curTab]], pdfout = paste0(curTab, "_full.pdf")) conv = TableToLongForm(TCData[[curTab]]) convdraw = rbind(gsub("UNKNOWN", NA, colnames(conv)), conv) drawTableFront(convdraw, rows = 1:25, cols = 1:13, pdfout = paste0(curTab, "converted.pdf")) ## Toy Examples (Recognised Patterns) ## Not all of these are used in article for(curTab in names(TCData)[grep("ToyEx", names(TCData))]){ conv = TableToLongForm(TCData[[curTab]]) ## Set output number of columns to share same number ## for both original and converted (min 6) ## so cell widths (once stretched in pdf) are visually equal cols = 1:max(ncol(TCData[[curTab]]), ncol(conv), 6) drawTableFront(TCData[[curTab]], cols = cols, cellwidth = 1.1, pdfout = paste0(curTab, ".pdf")) convdraw = rbind(gsub("UNKNOWN", NA, colnames(conv)), conv) drawTableFront(convdraw, cols = cols, cellwidth = 1.1, pdfout = paste0(curTab, "converted.pdf")) } ## UK Dept Edu curTab = "UK_DeptEdu_NEET_2013" ## Not included as part of TCData, so must be read in from csv curTabread = as.matrix(read.csv(paste0(curTab, ".csv"), header = FALSE, na.strings = c(""))) hcls = hcl(seq(0, 240, length = 3)) highmat = matrix(list(NA), nrow = nrow(curTabread), ncol = ncol(curTabread)) highmat[3:4, 4:24] = list(hcls[1]) highmat[5:46, 2:3] = list(hcls[2]) highmat[5:46, 4:24] = list(hcls[3]) drawTableFront(curTabread, rows = 1:14, cols = 1:11, pdfout = paste0(curTab, ".pdf"), colNotNum = 3, highmat = highmat) #drawTableFront(curTabread, pdfout = paste0(curTab, "_full.pdf"), colNotNum = 3, highmat = highmat) conv = TableToLongForm(curTabread, IdentResult = list(rows = list(label = 3:4, data = 5:46), cols = list(label = 2:3, data = 4:24))) convdraw = rbind(gsub("UNKNOWN", NA, colnames(conv)), conv) drawTableFront(convdraw, rows = 1:14, cols = 1:11, pdfout = paste0(curTab, "converted.pdf"), colNotNum = 3) }