From 648c77ef5c0e3c3ca098bc77e2f0f5ffd8a60feb Mon Sep 17 00:00:00 2001 From: Don van den Bergh Date: Fri, 11 Oct 2024 10:01:01 +0200 Subject: [PATCH 1/4] fix logic for preloadData --- R/options.R | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/R/options.R b/R/options.R index 028ba73..b4c8d03 100644 --- a/R/options.R +++ b/R/options.R @@ -297,8 +297,22 @@ parsePreloadDataFromDescriptionQml <- function(analysisName) { description <- parseDescriptionQmlFromAnalysisName(analysisName) - preloadData <- isTRUE(description[["Description"]][["preloadData"]]) || isTRUE(description[[analysisName]][["preloadData"]]) - if (!preloadData) + # is the preloadData globally set to TRUE? + preloadDataGlobal <- isTRUE(description[["Description"]][["preloadData"]]) + # is the preloadData even set for this specific analysis? + specifiedPreloadData <- "preloadData" %in% names(description[[analysisName]]) + # is the preloadData set to TRUE for this specific analysis? + preloadDataAnalysis <- specifiedPreloadData && isTRUE(description[[analysisName]][["preloadData"]]) + # preloadData if set to TRUE for the analysis or if set globally to TRUE and not set for the analysis + preloadData <- preloadDataAnalysis || (preloadDataGlobal && !specifiedPreloadData) + + # global analysis -> result warning + # preloadData TRUE TRUE -> TRUE + # TRUE FALSE -> FALSE + # FALSE TRUE -> TRUE + # FALSE FALSE -> FALSE + + if (!preloadData && !specifiedPreloadData) lifecycle::deprecate_warn( when = "0.19.2", what = I(sprintf("The analysis `%s` does not preload data. Please update inst/Description.qml, add `preloadData: true`, and fix any minor issues.", analysisName)) From e895a8366cc138c3a060bef3f1fe0004e149c89b Mon Sep 17 00:00:00 2001 From: Don van den Bergh Date: Fri, 11 Oct 2024 10:03:59 +0200 Subject: [PATCH 2/4] cleanup --- R/options.R | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/R/options.R b/R/options.R index b4c8d03..56d02d2 100644 --- a/R/options.R +++ b/R/options.R @@ -297,21 +297,16 @@ parsePreloadDataFromDescriptionQml <- function(analysisName) { description <- parseDescriptionQmlFromAnalysisName(analysisName) - # is the preloadData globally set to TRUE? + # is preloadData globally set to TRUE? preloadDataGlobal <- isTRUE(description[["Description"]][["preloadData"]]) - # is the preloadData even set for this specific analysis? + # is preloadData even set for this specific analysis? specifiedPreloadData <- "preloadData" %in% names(description[[analysisName]]) - # is the preloadData set to TRUE for this specific analysis? + # is preloadData set to TRUE for this specific analysis? preloadDataAnalysis <- specifiedPreloadData && isTRUE(description[[analysisName]][["preloadData"]]) - # preloadData if set to TRUE for the analysis or if set globally to TRUE and not set for the analysis + # if preloadData set to TRUE for the analysis, or if set globally to TRUE and not set for the analysis preloadData <- preloadDataAnalysis || (preloadDataGlobal && !specifiedPreloadData) - # global analysis -> result warning - # preloadData TRUE TRUE -> TRUE - # TRUE FALSE -> FALSE - # FALSE TRUE -> TRUE - # FALSE FALSE -> FALSE - + # show a warning but only if the preloadData is not set for the analysis if (!preloadData && !specifiedPreloadData) lifecycle::deprecate_warn( when = "0.19.2", From 571a7e07b739e8d2ab5a25e0c5112c0da9804e28 Mon Sep 17 00:00:00 2001 From: Don van den Bergh Date: Mon, 14 Oct 2024 11:28:42 +0200 Subject: [PATCH 3/4] fixes for empty dataset --- R/dataset.R | 7 ++++++- R/run.R | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/R/dataset.R b/R/dataset.R index cef3c9c..f82392b 100644 --- a/R/dataset.R +++ b/R/dataset.R @@ -2,7 +2,7 @@ loadCorrectDataset <- function(x) { if (is.matrix(x) || is.data.frame(x)) { return(x) } else if (is.character(x)) { - if (! endsWith(x, ".csv")) { + if (!endsWith(x, ".csv")) { x <- paste0(x, ".csv") } @@ -50,6 +50,11 @@ findAllColumnNamesInOptions <- function(options, allColumnNames) { preloadDataset <- function(datasetPathOrObject, options) { + if (is.null(datasetPathOrObject)) { + .setInternal("preloadedDataset", data.frame()) + return() + } + dataset <- loadCorrectDataset(datasetPathOrObject) # repair any names like "", which cause false positives in findAllColumnNamesAndTypes diff --git a/R/run.R b/R/run.R index 6bac20a..98ba738 100644 --- a/R/run.R +++ b/R/run.R @@ -54,7 +54,7 @@ #' #' #' @export runAnalysis -runAnalysis <- function(name, dataset, options, view = TRUE, quiet = FALSE, makeTests = FALSE) { +runAnalysis <- function(name, dataset = NULL, options, view = TRUE, quiet = FALSE, makeTests = FALSE) { if (is.list(options) && is.null(names(options)) && any(names(unlist(lapply(options, attributes))) == "analysisName")) stop("The provided list of options is not named. Did you mean to index in the options list (e.g., options[[1]])?") From 48c562a02501f88c91867f1f36684226894b21a1 Mon Sep 17 00:00:00 2001 From: Don van den Bergh Date: Mon, 14 Oct 2024 11:29:17 +0200 Subject: [PATCH 4/4] rename rstudio project to match package name --- JASPTools.Rproj => jaspTools.Rproj | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename JASPTools.Rproj => jaspTools.Rproj (100%) diff --git a/JASPTools.Rproj b/jaspTools.Rproj similarity index 100% rename from JASPTools.Rproj rename to jaspTools.Rproj