asInteger: Convert numeric values to rounded integers

Description Usage Arguments Value Note Examples

View source: R/misc.R

Description

Essentially a wrapper around round, rather than truncate, which is what as.integer does. Internally, this is simply as.integer(floor(x + 0.5)).

Usage

1

Arguments

x

A numeric vector

Value

An integer vector of length x, rounded to zero decimal places prior to as.integer

Note

Values ending in .5 will be rounded up, whether positive or negative. This is different than round.

Examples

1
2
x <- seq(-2, 2, 0.25)
data.frame(dbl = x, int = asInteger(x))

PredictiveEcology/LandR documentation built on Jan. 24, 2021, 12:52 a.m.