asInteger | R Documentation |
Essentially a wrapper around round
, rather than truncate
, which is what as.integer
does. Internally, this is simply as.integer(floor(x + 0.5))
.
asInteger(x)
x |
A numeric vector |
An integer vector of length x
, rounded to zero decimal places
prior to as.integer
Values ending in .5
will be rounded up, whether positive or negative.
This is different than round
.
x <- seq(-2, 2, 0.25)
data.frame(dbl = x, int = asInteger(x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.