Skip to content

Commit

Permalink
Fix unit tests under R4.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
JTPetter committed Sep 20, 2023
1 parent e87167e commit 4da56c1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
10 changes: 5 additions & 5 deletions R/doeAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
21 changes: 12 additions & 9 deletions R/msaGaugeRR.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions R/msaGaugeRRnonrep.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#' @export
msaGaugeRRnonrep <- function(jaspResults, dataset, options, ...) {

wideFormat <- options[["gaugeRRNonRepDataFormat"]] == "gaugeRRNonRepWideFormat"
if(!wideFormat){
measurements <- unlist(options$measurements)
Expand Down Expand Up @@ -62,7 +62,6 @@ msaGaugeRRnonrep <- function(jaspResults, dataset, options, ...) {
longMeasurementCols <- "Measurement"
}


# Report
if (options[["anovaGaugeNestedReport"]] && ready) {
if (is.null(jaspResults[["anovaGaugeNestedReport"]])) {
Expand Down Expand Up @@ -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)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 4da56c1

Please sign in to comment.