
上QQ阅读APP看书,第一时间看更新
Numeric and Integers
The numeric data class includes all numbers except integers, which are their own separate class in R. Anything of class numeric will be of type double, unless it is explicitly declared as an integer. To create an integer, you must type a capital letter, L, after a whole number.
Let's now create and check the class() and typeof() of different numeric objects in R. Follow the steps given below:
- Create the following numeric objects:
x <- 12.7
y <- 8L
z <- 950
- Check the class and type of each using class() and typeof(), respectively, as follows:
class(x)
typeof(x)
class(y)
typeof(y)
class(z)
typeof(z)
Output: The preceding code provides the following output:
