Round: Round each element of a matrix/vector

View source: R/Round.R

Round each element of a matrix/vectorR Documentation

Round each element of a matrix/vector

Description

Round each element of a matrix/vector.

Usage

Round(x,digit=0,na.rm = FALSE)

Arguments

x

A numeric matrix/vector with data or NA. NOT integer values.

digit

An integer value for 0...N-1 where N is the number of the digits. By default is 0.

na.rm

TRUE or FAlSE for remove NAs if exists.

Details

Round is a very fast C++ implementation. Especially for large data. It handles NA.

Value

A vector/matrix where each element is been rounded in the given digit.

Author(s)

Manos Papadakis

R implementation and documentation: Manos Papadakis <papadakm95@gmail.com>.

See Also

Lchoose, Log, Choose

Examples

x <-matrix( rnorm( 50 * 10), ncol = 10 )
a <- Round(x,5)
b <- round(x,5)
all.equal(a,b) #true
x <-rnorm( 1000)
a <- Round(x,5)
b <- round(x,5)
all.equal(a,b) # true

Rfast documentation built on Nov. 9, 2023, 5:06 p.m.