R/formatR.R

#' Pretty formatting of correlation coefficients
#'
#' @param r The Pearson correlation to format.
#' @param digits The number of digits to round to.
#'
#' @return The formatted correlation.
#' @seealso [noZero()], [formatCI()], [formatPvalue()]
#' @export
#'
#' @examples formatR(cor(mtcars$mpg, mtcars$disp));

formatR <- function (r, digits = 2) {
  return(ufs::noZero(round(r,
                           digits = digits)));
}

Try the ufs package in your browser

Any scripts or data that you put into this service are public.

ufs documentation built on July 9, 2023, 6:07 p.m.