Skip to content

Commit

Permalink
add f_sign
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Rinker committed Nov 18, 2016
1 parent 6481d7b commit 05a3070
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export(f_percent)
export(f_prefix)
export(f_prop2percent)
export(f_pval)
export(f_sign)
export(f_suffix)
export(f_thous)
19 changes: 19 additions & 0 deletions R/f_sign.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#' Format Numeric Signs
#'
#' \code{f_sign} - Formats numeric values to just their sign
#' ('-' == < 0, '+' == > 0, or '' == 0).
#'
#' @param x A vector of values.
#' @param \ldots ignored.
#' @return Returns a string of signs.
#' @export
#' @rdname f_sign
#' @seealso \code{\link[numform]{f_num}}
#' @examples
#' f_sign(c(-10, 0, 10))
f_sign <- function(x, ...) {

gsub("[01]", "", gsub("^1$", "+", as.character(sign(x))))

}

27 changes: 27 additions & 0 deletions man/f_sign.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/number_abbreviation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 05a3070

Please sign in to comment.