Rounds all numeric columns in dataframe. By default, uses "round half to even" (aka banker's rounding), but the rounding method can be changed via the timesaveR.round_method option (see Details).

round_df(df, digits = 2)

Source

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

Arguments

df

Dataframe to be rounded

digits

Number of digits, defaults to 2

Details

The rounding method is controlled by the timesaveR.round_method option:

  • "to_even" (default): Round half to even (banker's rounding)

  • "default": Standard R rounding (round half away from zero)

Set via options(timesaveR.round_method = "default") to change for your session.