Learn R Programming

taRifx (version 1.0.6.2)

roundnear: Rounds a numeric vector to arbitrary values (not just decimal values as with round) or to a specified number of significant digits.

Description

Rounds a numeric vector to arbitrary values (not just decimal values as with round). E.g. allows you to round to nearest 0.3 instead of just nearest 1 or 0.1

Usage

roundnear(vec, roundvec)

round_sigfig(vec, digits = 2)

Arguments

vec

numeric vector

roundvec

What value to round things to (e.g. nearest 1, 10, 0.3, etc.). Typically a single item to apply to all of vec. If of length greater than 1, usual wrapping rules apply.

digits

Number of significant digits to round to

Value

Rounded numeric vector of length length(vec)

References

http://en.wikipedia.org/wiki/Significant_figures

Examples

Run this code
# NOT RUN {
roundnear( runif(10) , .03 )
# }

Run the code above in your browser using DataLab