An R Introduction to Statistics


Decimal values are called numerics in R. It is the default computational data type. If we assign a decimal value to a variable x as follows, x will be of numeric type.

> x = 10.5       # assign a decimal value 
> x              # print the value of x 
[1] 10.5 
> class(x)       # print the class name of x 
[1] "numeric"

Furthermore, even if we assign an integer to a variable k, it is still being saved as a numeric value.

> k = 1 
> k              # print the value of k 
[1] 1 
> class(k)       # print the class name of k 
[1] "numeric"

The fact that k is not an integer can be confirmed with the is.integer function. We will discuss how to create an integer in our next tutorial on the integer type.

> is.integer(k)  # is k an integer?