From f6d3a85d1517402a7f7f0696ed9888de76619de7 Mon Sep 17 00:00:00 2001 From: Shu Fai Cheung Date: Wed, 2 Oct 2024 12:39:04 +0800 Subject: [PATCH] 0.2.3.14: Wrap the printout of computation formulas Tests, checks, and build_site() passed. --- DESCRIPTION | 2 +- NEWS.md | 7 ++++++- R/print_indirect.R | 26 ++++++++++++++++++++++++-- README.md | 2 +- man/print.indirect.Rd | 7 +++++++ 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7ad9fb71..1a5ed261 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: manymome Title: Mediation, Moderation and Moderated-Mediation After Model Fitting -Version: 0.2.3.13 +Version: 0.2.3.14 Authors@R: c(person(given = "Shu Fai", family = "Cheung", diff --git a/NEWS.md b/NEWS.md index 94a05051..eee096e2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# manymome 0.2.3.13 +# manymome 0.2.3.14 ## New Features @@ -52,6 +52,11 @@ `many_indirect_effects()` individually. (0.2.3.12) +- Added `wrap_computation` to the argument + of `print.indirect()` to wrap the printout + of long computational formulas. + (0.2.3.14) + ## Documentation and Notes - Corrected `README` to remark that diff --git a/R/print_indirect.R b/R/print_indirect.R index 74458b23..672563e4 100644 --- a/R/print_indirect.R +++ b/R/print_indirect.R @@ -149,6 +149,11 @@ #' been computed. Default #' to `TRUE`. #' +#' @param wrap_computation Logical. +#' If `TRUE`, the default, long +#' computational symbols and values +#' will be wrapped to fit to the screen +#' width. #' #' @param ... Other arguments. Not used. #' @@ -214,6 +219,7 @@ print.indirect <- function(x, se = NULL, level = .95, se_ci = TRUE, + wrap_computation = TRUE, ...) { xold <- x my_call <- x$call @@ -487,7 +493,15 @@ print.indirect <- function(x, # cat("\n", paste(x$op, x$computation_symbol, collapse = "\n")) } else { cat("\nComputation Formula:") - cat("\n ", x$computation_symbol) + if (wrap_computation) { + tmp <- strwrap(x$computation_symbol, + indent = 2, + exdent = 2) + cat("\n") + cat(tmp, sep = "\n") + } else { + cat("\n ", x$computation_symbol) + } } } if (!is.null(x$computation_values)) { @@ -496,7 +510,15 @@ print.indirect <- function(x, # cat("\n", paste(x$op, x$computation_values, collapse = "\n")) } else { cat("\nComputation:") - cat("\n ", x$computation_values) + if (wrap_computation) { + tmp <- strwrap(x$computation_values, + indent = 2, + exdent = 2) + cat("\n") + cat(tmp, sep = "\n") + } else { + cat("\n ", x$computation_values) + } } } if (has_ci) { diff --git a/README.md b/README.md index 820d5f54..64455ad1 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![R-CMD-check](https://github.com/sfcheung/manymome/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/sfcheung/manymome/actions/workflows/R-CMD-check.yaml) -(Version 0.2.3.13, updated on 2024-09-30, [release history](https://sfcheung.github.io/manymome/news/index.html)) +(Version 0.2.3.14, updated on 2024-10-02, [release history](https://sfcheung.github.io/manymome/news/index.html)) # manymome diff --git a/man/print.indirect.Rd b/man/print.indirect.Rd index 90288a08..cca38f06 100644 --- a/man/print.indirect.Rd +++ b/man/print.indirect.Rd @@ -13,6 +13,7 @@ Object} se = NULL, level = 0.95, se_ci = TRUE, + wrap_computation = TRUE, ... ) } @@ -80,6 +81,12 @@ if confidence interval has already been computed. Default to \code{TRUE}.} +\item{wrap_computation}{Logical. +If \code{TRUE}, the default, long +computational symbols and values +will be wrapped to fit to the screen +width.} + \item{...}{Other arguments. Not used.} } \value{