From 1eb216427e28ad4686e7ca76680b1223d7a4b255 Mon Sep 17 00:00:00 2001 From: Jan Simson Date: Tue, 26 Nov 2024 11:04:14 +0100 Subject: [PATCH] Fix error due to coercion of vectors of length > 1 to logicals of length 1 (jasp-stats/jasp-test-release#2754) (#52) --- R/commonPower.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/commonPower.R b/R/commonPower.R index f0b63eb..72fac2c 100644 --- a/R/commonPower.R +++ b/R/commonPower.R @@ -212,7 +212,7 @@ if (sum(sapply(list(p, n, power, sig.level), is.null)) != 1) { stop("exactly one of p, n, power, and sig.level must be NULL") } - if (!is.null(n) && n < 2) { + if (any(!is.null(n) & n < 2)) { stop("number of observations in the first group must be at least 2") } if (!is.null(sig.level) && (!is.numeric(sig.level) || any(0 > sig.level | sig.level > 1))) { @@ -292,7 +292,7 @@ stop("exactly one of p1, n, n.ratio, power, and sig.level must be NULL") } - if (!is.null(n) && n < 2) { + if (any(!is.null(n) & n < 2)) { stop("number of observations in the first group must be at least 2") } if (!is.null(n.ratio) && n.ratio <= 0) { @@ -383,7 +383,7 @@ stop("exactly one of rho, n, power, and sig.level must be NULL") } - if (!is.null(n) && n < 2) { + if (any(!is.null(n) & n < 2)) { stop("number of observations in the first group must be at least 2") } if (!is.null(sig.level) && (!is.numeric(sig.level) || any(0 > sig.level | sig.level > 1))) { @@ -392,7 +392,7 @@ if (!is.null(power) && (!is.numeric(power) || any(0 > power | power > 1))) { stop("power must be between 0 and 1") } - if (!is.null(rho) && 0 > rho) { + if (any(!is.null(rho) & 0 > rho)) { stop("rho must be positive") } alternative <- match.arg(alternative) @@ -470,7 +470,7 @@ stop("exactly one of rho, n, n.ratio, power, and sig.level must be NULL") } - if (!is.null(n) && n < 2) { + if (any(!is.null(n) & n < 2)) { stop("number of observations in the first group must be at least 2") } if (!is.null(n.ratio) && n.ratio <= 0) { @@ -482,7 +482,7 @@ if (!is.null(power) && (!is.numeric(power) || any(0 > power | power > 1))) { stop("power must be between 0 and 1") } - if (!is.null(rho) && 0 > rho) { + if (any(!is.null(rho) & 0 > rho)) { stop("rho must be positive") } alternative <- match.arg(alternative)