Data types are an essential part of programming. The ability to identify the different data types in a programming language makes it easier for a programmer to code. The different data types mean that different data types can and can not do different things.
A variable helps store different data, which are of various types. We’ll look at the different data types in the
R language in this shot.
There are five basic data types in
character: Strings. For example,
'10', and so on.
integer: Positive or negative. For example,
100L, and so on. The
Rto store the value as an integer.
numerical: Numbers. For example,
1000, and so on.
logical: Boolean (
complex: Complex numbers. For example,
5 + 2i,
10 - 5i, and so on.
# character name <- 'Theo' # integer x <- -10L # numerical y <- 200 # logical a <- TRUE # complex z = 3 + 9i name x y a z
R language, we use the
class() function to check the data type of a variable.
# character name <- 'Theo' # integer x <- -10L # numerical y <- 200 # logical a <- TRUE # complex z = 3 + 9i class(name) class(x) class(y) class(a) class(z)
View all Courses