diff --git a/NAMESPACE b/NAMESPACE index fdcd658..04debc4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/checks.R b/R/checks.R index f116c32..54fdf24 100644 --- a/R/checks.R +++ b/R/checks.R @@ -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? #' @@ -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")) { @@ -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.") - } - } diff --git a/R/fig_height_h_barchart.R b/R/fig_height_h_barchart.R deleted file mode 100644 index 6043ebe..0000000 --- a/R/fig_height_h_barchart.R +++ /dev/null @@ -1,206 +0,0 @@ -#' Estimate figure height for a horizontal barchart -#' -#' This function estimates the height of a figure for a horizontal barchart based on several parameters including the number of dependent and independent variables, number of categories, maximum characters in the labels, and legend properties. -#' -#' @param n_y Integer. Number of dependent variables. -#' @param n_cats_y Integer. Number of categories across the dependent variables. -#' @param max_chars_y Integer. Maximum number of characters across the dependent variables. -#' @param n_x Integer. Number of independent variables. -#' @param n_cats_x Integer. Number of categories across the independent variables. -#' @param max_chars_x Integer. Maximum number of characters across the independent variables. -#' @param freq Logical. If TRUE, frequency plot with categories next to each other. If FALSE (default), proportion plot with stacked categories. -#' @param x_axis_label_width Numeric. Width allocated for x-axis labels. -#' @param strip_angle Integer. Angle of the strip text. -#' @param main_font_size Numeric. Font size for the main text. -#' @param legend_location Character. Location of the legend ("panel" or "plot"). -#' @param n_legend_lines Integer. Number of lines in the legend. -#' @param legend_key_chars_equivalence Integer. Approximate number of characters the legend key equals. -#' @param max_chars_per_figure_width Integer. Maximum number of characters per figure width. -#' @param multiplier_per_horizontal_line Numeric. Multiplier per horizontal line. -#' @param multiplier_per_vertical_letter Numeric. Multiplier per vertical letter. -#' @param multiplier_per_facet Numeric. Multiplier per facet. -#' @param multiplier_per_legend_line Numeric. Multiplier per legend line. -#' @param fixed_constant Numeric. Fixed constant to be added to the height. -#' @param figure_width_in_cm Numeric. Width of the figure in centimeters. -#' @param margin_in_cm Numeric. Margin in centimeters. -#' @param max Numeric. Maximum height. -#' @param min Numeric. Minimum height. -#' -#' @return Numeric value representing the estimated height of the figure. -#' @export -#' -#' @examples -#' fig_height_h_barchart(n_y = 5, -#' n_cats_y = 3, -#' max_chars_y = 10, -#' n_x = 2, -#' n_cats_x = 4, -#' max_chars_x = 12, -#' freq = FALSE, -#' x_axis_label_width = 20, -#' strip_angle = 0, -#' main_font_size = 8, -#' legend_location = "panel", -#' n_legend_lines = 2, -#' legend_key_chars_equivalence = 5, -#' max_chars_per_figure_width = 100, -#' multiplier_per_horizontal_line = NULL, -#' multiplier_per_vertical_letter = .15, -#' multiplier_per_facet = .95, -#' multiplier_per_legend_line = 1.5, -#' fixed_constant = 0, -#' figure_width_in_cm = 16, -#' margin_in_cm = 0, -#' max = 8, -#' min = 1) -fig_height_h_barchart <- # Returns a numeric value - function(n_y, - n_cats_y, - max_chars_y = NULL, - n_x = NULL, - n_cats_x = NULL, - max_chars_x = NULL, - freq = FALSE, - x_axis_label_width = 20, - strip_angle = 0, - main_font_size = 8, - legend_location = c("panel", "plot"), - n_legend_lines = 2, - legend_key_chars_equivalence = 5, - max_chars_per_figure_width = 100, - multiplier_per_horizontal_line = NULL, - multiplier_per_vertical_letter = .15, - multiplier_per_facet = .95, - multiplier_per_legend_line = 1.5, - fixed_constant = 0, - figure_width_in_cm = 16, - margin_in_cm = 0, - max = 8, - min = 1) { - - check_integerish(n_y) - check_integerish(n_cats_y) - check_integerish(max_chars_y) - check_integerish(n_x, null_allowed=TRUE) - check_integerish(n_cats_x, null_allowed=TRUE) - check_integerish(max_chars_x, null_allowed=TRUE) - check_bool(freq) - check_double(strip_angle) - check_double(main_font_size) - check_double(multiplier_per_horizontal_line, null_allowed=TRUE) - check_double(multiplier_per_vertical_letter) - check_double(multiplier_per_legend_line) - check_integerish(legend_key_chars_equivalence) - check_integerish(max_chars_per_figure_width) - - check_integerish(n_legend_lines, null_allowed= TRUE) - check_integerish(fixed_constant) - check_integerish(margin_in_cm) - check_integerish(figure_width_in_cm) - check_integerish(strip_angle) - check_integerish(max) - check_integerish(min) - legend_location <- rlang::arg_match(legend_location, multiple = FALSE) - - if(is.null(multiplier_per_horizontal_line)) { - multiplier_per_horizontal_line <- main_font_size/72.27 - } - - get_max_lines <- function(max_cat_char, width) { - ceiling(max_cat_char / width) - } - - # Function to estimate the number of categories that can fit on one line of a legend - estimate_categories_per_line <- function(figure_width_cm = 12, - max_chars_cats = 20, # Maximum characters across the categories - font_size = 8, - legend_key_chars = 5, - margin_cm = 0) { - # Calculate the width of one character in cm, assuming a monospace font approximation - char_width_cm <- font_size * 0.035 - - # Estimate the width per category in cm - width_per_category_cm <- (legend_key_chars + max_chars_cats) * char_width_cm - - # Calculate the total available width for the legend in cm - available_width_cm <- figure_width_cm - margin_cm * 2 - - # Calculate the number of categories that can fit in one line - categories_per_line <- available_width_cm / width_per_category_cm - - # Return the estimated number of categories per line - floor(categories_per_line) - } - - calculate_height <- function(strip_height, - x_axis_height, - n_facets = 1, - n_legend_lines, - multiplier_per_facet, - multiplier_per_legend_line, - fixed_constant) { - - max(c(strip_height, x_axis_height), na.rm=TRUE) * n_facets * multiplier_per_facet + - n_legend_lines * multiplier_per_legend_line + - fixed_constant - } - - if(is.null(n_legend_lines)) { - categories_per_line <- - estimate_categories_per_line(figure_width_cm = figure_width_in_cm, - max_chars_cats = max_chars_y, # Maximum characters across the categories - font_size = main_font_size, - legend_key_chars = legend_key_chars_equivalence, - margin_cm = margin_in_cm) - n_legend_lines <- ceiling(n_y / categories_per_line) - } - - - - max_lines_y <- get_max_lines(max_cat_char = max_chars_y, - width = x_axis_label_width) - if(n_cats_y==0) unique_y_cats <- 1 - - if(isFALSE(freq)) { - n_cats_y <- 1 - } - - - - if(!is.null(n_x) && n_x > 0) { - - max_lines_x <- get_max_lines(max_cat_char = max_chars_x, - width = x_axis_label_width) - - x_axis_height <- - max(c(max_lines_x, n_cats_y), na.rm=TRUE) * multiplier_per_horizontal_line * n_cats_x - n_facets <- n_y - - if (strip_angle >= 45 && strip_angle <= 135) { # vertical strip - strip_height <- - max_chars_y * multiplier_per_vertical_letter - - } else { # horizontal strip - strip_height <- - max_lines_y * multiplier_per_horizontal_line - } - - } else { # Univariates - x_axis_height <- - max(c(max_lines_y, n_cats_y), na.rm=TRUE) * - multiplier_per_horizontal_line * n_y - strip_height <- NA_real_ - n_facets <- 1 - - } - estimate <- calculate_height(strip_height = strip_height, - x_axis_height = x_axis_height, - n_facets = n_facets, - n_legend_lines = n_legend_lines, - multiplier_per_facet = multiplier_per_facet, - multiplier_per_legend_line = multiplier_per_legend_line, - fixed_constant = fixed_constant) - plot_height <- max(c(min(c(estimate, max)), min)) - round(plot_height, digits=2) - } - diff --git a/R/remove_from_chapter_structure_if_n_below.R b/R/remove_from_chapter_structure_if_n_below.R index 5663a93..2bd6fb3 100644 --- a/R/remove_from_chapter_structure_if_n_below.R +++ b/R/remove_from_chapter_structure_if_n_below.R @@ -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]]) & diff --git a/R/remove_from_chapter_structure_if_non_significant.R b/R/remove_from_chapter_structure_if_non_significant.R index 207aaf0..051ed06 100644 --- a/R/remove_from_chapter_structure_if_non_significant.R +++ b/R/remove_from_chapter_structure_if_non_significant.R @@ -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_ diff --git a/man/fig_height_h_barchart.Rd b/man/fig_height_h_barchart.Rd deleted file mode 100644 index 33a6e8e..0000000 --- a/man/fig_height_h_barchart.Rd +++ /dev/null @@ -1,110 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/fig_height_h_barchart.R -\name{fig_height_h_barchart} -\alias{fig_height_h_barchart} -\title{Estimate figure height for a horizontal barchart} -\usage{ -fig_height_h_barchart( - n_y, - n_cats_y, - max_chars_y = NULL, - n_x = NULL, - n_cats_x = NULL, - max_chars_x = NULL, - freq = FALSE, - x_axis_label_width = 20, - strip_angle = 0, - main_font_size = 8, - legend_location = c("panel", "plot"), - n_legend_lines = 2, - legend_key_chars_equivalence = 5, - max_chars_per_figure_width = 100, - multiplier_per_horizontal_line = NULL, - multiplier_per_vertical_letter = 0.15, - multiplier_per_facet = 0.95, - multiplier_per_legend_line = 1.5, - fixed_constant = 0, - figure_width_in_cm = 16, - margin_in_cm = 0, - max = 8, - min = 1 -) -} -\arguments{ -\item{n_y}{Integer. Number of dependent variables.} - -\item{n_cats_y}{Integer. Number of categories across the dependent variables.} - -\item{max_chars_y}{Integer. Maximum number of characters across the dependent variables.} - -\item{n_x}{Integer. Number of independent variables.} - -\item{n_cats_x}{Integer. Number of categories across the independent variables.} - -\item{max_chars_x}{Integer. Maximum number of characters across the independent variables.} - -\item{freq}{Logical. If TRUE, frequency plot with categories next to each other. If FALSE (default), proportion plot with stacked categories.} - -\item{x_axis_label_width}{Numeric. Width allocated for x-axis labels.} - -\item{strip_angle}{Integer. Angle of the strip text.} - -\item{main_font_size}{Numeric. Font size for the main text.} - -\item{legend_location}{Character. Location of the legend ("panel" or "plot").} - -\item{n_legend_lines}{Integer. Number of lines in the legend.} - -\item{legend_key_chars_equivalence}{Integer. Approximate number of characters the legend key equals.} - -\item{max_chars_per_figure_width}{Integer. Maximum number of characters per figure width.} - -\item{multiplier_per_horizontal_line}{Numeric. Multiplier per horizontal line.} - -\item{multiplier_per_vertical_letter}{Numeric. Multiplier per vertical letter.} - -\item{multiplier_per_facet}{Numeric. Multiplier per facet.} - -\item{multiplier_per_legend_line}{Numeric. Multiplier per legend line.} - -\item{fixed_constant}{Numeric. Fixed constant to be added to the height.} - -\item{figure_width_in_cm}{Numeric. Width of the figure in centimeters.} - -\item{margin_in_cm}{Numeric. Margin in centimeters.} - -\item{max}{Numeric. Maximum height.} - -\item{min}{Numeric. Minimum height.} -} -\value{ -Numeric value representing the estimated height of the figure. -} -\description{ -This function estimates the height of a figure for a horizontal barchart based on several parameters including the number of dependent and independent variables, number of categories, maximum characters in the labels, and legend properties. -} -\examples{ -fig_height_h_barchart(n_y = 5, - n_cats_y = 3, - max_chars_y = 10, - n_x = 2, - n_cats_x = 4, - max_chars_x = 12, - freq = FALSE, - x_axis_label_width = 20, - strip_angle = 0, - main_font_size = 8, - legend_location = "panel", - n_legend_lines = 2, - legend_key_chars_equivalence = 5, - max_chars_per_figure_width = 100, - multiplier_per_horizontal_line = NULL, - multiplier_per_vertical_letter = .15, - multiplier_per_facet = .95, - multiplier_per_legend_line = 1.5, - fixed_constant = 0, - figure_width_in_cm = 16, - margin_in_cm = 0, - max = 8, - min = 1) -} diff --git a/tests/testthat/test-checks.R b/tests/testthat/test-checks.R index e28a65b..3f2d15c 100644 --- a/tests/testthat/test-checks.R +++ b/tests/testthat/test-checks.R @@ -1,68 +1,3 @@ -testthat::test_that("check_bool", { - test_arg <- "d" - testthat::expect_error( - object = saros.base:::check_bool(test_arg), - regexp = "`test_arg` must be a logical of length 1, not a string" - ) - test_arg <- TRUE - testthat::expect_no_error( - object = saros.base:::check_bool(test_arg)) -}) - -testthat::test_that("check_integerish", { - - - test_arg <- "d" - testthat::expect_error( - object = saros.base:::check_integerish(test_arg), - regexp = "`test_arg` must be an integer of length 1, not a string" - ) - - - test_arg <- -2 - testthat::expect_error( - object = saros.base:::check_integerish(test_arg, min = 0), - regexp = "`test_arg` must be a positive integer of length 1, not a number") - - test_arg <- 2L - testthat::expect_no_error( - object = saros.base:::check_integerish(test_arg)) - - test_arg <- 2.0 - testthat::expect_no_error( - object = saros.base:::check_integerish(test_arg)) - - - test_arg <- 10 - testthat::expect_no_error( - object = saros.base:::check_integerish(test_arg, min = 0)) - - - test_arg <- 10 - testthat::expect_error( - object = saros.base:::check_integerish(test_arg, min = 0, max = 8), - regexp = "`test_arg` must be a positive integer of length 1 \\(max=8\\), not a number") -}) - - -testthat::test_that("check_double", { - test_arg <- "d" - testthat::expect_error( - object = saros.base:::check_double(test_arg), - regexp = "`test_arg` must be a numeric of length 1, not a string" - ) - - test_arg <- -2.5 - testthat::expect_error( - object = saros.base:::check_double(test_arg, min = 0), - regexp = "`test_arg` must be a positive numeric of length 1 \\(min=0\\), not a number" - ) - - test_arg <- 2.5 - testthat::expect_no_error( - object = saros.base:::check_double(test_arg) - ) -}) testthat::test_that("check_string", { test_arg <- 5 @@ -88,38 +23,6 @@ testthat::test_that("check_string", { ) }) -testthat::test_that("check_list", { - test_arg <- "d" - testthat::expect_error( - object = saros.base:::check_list(test_arg, null.ok = FALSE), - regexp = "`test_arg` must be a list, not a string" - ) - - test_arg <- list(a = 1, b = 2) - testthat::expect_no_error( - object = saros.base:::check_list(test_arg) - ) - - test_arg <- NULL - testthat::expect_error( - object = saros.base:::check_list(test_arg, null.ok = FALSE), - regexp = "`test_arg` must be a list, not NULL" - ) - testthat::expect_no_error( - object = saros.base:::check_list(test_arg, null.ok = TRUE)) - - - - test_arg <- list(a = 1, b = 2) - testthat::expect_no_error( - object = saros.base:::check_list(test_arg, n = 2, null.ok = TRUE)) - testthat::expect_error( - object = saros.base:::check_list(test_arg, n = 1, null.ok = TRUE), - regexp = "must be a list of length 1, not") - -}) - - testthat::test_that("check_data_frame", { test_arg <- "not_a_data_frame" @@ -150,21 +53,3 @@ testthat::test_that("check_data_frame", { - -testthat::test_that("check_multiple_dep_and_one_indep", { - - data <- data.frame(a = 1:5, b = 6:10, c = 11:15, d = 16:20, e = 21:25) - - # Test 1: One column for 'dep' and one column for 'indep', expect no error - testthat::expect_no_error( - object = saros.base:::check_multiple_dep_and_one_indep(data, a, b) - ) - - # Test 2: Two columns for 'dep' and one column for 'indep', expect an error - testthat::expect_error( - object = saros.base:::check_multiple_dep_and_one_indep(data, c(a, b), c), - regexp = "Multiple columns for `dep` and `indep` are not allowed.*You provided dep = \\^c\\(a, b\\)" - ) - -}) - diff --git a/tests/testthat/test-fig_height_h_barchart.R b/tests/testthat/test-fig_height_h_barchart.R deleted file mode 100644 index e425ff7..0000000 --- a/tests/testthat/test-fig_height_h_barchart.R +++ /dev/null @@ -1,134 +0,0 @@ -testthat::test_that("fig_height_h_barchart works with typical input", { - result <- saros.base::fig_height_h_barchart(n_y = 5, - n_cats_y = 3, - max_chars_y = 10, - n_x = 2, - n_cats_x = 4, - max_chars_x = 12, - freq = FALSE, - x_axis_label_width = 20, - strip_angle = 0, - main_font_size = 8, - legend_location = "panel", - n_legend_lines = 2, - legend_key_chars_equivalence = 5, - max_chars_per_figure_width = 100, - multiplier_per_horizontal_line = NULL, - multiplier_per_vertical_letter = .15, - multiplier_per_facet = .95, - multiplier_per_legend_line = 1.5, - fixed_constant = 0, - figure_width_in_cm = 16, - margin_in_cm = 0, - max = 8, - min = 1) - testthat::expect_equal(result, 5.1) -}) - -testthat::test_that("fig_height_h_barchart handles frequency plot", { - result <- saros.base::fig_height_h_barchart(n_y = 5, - n_cats_y = 3, - max_chars_y = 10, - n_x = 2, - n_cats_x = 4, - max_chars_x = 12, - freq = TRUE, - x_axis_label_width = 20, - strip_angle = 0, - main_font_size = 8, - legend_location = "panel", - n_legend_lines = 2, - legend_key_chars_equivalence = 5, - max_chars_per_figure_width = 100, - multiplier_per_horizontal_line = NULL, - multiplier_per_vertical_letter = .15, - multiplier_per_facet = .95, - multiplier_per_legend_line = 1.5, - fixed_constant = 0, - figure_width_in_cm = 16, - margin_in_cm = 0, - max = 8, - min = 1) - testthat::expect_equal(result, 8) -}) - -testthat::test_that("fig_height_h_barchart handles missing n_x and n_cats_x", { - result <- saros.base::fig_height_h_barchart(n_y = 5, - n_cats_y = 3, - max_chars_y = 10, - n_x = NULL, - n_cats_x = NULL, - max_chars_x = NULL, - freq = FALSE, - x_axis_label_width = 20, - strip_angle = 0, - main_font_size = 8, - legend_location = "panel", - n_legend_lines = 2, - legend_key_chars_equivalence = 5, - max_chars_per_figure_width = 100, - multiplier_per_horizontal_line = NULL, - multiplier_per_vertical_letter = .15, - multiplier_per_facet = .95, - multiplier_per_legend_line = 1.5, - fixed_constant = 0, - figure_width_in_cm = 16, - margin_in_cm = 0, - max = 8, - min = 1) - testthat::expect_equal(result, 3.53) -}) - -testthat::test_that("fig_height_h_barchart handles NULL multiplier_per_horizontal_line", { - result <- saros.base::fig_height_h_barchart(n_y = 5, - n_cats_y = 3, - max_chars_y = 10, - n_x = 2, - n_cats_x = 4, - max_chars_x = 12, - freq = FALSE, - x_axis_label_width = 20, - strip_angle = 0, - main_font_size = 8, - legend_location = "panel", - n_legend_lines = 2, - legend_key_chars_equivalence = 5, - max_chars_per_figure_width = 100, - multiplier_per_horizontal_line = NULL, - multiplier_per_vertical_letter = .15, - multiplier_per_facet = .95, - multiplier_per_legend_line = 1.5, - fixed_constant = 0, - figure_width_in_cm = 16, - margin_in_cm = 0, - max = 8, - min = 1) - testthat::expect_equal(result, 5.1) -}) - -testthat::test_that("fig_height_h_barchart respects min and max height", { - result <- saros.base::fig_height_h_barchart(n_y = 5, - n_cats_y = 3, - max_chars_y = 10, - n_x = 2, - n_cats_x = 4, - max_chars_x = 12, - freq = FALSE, - x_axis_label_width = 20, - strip_angle = 0, - main_font_size = 8, - legend_location = "panel", - n_legend_lines = 2, - legend_key_chars_equivalence = 5, - max_chars_per_figure_width = 100, - multiplier_per_horizontal_line = NULL, - multiplier_per_vertical_letter = .15, - multiplier_per_facet = .95, - multiplier_per_legend_line = 1.5, - fixed_constant = 1, - figure_width_in_cm = 16, - margin_in_cm = 0, - max = 6, - min = 2) - testthat::expect_equal(result, 6) -})