Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fig_height_h_barchart moved from base to contents and rm redundant checks #45

Merged
merged 1 commit into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(draft_report)
export(fig_height_h_barchart)
export(filename_sanitizer)
export(get_chunk_template_defaults)
export(get_raw_labels)
Expand Down
104 changes: 0 additions & 104 deletions R/checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,6 @@ err_msg <- function(infix) {
", not {.obj_type_friendly {x}}.")
}

check_bool <- function(x, call = rlang::caller_env(),
arg = rlang::caller_arg(x)) {
if(!(is.logical(x) && length(x) == 1 && !is.na(x)) || is.na(x)) {
cli::cli_abort(err_msg(" logical of length 1"),
call = call)
}
}

check_pval <- function(x, n = 1,
call = rlang::caller_env(),
arg = rlang::caller_arg(x)) {
if(!(rlang::is_double(x = x, n = n, finite = TRUE) &&
all(x >= 0) && all(x <= 1))) {
cli::cli_abort(err_msg(" numeric between 0 and 1"))
}
}


check_integerish <- function(x, min=-Inf, max=Inf,
null_allowed = FALSE,
call = rlang::caller_env(),
arg = rlang::caller_arg(x)) {
if(isTRUE(null_allowed) && is.null(x)) return()
pos_str <- if(min==0) " positive" else "n"
max_str <- if(!max==Inf) stringi::stri_c(ignore_null=TRUE, " (max=", max, ")") else ""
if(!rlang::is_integerish(x, n = 1) || x > max || x < min) {
cli::cli_abort(err_msg("{pos_str} integer of length 1{max_str}"),
call = call)
}
}

check_double <- function(x, min=-Inf, max=Inf, null_allowed = FALSE,
call = rlang::caller_env(),
arg = rlang::caller_arg(x)) {
if(isTRUE(null_allowed) && is.null(x)) return()
pos_str <- if(min==0) " positive" else ""
max_str <- if(!max==Inf) stringi::stri_c(ignore_null=TRUE, " (max=", max, ")") else ""
min_str <- if(!min==-Inf) stringi::stri_c(ignore_null=TRUE, " (min=", min, ")") else ""
if(!rlang::is_double(x, n = 1) || x < min || x > max) {
cli::cli_abort(err_msg("{pos_str} numeric of length 1{max_str}{min_str}"),
call = call)
}
}

#' Is x A String?
#'
Expand Down Expand Up @@ -80,28 +37,6 @@ check_string <- function(x, null.ok = FALSE, n = 1,



check_list <- function(x,
null.ok = TRUE,
n = NULL,
call = rlang::caller_env(),
arg = rlang::caller_arg(x)) {
msg_suffix <- err_msg(stringi::stri_c(ignore_null=TRUE, " list",
if(!is.null(n)) " of length ",
if(!is.null(n)) n))
if(is.null(x)) {
if(!null.ok) {
cli::cli_abort(message = msg_suffix, call = call)
}
} else if (!rlang::is_list(x, n = n)) {
msg_prefix <- if(null.ok) "If not NULL, " else ""
msg <- stringi::stri_c(ignore_null=TRUE, msg_prefix, msg_suffix)
cli::cli_abort(message = msg, call = call)
}
}




check_data_frame <- function(x, n=NULL, call = rlang::caller_env(),
arg = rlang::caller_arg(x)) {
if(!inherits(x, "data.frame")) {
Expand All @@ -113,42 +48,3 @@ check_data_frame <- function(x, n=NULL, call = rlang::caller_env(),
}
}

check_summary_data_cols <- function(x, call = rlang::caller_env(),
arg = rlang::caller_arg(x)) {
missing_cols <-
.saros.env$summary_data_sort2[
!.saros.env$summary_data_sort2 %in% colnames(x)]
if(length(missing_cols)>0) {
cli::cli_abort(c("{.arg {arg}} is missing columns {.var {missing_cols}}."),
call = call)
}
}


check_multiple_dep_and_one_indep <-
function(data, dep, indep,
call = rlang::caller_env()) {

dep_call <- rlang::expr_deparse(rlang::enquo(dep))
indep_call <- rlang::expr_deparse(rlang::enquo(indep))

if((ncol(dplyr::select(.data = data, {{dep}})) > 1L &&
ncol(dplyr::select(.data = data, {{indep}})) >= 1L)) {
cli::cli_abort(c("Multiple columns for {.arg dep} and {.arg indep} are not allowed.",
i="You provided dep = {dep_call} and indep = {indep_call}"),
call = call)
}
}







check_existing_path <-
function(x, call = rlang::caller_env()) {
if(!fs::is_file(x, follow = TRUE)) {
cli::cli_abort("{.arg {x}} is not an existing file path.")
}
}
206 changes: 0 additions & 206 deletions R/fig_height_h_barchart.R

This file was deleted.

2 changes: 1 addition & 1 deletion R/remove_from_chapter_structure_if_n_below.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ remove_from_chapter_structure_if_n_below <-
if(is.null(chapter_structure[[n_variable_name]])) {
cli::cli_abort("{.arg n_variable_name} does not exist in {.arg chapter_structure}: {.arg {n_variable_name}}.")
}
check_integerish(hide_chunk_if_n_below)

vctrs::vec_slice(chapter_structure,
is.na(as.character(chapter_structure[[".variable_name_dep"]])) | # Introduction chapter or ..
(!is.na(chapter_structure[[n_variable_name]]) &
Expand Down
2 changes: 0 additions & 2 deletions R/remove_from_chapter_structure_if_non_significant.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ remove_from_chapter_structure_if_non_significant <-

check_data_frame(chapter_structure)
check_data_frame(data)
check_double(hide_bi_entry_if_sig_above, min = 0, max = 1, call = call)
check_string(always_show_bi_for_indep, null.ok = TRUE, n = NULL, call = call)

chapter_structure$.bi_test <- NA_character_
chapter_structure$.p_value <- NA_real_
Expand Down
Loading
Loading