round_df: Round all columns with numerical values in a data frame

View source: R/round_df.R

round_dfR Documentation

Round all columns with numerical values in a data frame

Description

A function to round all columns with numerical values in a data frame

Usage

round_df(df, digits = 3)

Arguments

df

a data frame with some numeric columns. Required

digits

the number of digits in decimal part. Defauld: 3

Details

All numbers are rounded in decimal (e.g., 0.003), not scientific, format

Value

the data frame with rounded numbers

Note

Source: https://stackoverflow.com/questions/9063889/how-to-round-a-data-frame-in-r-that-contains-some-character-variables

Examples

## Not run: 
mtx <- data.frame(a = c("a", "b", "c"), b = c(0.123456, 1.2345678, 2.34), c = c(5.678e-3, 3.4567890, 6.789^3))
mtx
round_df(mtx)

## End(Not run)

mdozmorov/MDmisc documentation built on Aug. 24, 2022, 9:18 a.m.