R data types
R not like other programming languages like C and java,the variables are not declared as some data type. R basically object base.There are many types of R-objects. The frequently used ones are −
Vectors
Lists
Matrices
Arrays
Factors
Data Frames
These objects is the vector object and there are six data types of these atomic vectors, also termed as six classes of vectors. The other R-Objects are built upon the atomic vectors.
Logical
TRUE, FALSE
v <- TRUE
print(class(v))
[1] “logical”
Numeric
11.3, 7, 555
v <- 23.5
print(class(v))
[1] “numeric”
Integer
2L, 34L, 0L
v <- 22L
print(class(v))
[1] “integer”
Complex
3 + 5i
v <- 3+6i
print(class(v))
[1] “complex”
Character
‘ab’ , ‘”bad”, “TRUE”, ‘123.4’
v <- “TRUE”
print(class(v))
[1] “character”
Raw
“Hello” is stored as 48 65 6c 6c 6f
v <- charToRaw(“Hello”)
print(class(v))
[1] “raw”