# ---------------------------------------------------------------------------- #
#' Compute maximum length of formatted integers
#'
#' Computes the maximum character length of a vector of integers when they are
#' converted to strings.
#'
#' @param num A vector of integer values.
#'
#' @return Maximum character length of the integers provided, if they were
#' formatted as strings.
#'
#' @examples
#' get_max_int_len(1.0)
#' get_max_int_len(2)
#' get_max_int_len(c(2, 25, 467))
#'
#' @export
#'
get_max_int_len <- function(num) {
lens <- vapply(fmt_int(num), stringr::str_length, integer(1),
USE.NAMES = FALSE
)
# The expected behaviour is that all the strings are formatted to be of equal
# length so this should be equivalent to lens[1]; however, doing it this way
# provides insurance against a future change
unique(max(lens))
}
# ---------------------------------------------------------------------------- #
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.