round_numbers function

Round Numbers

Round Numbers

Rounds the values in its first argument to the specified number of decimal places. This function uses the U.S. Geological Survey rounding method.

round_numbers(x, digits = 0)

Arguments

  • x: 'numeric' vector. Value to be rounded.
  • digits: 'integer' vector or value. Number of decimal places to use (default 0). Values are recycled to match the vector length of x.

Returns

A numeric vector of rounded values.

Examples

round_numbers(x = rep(pi, 3), digits = c(1, 2, 3))

Author(s)

J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center