First of all, it is quite possible to successfully use R for years, and there is no need to know the answer to this question. R handles the differences between (regular) numbers and integers for you in the background.
> is.numeric(1) [1] TRUE > is.integer(1) [1] FALSE > is.numeric(1L) [1] TRUE > is.integer(1L) [1] TRUE
(Placing the capital letter "L" after an integer forces it to be stored as an integer.)
As you can see, an integer is a subset of a numeric.
> .Machine$integer.max [1] 2147483647 > .Machine$double.xmax [1] 1.797693e+308
Integer values ββare just over 2 billion, while other numbers can be much larger. They may be larger because they are stored as double precision floating point numbers. This means that the number is stored in two parts: the exponent (as 308 is higher, except in base 2, and not in base 10), and βsignificantβ (as 1.797693 is higher).
Please note that is.integer is not a test of whether you have an integer, but a check of how the data is stored.
It is worth noting that the colon operator : returns integers if the start and end points are integers. For example, 1:5 creates an integer vector of numbers from 1 to 5. You do not need to add the letter L
> class(1:5) [1] "integer"
Link: https://www.quora.com/What-is-the-difference-between-numeric-and-integer-in-R
Rana Muhammad kashif Sep 04 '15 at 15:32 2015-09-04 15:32
source share