Skip to content

Commit

Permalink
Fix error due to coercion of vectors of length > 1 to logicals of len…
Browse files Browse the repository at this point in the history
  • Loading branch information
jansim authored Nov 26, 2024
1 parent 092b755 commit 1eb2164
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions R/commonPower.R
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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))) {
Expand All @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
Expand Down

0 comments on commit 1eb2164

Please sign in to comment.