diff --git a/R/doeAnalysis.R b/R/doeAnalysis.R index 76ff0e93..342dafaf 100644 --- a/R/doeAnalysis.R +++ b/R/doeAnalysis.R @@ -56,16 +56,16 @@ doeAnalysis <- function(jaspResults, dataset, options, ...) { if (options[["dependent"]] != "") { numericVars <- c(numericVars, options[["dependent"]]) } - if (length(options[["continuousFactors"]]) > 0 && options[["continuousFactors"]] != "") { + if (length(options[["continuousFactors"]]) > 0 && !identical(options[["continuousFactors"]], "")) { numericVars <- c(numericVars, unlist(options[["continuousFactors"]])) } - if (length(options[["fixedFactors"]]) > 0 && options[["fixedFactors"]] != "") { + if (length(options[["fixedFactors"]]) > 0 && !identical(options[["fixedFactors"]], "")) { factorVars <- c(factorVars, unlist(options[["fixedFactors"]])) } - if (options[["blocks"]] != "") { + if (length(options[["blocks"]]) > 0 && !identical(options[["blocks"]], "")) { factorVars <- c(factorVars, options[["blocks"]]) } - if (length(options[["covariates"]]) > 0 && options[["covariates"]] != "") { + if (length(options[["covariates"]]) > 0 && !identical(options[["covariates"]], "")) { numericVars <- c(numericVars, unlist(options[["covariates"]])) } dataset <- .readDataSetToEnd(columns.as.numeric = numericVars, columns.as.factor = factorVars) @@ -163,7 +163,7 @@ doeAnalysis <- function(jaspResults, dataset, options, ...) { "fullQuadratic" = paste0(options[["dependent"]], " ~ rsm::FO(", numPredString, ")", catPredString, " + rsm::TWI(", numPredString, ") + rsm::PQ(", numPredString, ")") ) } - if (options[["blocks"]] != "") { + if (length(options[["blocks"]]) > 0 && !identical(options[["blocks"]], "")) { formulaString <- paste0(formulaString, " + ", options[["blocks"]]) } formula <- as.formula(formulaString) diff --git a/R/msaGaugeRR.R b/R/msaGaugeRR.R index 9820bce0..d9d39b50 100644 --- a/R/msaGaugeRR.R +++ b/R/msaGaugeRR.R @@ -27,16 +27,19 @@ msaGaugeRR <- function(jaspResults, dataset, options, ...) { parts <- unlist(options$parts) operators <- unlist(options$operators) - + #ready statement - if (wideFormat && !options$Type3) - ready <- (length(measurements) != 0 && operators != "" && parts != "") - else if (options$Type3) - ready <- (measurements != "" && parts != "" & length(measurements) != 0) - else + if (wideFormat && !options[["Type3"]]) { + ready <- (length(measurements) > 1 && operators != "" && parts != "") + } else if (wideFormat && options[["Type3"]]) { + ready <- (length(measurements) > 1 && parts != "") + } else if (!wideFormat && !options[["Type3"]]) { ready <- (measurements != "" && operators != "" && parts != "") - - + } else if (!wideFormat && options[["Type3"]]) { + ready <- (measurements != "" && parts != "") + } + + numeric.vars <- measurements numeric.vars <- numeric.vars[numeric.vars != ""] factor.vars <- c(parts, operators) @@ -70,7 +73,7 @@ msaGaugeRR <- function(jaspResults, dataset, options, ...) { dataset <- dataset[order(dataset[[parts]]),] } - if(ready & !options$Type3){ + if(ready && !options$Type3){ crossed <- .checkIfCrossed(dataset, operators, parts, measurements) if(!crossed){ plot <- createJaspPlot(title = gettext("Gauge r&R"), width = 700, height = 400) diff --git a/R/msaGaugeRRnonrep.R b/R/msaGaugeRRnonrep.R index 2dbede0a..aed26b63 100644 --- a/R/msaGaugeRRnonrep.R +++ b/R/msaGaugeRRnonrep.R @@ -17,7 +17,7 @@ #' @export msaGaugeRRnonrep <- function(jaspResults, dataset, options, ...) { - + wideFormat <- options[["gaugeRRNonRepDataFormat"]] == "gaugeRRNonRepWideFormat" if(!wideFormat){ measurements <- unlist(options$measurements) @@ -62,7 +62,6 @@ msaGaugeRRnonrep <- function(jaspResults, dataset, options, ...) { longMeasurementCols <- "Measurement" } - # Report if (options[["anovaGaugeNestedReport"]] && ready) { if (is.null(jaspResults[["anovaGaugeNestedReport"]])) { @@ -374,7 +373,7 @@ msaGaugeRRnonrep <- function(jaspResults, dataset, options, ...) { } .reshapeToWide <- function(dataset, measurements, parts, operators) { - dataset <- dataset[order(dataset[parts]),] + dataset <- dataset[order(dataset[[parts]]),] index <- sequence(dplyr::count(dataset, dplyr::across(dplyr::all_of(c(parts, operators))))$n) dataset$index <- index dataset <- tidyr::spread(dataset, index, measurements) diff --git a/tests/testthat/_snaps/doeAnalysis/normal-probability-plot-of-residuals.svg b/tests/testthat/_snaps/doeAnalysis/normal-probability-plot-of-residuals.svg index 2a9c10fc..f4354954 100644 --- a/tests/testthat/_snaps/doeAnalysis/normal-probability-plot-of-residuals.svg +++ b/tests/testthat/_snaps/doeAnalysis/normal-probability-plot-of-residuals.svg @@ -32,7 +32,7 @@ - + @@ -40,7 +40,7 @@ - +