R provides 3 basic indexing operators. Refer below for the syntax and example:
a[i]
a[i, j]
a[[i]]
a[[i, j]]
a$x
a$"x"
When it comes to vectors and matrices [[ are hardly used even though they have semantic differences from [.
While indexing multi-dimensional structures with a single index, a[[i]] or a[i] will return the ith sequential element of a.
When you use lists, [[ is used to select any single element, and [ is used to return a list of the selected elements.
[[ allows a single element to be selected using various indices like integer/character and [ indexes by vectors.