Commit d24352c9 authored by Yong Liu's avatar Yong Liu

Refs #6196

parent 505fe698
......@@ -378,17 +378,20 @@ sdcGUI <- function() {
}
n <- nrow(ActiveSdcObject()@origData)
svalue(nbMain) <- 1
keyvariablerisktable[] = data.frame(c("violating 2-anonymity", "violating 3-anonymity", "risk-higher than the benchmark", "Re-indentification, global risk", "Re-indentification, hierarchical risk"),
keyvariablerisktable[] = data.frame(c("N1", "N2", "N3", "N4", "N5"),
c("violating 2-anonymity", "violating 3-anonymity", "risk-higher than the benchmark", "Re-indentification, global risk", "Re-indentification, hierarchical risk"),
c(current2violate, current3violate, currenthighrisk, currentexpectedrisk, CurrentCount),
c(orig2violate, orig3violate, orighighrisk, origexpectedrisk, OrigCount),
c(paste(round(current2violate/n * 100, 2), "%", SEP=""), paste(round(current3violate/n * 100, 2), "%", SEP=""), paste(round(currenthighrisk/n * 100, 2), "%", SEP=""), paste(round(currentexpectedrisk/n * 100, 2), "%", SEP=""),paste(CurrentPercentage, "%", SEP="")),
c(paste(round(orig2violate/n * 100, 2), "%", SEP=""), paste(round(orig3violate/n * 100, 2), "%", SEP=""), paste(round(orighighrisk/n * 100, 2), "%", SEP=""), paste(round(origexpectedrisk/n * 100, 2), "%", SEP=""),paste(OrigPercentage, "%", SEP="")),stringsAsFactors=FALSE)
visible(keyvariableriskgraph) <- TRUE
barplot(matrix(c(current2violate, orig2violate,
current3violate, orig3violate,
currenthighrisk, orighighrisk,
currentexpectedrisk,origexpectedrisk
), nrow = 2, ncol = 4), beside = TRUE, main="Frequency Distribution", legend=c("obs. curr", "obs. orig"))
counts <- c(round(current2violate/n * 100, 2), round(orig2violate/n * 100, 2),
round(current3violate/n * 100, 2), round(orig3violate/n * 100, 2),
round(currenthighrisk/n * 100, 2), round(orighighrisk/n * 100, 2),
round(currentexpectedrisk/n * 100, 2),round(origexpectedrisk/n * 100, 2),
CurrentPercentage, OrigPercentage
)
barplot(matrix(counts, nrow = 2, ncol = 5), beside = TRUE, main="Percentage of observations at risk", names.arg=c("N1", "N2","N3", "N4", "N5"))
m1 <- ActiveSdcVars("risk")$individual
xtmp <- ActiveSdcVars("manipKeyVars")
tabDat <- cbind(xtmp,m1)
......@@ -5210,7 +5213,7 @@ compareDataExport <- function(comparedScript, len, ...){
} else if(h$pageno == 3) {
visible(g1) <- TRUE
if(nrow(tabDat) > 10) {
try(barplot(c(as.numeric(tabDat$Fk[1:10])), main="Ten Least Population Frequencies for Categorical Key Variables", horiz =TRUE, cex.names=0.5, names.arg=do.call(paste0, tabDat[1:10, names(sdc@manipKeyVars)]), las=1), silent=TRUE)
try(barplot(c(as.numeric(tabDat$Fk[1:10])), main="Ten Lowest Population Frequencies for Categorical Key Variables", horiz =TRUE, cex.names=0.5, names.arg=do.call(paste0, tabDat[1:10, names(sdc@manipKeyVars)]), las=1), silent=TRUE)
} else {
try(barplot(c(as.numeric(tabDat$Fk)), main="Population Frequencies for Categorical Key Variables", horiz =TRUE, cex.names=0.5, names.arg=do.call(paste0, tabDat[names(sdc@manipKeyVars)]), las=1), silent=TRUE)
}
......@@ -5497,10 +5500,10 @@ compareDataExport <- function(comparedScript, len, ...){
tmpCR = gframe('<span foreground="blue" size="x-large" weight="bold">Risk</span>', container=mainGroupCat, horizontal=FALSE,markup=TRUE, expand=TRUE)
tmpCU = gframe('<span foreground="blue" size="x-large" weight="bold">Information Loss</span>', container=mainGroupCat, horizontal=FALSE,markup=TRUE, expand=TRUE)
fc_tmp = gframe('<span size="medium" weight="bold">Frequency calculations</span>', expand=TRUE,markup=TRUE,container= tmpCR)
fc_tmp = gframe('<span size="medium" weight="bold">Observations at risk of</span>', expand=TRUE,markup=TRUE,container= tmpCR)
tmp = gframe("", container=fc_tmp,horizontal=FALSE, expand=TRUE)
keyvariablerisktable = gtable(data.frame("risk.calculations"=c(""), "curr.count"=c(""),"orig.count"=c(""),
keyvariablerisktable = gtable(data.frame("number"=c(""), "risk.calculations"=c(""), "curr.count"=c(""),"orig.count"=c(""),
"curr.pct"=c(""),"orig.pct"=c(""),stringsAsFactors=FALSE), container=tmp, width=280, height=250, expand=TRUE)
keyvariableriskgraph = ggraphics(container=tmp, width=280, height=200)
keyvariableFreqGroup <- ggroup(container=tmp, width=280, height=250, expand=TRUE)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment