Skip to content

Commit

Permalink
Fix misstated items table
Browse files Browse the repository at this point in the history
  • Loading branch information
koenderks committed Feb 8, 2025
1 parent b9b8328 commit 2bdb9b6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 17 deletions.
50 changes: 38 additions & 12 deletions R/auditCommonFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -3006,15 +3006,29 @@
tb$position <- positionInContainer
tb$dependOn(options = "tableTaints")

if (options[["workflow"]]) {
binary <- options[["annotation"]] == "binary"
} else {
if (options[["values.audit"]] == "") {
binary <- FALSE
} else {
binary <- all(sample[[options[["values.audit"]]]] %in% c(0, 1))
}
}

tb$addColumnInfo(name = "id", title = gettext("ID"), type = "string")
tb$addColumnInfo(name = "values", title = gettext("Book value"), type = "number")
tb$addColumnInfo(name = "values.audit", title = gettext("Audit value"), type = "number")
tb$addColumnInfo(name = "diff", title = gettext("Difference"), type = "number")
if (options[["values"]] != "") {
tb$addColumnInfo(name = "values", title = gettext("Book value"), type = "number")
}
if (!binary) {
tb$addColumnInfo(name = "values.audit", title = gettext("Audit value"), type = "number")
tb$addColumnInfo(name = "diff", title = gettext("Difference"), type = "number")
}
tb$addColumnInfo(name = "taint", title = gettext("Taint"), type = "number")
tb$addColumnInfo(name = "times", title = gettext("Counted"), type = "string")
parentContainer[["tableTaints"]] <- tb

if (options[["values.audit"]] == "" || options[["values"]] == "") {
if (options[["values.audit"]] == "") {
return()
}

Expand All @@ -3023,15 +3037,16 @@
sample <- rbind(sample, subset(dataset, dataset[[options[["critical_name"]]]] != 0))
}

errors <- sample[sample[[options[["values"]]]] != sample[[options[["values.audit"]]]], ]
if (!binary) {
errors <- sample[sample[[options[["values"]]]] != sample[[options[["values.audit"]]]], ]
} else {
errors <- sample[sample[[options[["values.audit"]]]] == 1, ]
}
if (nrow(errors) == 0) {
tb$addFootnote(message = gettext("No misstatements were identified in the sample."))
return()
}

id <- errors[[options[["id"]]]]
ist <- errors[[options[["values"]]]]
soll <- errors[[options[["values.audit"]]]]
if (options[["workflow"]]) {
times <- errors[[options[["indicator_col"]]]]
} else {
Expand All @@ -3041,11 +3056,22 @@
times <- errors[[options[["times"]]]]
}
}

id <- errors[[options[["id"]]]]
tb[["id"]] <- c(id, gettext("Total"))
tb[["values"]] <- c(ist, NA)
tb[["values.audit"]] <- c(soll, NA)
tb[["diff"]] <- c(ist - soll, sum(ist - soll))
tb[["taint"]] <- c((ist - soll) / ist, sum(((ist - soll) / ist) * times))
if (options[["values"]] != "") {
ist <- errors[[options[["values"]]]]
tb[["values"]] <- c(ist, NA)
}
if (!binary) {
soll <- errors[[options[["values.audit"]]]]
tb[["values.audit"]] <- c(soll, NA)
tb[["diff"]] <- c(ist - soll, sum(ist - soll))
tb[["taint"]] <- c((ist - soll) / ist, sum(((ist - soll) / ist) * times))
} else {
taints <- errors[[options[["values.audit"]]]]
tb[["taint"]] <- c(taints, sum(taints * times))
}
tb[["times"]] <- c(paste0("x", times), NA)
}

Expand Down
2 changes: 1 addition & 1 deletion inst/qml/auditBayesianEvaluation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Form
Evaluation.EvaluationOutput
{
bayesian: true
enable_taints: !data.use_stats && variables.use_book && variables.use_real
enable_taints: !data.use_stats
enable_corrections: population.n_units > 0 || data.use_population
enable_assumptions: algorithm.use_partial
enable_objectives: objectives.use_materiality || objectives.use_precision
Expand Down
1 change: 0 additions & 1 deletion inst/qml/auditBayesianWorkflow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,6 @@ Form
Evaluation.EvaluationOutput
{
bayesian: true
enable_taints: values.use_book
enable_corrections: values.use_book
enable_assumptions: algorithm.use_partial
enable_objectives: objectives.use_materiality || objectives.use_precision
Expand Down
2 changes: 1 addition & 1 deletion inst/qml/auditClassicalEvaluation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Form
Evaluation.EvaluationOutput
{
bayesian: false
enable_taints: !data.use_stats && variables.use_book && variables.use_real
enable_taints: !data.use_stats
enable_corrections: population.n_units > 0 || data.use_population
enable_objectives: objectives.use_materiality || objectives.use_precision
enable_scatter: !data.use_stats
Expand Down
1 change: 0 additions & 1 deletion inst/qml/auditClassicalWorkflow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,6 @@ Form
Evaluation.EvaluationOutput
{
bayesian: false
enable_taints: values.use_book
enable_corrections: values.use_book
enable_objectives: objectives.use_materiality || objectives.use_precision
enable_scatter: annotation.use_values
Expand Down
2 changes: 1 addition & 1 deletion inst/qml/common/evaluation/EvaluationOutput.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import JASP.Controls
Group
{
property bool bayesian: false
property bool enable_taints: false
property bool enable_taints: true
property bool enable_corrections: false
property bool enable_assumptions: false
property bool enable_predictive: false
Expand Down

0 comments on commit 2bdb9b6

Please sign in to comment.