R/roundf.R

Defines functions roundf

Documented in roundf

#' Round and format to specified decimal place
#'
#' Rounds and formats a number to specified decimal place.
#'
#' @param x Number(s)
#' @param decimals Number of decimals
#' @return Formatted number(s) in character format
#' @examples
#' roundf(0.345957, 2)
#' @export
roundf <- function(x, decimals){trimws(format(round(x, decimals), nsmall=decimals))}
cfree14/freeR documentation built on Aug. 22, 2023, 11:12 p.m.