#' Character sign of an argument
#'
#' Returns "+" for positive arguments, "-" for negative and `zero` for 0.
#'
#' @param x a numeric vector
#' @param zero character to return for 0 argument
#'
#' @examples
#' signc(-1:1)
#' signc(-1:1, zero = "|")
#'
#' @export
signc <- function(x, zero = "0") {
if (!is.numeric(x)) stop("x should be numeric")
str <- ifelse(x >= 0, "+", "-")
str[x == 0] <- zero
str
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.