Fix parsepvalue(brackets = TRUE) having no effect - #47
Open
vertesy wants to merge 2 commits into
Open
Conversation
parsepvalue() computed the bracket-wrapped string with
`if (brackets) paste0("(", pv, ")") else pv`, but never assigned that
result anywhere; it was a bare expression statement, not the function's
last expression, so R discarded it. The function's actual return value
came only from the final `if (!isFALSE(prefix)) ... else pv` line,
which always operated on the un-bracketed `pv`.
Impact: every call to parsepvalue(..., brackets = TRUE) has always
silently ignored the brackets flag and returned the same string as
brackets = FALSE. E.g. parsepvalue(0.03, brackets = TRUE) returned
"p<=0.03" instead of the documented "(p<=0.03)".
Fix: assign the bracket-wrapping back to `pv` (`if (brackets) pv <-
paste0("(", pv, ")")`) so it actually participates in the returned
value, including when combined with `prefix`. Also documented the
`prefix` parameter, which R CMD check flagged as missing from the
roxygen block (undocumented arguments with a \usage entry are a WARNING).
Version bumped 1.2.1 -> 1.2.2 in Development/config.R and DESCRIPTION.
Validation: manually confirmed parsepvalue() now brackets correctly
alone and combined with `prefix`, ordinary (no-bracket) output is
unchanged. R CMD check and the existing testthat suite (7/7 passing)
were run on this branch; the undocumented-prefix WARNING is gone.
Remaining R CMD check findings (parFlags example error, %!in% Rd name
warning, sandbox locale warning) are pre-existing and out of scope,
addressed in other PRs in this batch or environment-inherent.
…ts-noop # Conflicts: # DESCRIPTION # Development/config.R
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
parsepvalue()computed the bracket-wrapped string withif (brackets) paste0("(", pv, ")") else pv, but never assigned that result anywhere — it was a bare expression statement, not the function's last expression, so R discarded it. The function's actual return value came only from the finalif (!isFALSE(prefix)) ... else pvline, which always operated on the un-bracketedpv.Why it happened
Classic R gotcha: only a function's last expression is its implicit return value. The bracket-wrapping
if/elsesat one statement too early to matter.Impact
Every call to
parsepvalue(..., brackets = TRUE)has always silently ignored thebracketsflag and returned the same string asbrackets = FALSE. E.g.parsepvalue(0.03, brackets = TRUE)returned"p<=0.03"instead of the documented"(p<=0.03)".Fix
Assign the bracket-wrapping back to
pv(if (brackets) pv <- paste0("(", pv, ")")) so it actually participates in the returned value, including when combined withprefix. Also documented theprefixparameter, which R CMD check flagged as missing from the roxygen block (undocumented arguments with a\usageentry are a WARNING).Version bumped 1.2.1 → 1.2.2 in
Development/config.RandDESCRIPTION.Validation
Manually confirmed
parsepvalue()now brackets correctly alone and combined withprefix; ordinary (no-bracket) output is unchanged. R CMD check and the existingtestthatsuite (7/7 passing) were run on this branch; the undocumented-prefix WARNING is gone. Remaining R CMD check findings (parFlagsexample error,%!in%Rd-name warning, sandbox locale warning) are pre-existing and out of scope, addressed in other PRs in this batch or environment-inherent.Generated by Claude Code