convertInteger {BBmisc} | R Documentation |
Convert single numeric to integer only if the numeric represents a single integer, e.g. 1 to 1L. Otherwise the argument is returned unchanged.
convertInteger(x)
x |
[any] |
Either a single integer if conversion was done or x
unchanged.
str(convertInteger(1.0))
## int 1
str(convertInteger(1.3))
## num 1.3
str(convertInteger(c(1.0, 2.0)))
## num [1:2] 1 2
str(convertInteger("foo"))
## chr "foo"