Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

R Vector: Negative index, exclude element

Using a negative index will give you the same vector without that element

distances = c(11, 12, 13, 14)

nd = distances[-2]
print(nd)           # 11 13 14
print(distances)    # 11 12 13 14