Skip to content

Commit

Permalink
format warning, add verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Jul 31, 2023
1 parent 838d427 commit 7eb81f3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
13 changes: 9 additions & 4 deletions R/convert_pd_to_p.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#' @param p A p-value.
#' @param direction What type of p-value is requested or provided. Can be
#' `"two-sided"` (default, two tailed) or `"one-sided"` (one tailed).
#' @param verbose Toggle off warnings.
#' @param ... Arguments passed to or from other methods.
#'
#' @details
Expand Down Expand Up @@ -33,17 +34,21 @@
#' pd_to_p(pd = 0.95, direction = "one-sided")
#'
#' @export
pd_to_p <- function(pd, direction = "two-sided", ...) {
pd_to_p <- function(pd, direction = "two-sided", verbose = TRUE, ...) {
p <- 1 - pd
if (.get_direction(direction) == 0) {
p <- 2 * p
}

less_than_0.5 <- pd < 0.5

Check warning on line 43 in R/convert_pd_to_p.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/convert_pd_to_p.R,line=43,col=3,[object_name_linter] Variable and function name style should match snake_case or symbols.
if (any(less_than_0.5)) {
insight::format_warning("pd values smaller than 0.5 detected.",
"pd-to-p conversion assumes a continious parameter space;",
"see help('p_direction') for more info.")
if (verbose) {
insight::format_warning(paste(
"pd values smaller than 0.5 detected.",
"pd-to-p conversion assumes a continious parameter space;",
"see help('p_direction') for more info."
))
}
p[less_than_0.5] <- 1
}

Expand Down
22 changes: 18 additions & 4 deletions man/p_direction.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/pd_to_p.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7eb81f3

Please sign in to comment.