R/round.df.R

Defines functions round_df

Documented in round_df

#' Round numeric values of a data.frame
#'
#' @param df a data.frame
#' @param digits an integer
#'
#' @return a rounded data.frame
#' @export
round_df <- function(df, digits) {
  nums <- vapply(df, is.numeric, FUN.VALUE = logical(1))

  df[,nums] <- round(df[,nums], digits = digits)

  return(df)
}
JBLecomte/JBUtilities documentation built on March 31, 2021, 7:25 p.m.