Learn R Programming

BBmisc (version 1.13)

convertInteger: Conversion for single integer.

Description

Convert single numeric to integer only if the numeric represents a single integer, e.g. 1 to 1L. Otherwise the argument is returned unchanged.

Usage

convertInteger(x)

Value

Either a single integer if conversion was done or x unchanged.

Arguments

x

[any]
Argument.

Examples

Run this code
str(convertInteger(1.0))
str(convertInteger(1.3))
str(convertInteger(c(1.0, 2.0)))
str(convertInteger("foo"))

Run the code above in your browser using DataLab