R vector: Exclude several elements
distances = c(11, 12, 13, 14, 15, 16, 17, 18)
print(distances[-c(2, 4)]) # 11 13 15 16 17 18
print(distances[-(2:4)]) # 11 15 16 17 18
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
distances = c(11, 12, 13, 14, 15, 16, 17, 18)
print(distances[-c(2, 4)]) # 11 13 15 16 17 18
print(distances[-(2:4)]) # 11 15 16 17 18