R/gl.check.verbosity.r

Defines functions gl.check.verbosity

Documented in gl.check.verbosity

#' @name gl.check.verbosity
#' @title Checks the current global verbosity
#' @family environment
#' 
#' @description
#' The verbosity can be set in one of two ways -- (a) explicitly by the user by
#' passing a value using the parameter verbose in a function, or (b) by setting
#' the verbosity globally as part of the r environment (gl.set.verbosity).

#' @param x User requested level of verbosity [default NULL].
#' 
#' @examples 
#' gl.check.verbosity()
#' 
#' @author Bernd Gruber (Post to \url{https://groups.google.com/d/forum/dartr})
#' 
#' @export
#' @return The verbosity, in variable verbose

# Version v.2023.3

gl.check.verbosity <- function(x = NULL) {
    # SET VERBOSITY or GET it from global
    if (is.null(x)) {
        if (is.null(options()$dartR_verbose)) {
            verbose <- 2
        } else {
            verbose <- options()$dartR_verbose
        }
    } else {
        if (is.numeric(x) & x >= 0 & x <= 5) {
            verbose <- x
        } else {
            cat(
                warn(
                    "Warning: Parameter verbose must be an integer in the range 
                    0 to 5, set to 2\n"
                )
            )
            verbose <- 2
        }
    }
    
    return(verbose)
}

Try the dartR.base package in your browser

Any scripts or data that you put into this service are public.

dartR.base documentation built on April 4, 2025, 2:45 a.m.