Skip to content

Commit 53472e5

Browse files
authored
Updating data ingest to support preloading data (#227)
* removing old data reading from binary classification, testing, and estimation analyses * Updating the unit tests to work with the data preloading Updating the reference table for six of the binary testing unit tests to fix the spurious failures introduced with #218
1 parent 7c70294 commit 53472e5

20 files changed

+528
-541
lines changed

R/LSbinaryclassification.R

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,19 @@ LSbinaryclassification <- function(jaspResults, dataset, options, state = NULL)
122122
.bcReadData <- function(jaspResults, dataset, options, ready) {
123123
if(options[["inputType"]] != "data" || !ready) return(NULL)
124124

125-
if(is.null(dataset)) {
126-
dataset <- .readDataSetToEnd(columns = c(options[["marker"]], options[["labels"]]))
127-
dataset <- dataset[complete.cases(dataset),]
128-
129-
labels <- dataset[[options[["labels"]]]]
130-
levels <- levels(as.factor(labels))
131-
if(length(levels) != 2) .quitAnalysis(gettext("The 'Positive condition (binary)' variable must have two levels!"))
132-
if(any(table(labels) < 1)) .quitAnalysis(gettext("Each condition needs at least one observation."))
133-
134-
dataset <- data.frame(
135-
marker = dataset[[options[["marker"]]]],
136-
condition = labels == levels[2], # second level is "positive" condition
137-
test = dataset[[options[["marker"]]]] >= options[["threshold"]]
138-
)
139-
}
125+
dataset <- dataset[c(options[["marker"]], options[["labels"]])]
126+
dataset <- dataset[complete.cases(dataset), ]
127+
128+
labels <- dataset[[options[["labels"]]]]
129+
levels <- levels(as.factor(labels))
130+
if(length(levels) != 2) .quitAnalysis(gettext("The 'Positive condition (binary)' variable must have two levels!"))
131+
if(any(table(labels) < 1)) .quitAnalysis(gettext("Each condition needs at least one observation."))
132+
133+
dataset <- data.frame(
134+
marker = dataset[[options[["marker"]]]],
135+
condition = labels == levels[2], # second level is "positive" condition
136+
test = dataset[[options[["marker"]]]] >= options[["threshold"]]
137+
)
140138

141139
if(mean(subset(dataset, condition)$marker) < mean(subset(dataset, !condition)$marker))
142140
.quitAnalysis(gettextf("Mean of marker in positive condition (%1$s) needs to be larger than the mean of marker in negative condition (%2$s).", levels[2], levels[1]))

R/LSbinomialcommon.R

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,7 @@
5757

5858
} else if (options[["dataInputType"]] == "variable") {
5959

60-
# this is stupidly written #rework
61-
if (!is.null(dataset)) {
62-
tempY <- dataset
63-
} else {
64-
tempY <- .readDataSetToEnd(columns = options[["dataVariableSelected"]])[,1]
65-
}
60+
tempY <- dataset[[ options[["dataVariableSelected"]] ]]
6661

6762
}
6863

R/LSgaussiancommon.R

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,7 @@
5050

5151
} else if (options[["dataInputType"]] == "variable") {
5252

53-
# this is stupidly written #rework
54-
if (!is.null(dataset)) {
55-
tempY <- dataset
56-
} else{
57-
tempY <- .readDataSetToEnd(columns = options[["dataVariableSelected"]])[,1]
58-
}
59-
53+
tempY <- dataset[[ options[["dataVariableSelected"]] ]]
6054
data$SD <- options[["dataVariableSd"]]
6155

6256
}

inst/Description.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Description
99
description: qsTr("Learn Bayesian statistics with simple examples and supporting text")
1010
version : "0.19.2"
1111
requiresData: false
12+
preloadData: true
1213
author: "JASP Team"
1314
maintainer: "JASP Team <info@jasp-stats.org>"
1415
website: "www.jasp-stats.org"

tests/testthat/_snaps/lsbinomialestimation/models-beta-vol1-3.svg

Lines changed: 60 additions & 60 deletions
Loading

tests/testthat/_snaps/lsbinomialestimation/models-beta-vol2-1.svg

Lines changed: 50 additions & 50 deletions
Loading

tests/testthat/_snaps/lsbinomialestimation/models-point-vol1-4.svg

Lines changed: 60 additions & 60 deletions
Loading

0 commit comments

Comments
 (0)