Macaulay2 » Documentation
Packages » RInterface » RObject » round(RObject,RObject)
next | previous | forward | backward | up | index | toc

round(RObject,RObject) -- rounding of an R object

Description

Round each element of x to the nearest integer, calling R's round, which rounds to even (banker's rounding), just as in Macaulay2.

i1 : round RObject 2.5

o1 = [1] 2

o1 : RObject of type double
i2 : round RObject 3.5

o2 = [1] 4

o2 : RObject of type double

An optional second argument, or equivalently a digits option, specifies the number of decimal places to use when rounding.

i3 : x = RObject exp 1

o3 = [1] 2.718282

o3 : RObject of type double
i4 : round(x, 2)

o4 = [1] 2.72

o4 : RObject of type double
i5 : round(x, digits => 3)

o5 = [1] 2.718

o5 : RObject of type double

See also

Ways to use this method:


The source of this document is in /build/reproducible-path/macaulay2-1.26.05+ds/M2/Macaulay2/packages/RInterface/doc/rounding.m2:112:0.