isInteger tests if a given number is an integer.
a vector or an array of values to be tested.
a numeric value giving the tolerance level.
As opposed to
is.integer this function tests for
integrity of a given value, rather than being of type
In R integers are specified by the suffix
whereas all other numbers are of class
independent of their value. The function
not test whether a given variable has an integer value, but whether
it belongs to the class
In contrast, the function
isInteger compares the difference
between its argument and its rounded argument. If it is smaller than
some predefined tolerance level, the variable is regarded as integer.
TRUE if the argument
n has an integer value,
The R function
c concatenates its argument
and forms a vector. In doing so, it coerces the values to a common
type. Hence, attention has to be paid, because
give some unexpected results in this case. The R command
list, however, does not coerce its arguments (see
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
# isInteger tests if the _value_ of a variable is an integer # 'c' as opposed to 'list' coerces its arguments! isInteger(c("test", 1, 2, 2.1)) # FALSE FALSE FALSE FALSE isInteger(list("test", 1, 2, 2.1)) # FALSE TRUE TRUE FALSE class(1L) # integer typeof(1L) # integer class(1) # numeric typeof(1) # double # is.integer tests if the _class_ of a variable is 'integer' is.integer(c("test", 1, 2)) # FALSE is.integer(list("test", 1, 2)) # FALSE is.integer(1) # FALSE is.integer(1L) # TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.