Skip to content

Commit

Permalink
lintr
Browse files Browse the repository at this point in the history
  • Loading branch information
mattansb committed Dec 7, 2024
1 parent 23351eb commit d02f048
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 92 deletions.
2 changes: 1 addition & 1 deletion R/convert_between_d_to_r.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ r_to_d <- function(r, n1, n2, ...) {
#' @rdname d_to_r
#' @export
oddsratio_to_d <- function(OR, p0, log = FALSE, ...) {
if (missing(p0)) {
if (missing(p0) || !is.numeric(p0)) {
# Use approximation
if (log) {
log_OR <- OR
Expand Down
8 changes: 4 additions & 4 deletions R/interpret_bf.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ interpret_bf <- function(bf,
interpretation[bf == 0] <- "no"

# interpret direction
dir <- interpret(bf, rules(0, c("against", "in favour of")))
dir[bf == 0] <- "against or in favour of"
direction <- interpret(bf, rules(0, c("against", "in favour of")))
direction[bf == 0] <- "against or in favour of"

# Format text
if (include_value) {
bf_fmt <- insight::format_bf(exp(bf), protect_ratio = protect_ratio, exact = exact)
interpretation[] <- sprintf("%s evidence (%s) %s", interpretation, bf_fmt, dir)
interpretation[] <- sprintf("%s evidence (%s) %s", interpretation, bf_fmt, direction)
} else {
interpretation[] <- paste0(interpretation, " evidence ", dir)
interpretation[] <- paste0(interpretation, " evidence ", direction)
}

interpretation[is.na(bf)] <- ""
Expand Down
8 changes: 7 additions & 1 deletion R/interpret_direction.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
#' @examples
#' interpret_direction(.02)
#' interpret_direction(c(.5, -.02))
#' interpret_direction(0)
#'
#' @keywords interpreters
#' @export
interpret_direction <- function(x) {
interpret(x, rules(0, c("negative", "positive"), name = "math", right = FALSE))
interpret(x, rules(0, c("negative", "positive"), name = "math", right = FALSE),
transform = function(.x) {
s <- sign(.x)
replace(s, s == 0, NA_real_)
}
)
}
4 changes: 2 additions & 2 deletions R/interpret_oddsratio.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' @param rules If `"cohen1988"` (default), `OR` is transformed to a
#' standardized difference (via [oddsratio_to_d()]) and interpreted according
#' to Cohen's rules (see [interpret_cohens_d()]; see Chen et al., 2010). If a
#' custom set of [rules()] is used, OR is interperted as is.
#' custom set of [rules()] is used, OR is interpreted as is.
#' @param log Are the provided values log odds ratio.
#' @inheritParams interpret
#' @inheritParams oddsratio_to_d
Expand Down Expand Up @@ -37,7 +37,7 @@
#'
#' @keywords interpreters
#' @export
interpret_oddsratio <- function(OR, rules = "cohen1988", p0, log = FALSE, ...) {
interpret_oddsratio <- function(OR, rules = "cohen1988", p0 = NULL, log = FALSE, ...) {
if (is.character(rules) && rules == "cohen1988") {
d <- oddsratio_to_d(OR, p0, log = log)
return(interpret_cohens_d(d, rules = rules))
Expand Down
2 changes: 1 addition & 1 deletion R/interpret_rope.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#'
#' @keywords interpreters
#' @export
interpret_rope <- function(rope, ci = 0.9, rules = "default") {
interpret_rope <- function(rope, rules = "default", ci = 0.9) {
if (ci < 1) {
e <- .Machine$double.eps

Expand Down
1 change: 1 addition & 0 deletions man/interpret_direction.Rd

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

4 changes: 2 additions & 2 deletions man/interpret_oddsratio.Rd

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

6 changes: 3 additions & 3 deletions man/interpret_rope.Rd

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

Loading

0 comments on commit d02f048

Please sign in to comment.