Fix issues #1, #3, #5: misc improvements
R-CMD-check / R CMD check (pull_request) Failing after 4m43s
R-CMD-check / R CMD check (pull_request) Failing after 4m43s
- #5: Unwrap _brand.yml for Quarto 1.9+ compatibility (remove top-level brand: wrapper so meta/logo/color/typography are at the top level) - #1: Add quiet parameter to na_sum() to suppress warnings in loops/pipelines - #3: Add beep() function for CLI beep, desktop notifications, and webhook alerts (supports type=beep|notify|webhook|all)
This commit is contained in:
@@ -149,6 +149,9 @@ race_short_names <- function(x) {
|
||||
#' Sum a numeric that contains missing values and ignore missing values
|
||||
#'
|
||||
#' @param x a numeric vector
|
||||
#' @param quiet Logical. If `TRUE` (default `FALSE`), suppress the warning
|
||||
#' message. Useful when calling `na_sum()` inside a loop or `dplyr` pipeline
|
||||
#' where the message would be emitted repeatedly.
|
||||
#'
|
||||
#' @return the sum, ignoring any missing values
|
||||
#' @export
|
||||
@@ -156,9 +159,12 @@ race_short_names <- function(x) {
|
||||
#' @examples
|
||||
#' x <- c(2, NA, 4, 9)
|
||||
#' na_sum(x) # 15
|
||||
na_sum <- function(x) {
|
||||
#' na_sum(x, quiet = TRUE) # 15 (no message)
|
||||
na_sum <- function(x, quiet = FALSE) {
|
||||
stopifnot(is.numeric(x))
|
||||
message("Taking a sum with missing values equal to 0, be careful!")
|
||||
if (!quiet) {
|
||||
message("Taking a sum with missing values equal to 0, be careful!")
|
||||
}
|
||||
x <- na_zero(x)
|
||||
return(sum(x))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user