Page 202 - Data Science class 11
P. 202
6.2.1 numeric
A numeric data type is the most common type in R, and contains any number with or without a decimal, like: 10.5,
55, 787:
Example
Enter the following code snippet in the script panel:
x <- 10.5
# <- is known as the assignment operator
y <- 55
# Print values of x and y
x
y
# Print the class name of x and y
class(x)
class(y)
class()—This is used to return the values of the class attribute of an R object.
Run to see the following in the console panel:
6.2.2 integer
Integers are numeric data without decimals. This is used when you are certain that you will never create a variable that
should contain decimals. To create an integer variable, you must use the letter L after the integer value:
Example
Enter the following code snippet in the script panel:
x <- 2021L
y <- 19435L
# Print values of x and y
x
y
# Print the class name of x and y
200 Touchpad Data Science-XI

