Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Nov 6, 2024
1 parent d0d241c commit c6ef41c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
14 changes: 11 additions & 3 deletions R/format_bf.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,22 @@ format_bf <- function(bf,
)
)

## Add stars
bf_text <- ifelse(bf_orig < (1 / 30), paste0(bf_text, paste(rep_len(inferiority_star, 3), collapse = "")), # nolint
## Add inferiority stars
if (!is.null(inferiority_star)) {
bf_text <- ifelse(bf_orig < (1 / 30), paste0(bf_text, paste(rep_len(inferiority_star, 3), collapse = "")), # nolint
ifelse(bf_orig < 0.1, paste0(bf_text, paste(rep_len(inferiority_star, 2), collapse = "")), # nolint
ifelse(bf_orig < (1 / 3), paste0(bf_text, inferiority_star), bf_text) # nolint
)
)
}

out <- .add_prefix_and_remove_stars(p_text = bf_text, stars, stars_only, name, inferiority_star)
out <- .add_prefix_and_remove_stars(
p_text = bf_text,
stars = stars,
stars_only = stars_only,
name = name,
inferiority_star = inferiority_star
)
if (is.na(na_reference)) out[bad_bf] <- ""
out
}
10 changes: 8 additions & 2 deletions R/format_p.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,16 @@ format_p <- function(p,
}

if (stars_only) {
p_text <- gsub(paste0("[^(\\*|", inferiority_star, ")]"), "", p_text)
if (is.null(inferiority_star)) {
p_text <- gsub(paste0("[^(\\*)]"), "", p_text)
} else {
p_text <- gsub(paste0("[^(\\*|", inferiority_star, ")]"), "", p_text)
}
} else if (!stars) {
p_text <- gsub("*", "", p_text, fixed = TRUE)
p_text <- gsub(inferiority_star, "", p_text, fixed = TRUE)
if (!is.null(inferiority_star)) {
p_text <- gsub(inferiority_star, "", p_text, fixed = TRUE)
}
}

# replace missing with related string
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-format.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ test_that("format others", {
format_bf(c(0.000045, 0.233, NA, 1557, 3.54), stars = TRUE),
c("BF < 0.001°°°", "BF = 0.233°", "", "BF > 1000***", "BF = 3.54*")
)
expect_identical(
format_bf(c(0.000045, 0.233, NA, 1557, 3.54), stars = TRUE, inferiority_star = NULL),
c("BF < 0.001", "BF = 0.233", "", "BF > 1000***", "BF = 3.54*")
)
expect_identical(
format_bf(c(0.000045, 0.233, NA, 1557, 3.54), stars = TRUE, stars_only = TRUE),
c("°°°", "°", "", "***", "*")
Expand Down

0 comments on commit c6ef41c

Please sign in to comment.