Vector is a type of object or data structure in R-language. They are designed to store multiple values of same data-type. For example: if you want to store different 50 food items for each cuisine, you don't need to create 50 variables for each cuisine but just a vector of length 50 of datatype character.
Note: It can not have a combination of any two datatype. It has to be homogeneous in nature.
This recipe demonstrates how to filter out a vector using substr() function and indexing
We use combine function "c()" to create a vector
a = c("Adam","Neil", "Shantanu", "Naomi", "Harry")
We use substr() function to first extract out characters from a character vector.
Syntax: substr(X, start, stop)
# to get the first character of each element of the vector substr(a,1,1)
'A' 'N' 'S' 'N' 'H'
Now, applying a filter to get the elements starting with letter 'N'
a[substr(a,1,1) == 'N']