In order to create an integer variable in R, we invoke the as.integer function. We can be assured that y is indeed an integer by applying the is.integer function.
> y # print the value of y
> class(y) # print the class name of y
> is.integer(y) # is y an integer?
Incidentally, we can coerce a numeric value into an integer with the same as.integer function.
And we can parse a string for decimal values in much the same way.
On the other hand, it is erroneous trying to parse a non-decimal string.
NAs introduced by coercion
Often, it is useful to perform arithmetic on logical values. Like the C language, TRUE has the value 1, while FALSE has value 0.