Skip to content

Commit

Permalink
updates to case_*() functions
Browse files Browse the repository at this point in the history
  • Loading branch information
IndrajeetPatil committed Sep 22, 2023
1 parent de77bdc commit 97dceba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions R/centrality_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ centrality_description <- function(data,
tr = 0.2,
k = 2L,
...) {
type <- stats_type_switch(type)

# styler: off
centrality <- case_when(
type == "parametric" ~ "mean",
type == "nonparametric" ~ "median",
type == "robust" ~ "trimmed",
type == "bayes" ~ "MAP"
centrality <- case_match(
stats_type_switch(type),
"parametric" ~ "mean",
"nonparametric" ~ "median",
"robust" ~ "trimmed",
"bayes" ~ "MAP"
)
# styler: on

Expand Down
4 changes: 2 additions & 2 deletions R/pairwise_comparisons.R
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ pairwise_comparisons <- function(data,
mutate(
expression = case_when(
p.adjust.method == "None" ~ glue("list(italic(p)[unadj.]=='{format_value(p.value, k)}')"),
TRUE ~ glue("list(italic(p)['{p.adjust.method}'-adj.]=='{format_value(p.value, k)}')")
.default = glue("list(italic(p)['{p.adjust.method}'-adj.]=='{format_value(p.value, k)}')")
)
)
}
Expand Down Expand Up @@ -296,6 +296,6 @@ p_adjust_text <- function(p.adjust.method) {
),
grepl("^BH|^f", p.adjust.method) ~ "FDR",
grepl("^BY", p.adjust.method) ~ "BY",
TRUE ~ "Holm"
.default = "Holm"
)
}
4 changes: 2 additions & 2 deletions R/tidy_model_expressions.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ tidy_model_expressions <- function(data,
df %<>% mutate(
expression = case_when(
df.error %in% c("NA", "Inf") ~ glue("list({es.text}=='{estimate}', italic(t)=='{statistic}', italic(p)=='{p.value}')"),
TRUE ~ glue("list({es.text}=='{estimate}', italic(t)('{df.error}')=='{statistic}', italic(p)=='{p.value}')")
.default = glue("list({es.text}=='{estimate}', italic(t)('{df.error}')=='{statistic}', italic(p)=='{p.value}')")
)
)
}
Expand Down Expand Up @@ -105,7 +105,7 @@ tidy_model_expressions <- function(data,
ungroup() %>% # convert from `expression` to `language`
mutate(expression = case_when(
is.na(unlist(expression)) ~ list(NULL),
TRUE ~ unlist(expression)
.default = unlist(expression)
)) %>%
.add_package_class()
}
Expand Down

0 comments on commit 97dceba

Please sign in to comment.