Vectors are nothing but data structures in R used for storing and retrieving various datatypes. Vectors are of two types: 1. Atomic vectors which consists of — Logical, integer, numeric, double and character datatype. Atomic vectors take a single value as an input. 2. Recursive vectors i.e lists, multiple values can be passed using a list. are used for indexing list vectors. The class () function is used for finding out the data type of a given vector. This recipe demonstrates different types of vectors that a user can use..
a <- print(123) class(a)
"Output of the code is" : 123 type : numeric
b <- print(2L) class(b)
"Output of the code is" : 2 type : integer
c <- print("hello there") class(c)
"Output of the code is" : "hello there" type- character "
x <- c(list("hello",123,2.5,"good")) class(x)
"Output of the code is " : "hello" 123 2.5 "good" type - 'list'