round_int: Round down to the nearest integer.

Description Usage Arguments Value Examples

Description

round_int takes a numeric input x and rounds each element to the nearest integer. Ties are broken using a 'half-up' rule. This is different from R's default rounding method, which breaks ties by rounding to the nearest even number (i.e. 'half-even').

Usage

1

Arguments

x

A numeric vector.

Value

The function returns the vector x rounded to the nearest integer.

Examples

1
2
round_int(2.5)  # rounding 'half-up' returns 3
round(2.5)      # rounding 'half-even', R's default, return 2

bochocki/slackrsheets documentation built on May 8, 2019, 9:46 a.m.