R Cheatsheet: Vectors
A Vector is a collection of n elements of the same class.
A numeric vector:
num_vect<-c(0.5, 55, -10,6)
If we need to know which elements of the previous vector are lesser than 1:
tf<-num_vect<1
And we obtain a Logical Vector
A character vector:
my_char<-c(«my», «name», «is»)
Concatenate the individual elements of a vector with a » » (blank)
paste(my_char, collapse = » «)
Creating a new character vector with another element
my_name<-c(my_char, «Martin»)
paste(my_name, collapse = » «)
Using paste() function in order to concatenate each individual element of two vectors:
paste(LETTERS, 1:4, sep = «-«)