R/round_df.R

Defines functions round_df

Documented in round_df

#' A function to round entire dataframe
#'
#' This function enables tue user to round all values in a dataframe. The function isolates double variables and round them.
#'
#' @param df a dataframe under the data frame format or a Tibble
#' @param digits number of decimal wanted
#' @keywords round data frame
#' @export


round_df <- function(df, digits){
  for(i in 1:ncol(df)){
    if(typeof(df[,i]) == "double"){
      df[,i] <- round(df[,i], digits)
    } else {
      next
    }
  }
  return(df)
}
EricMenetre/NPL documentation built on June 23, 2021, 2:10 p.m.