Rounding Up, Down, Off, and Changing Digits in R
Overview

The ceiling() function rounds up, and the floor() function rounds down. These functions may seem unnecessary in R, which mainly deals with statistics, but they are surprisingly convenient when handling data.
Explanation
- The
trunc()function also discards everything below the decimal point, but it returns the value that is closer to $0$. - Both the
round()function and thesignif()function keep a number of digits, but they differ in thatround()cares about the digits below the decimal point, whilesignif()cares about the whole number. Usually you would just useround(), but if you want the results to come out neatly aligned in columns, you need thesignif()function.
Meanwhile, instead of adjusting numbers one by one with such functions, if you want to change the number of digits across the entire project, use the options() function. If you set the desired number of digits in the digits option, all real numbers are printed with the specified number of digits.
