values = [1, 2, 4, 7, 11]
# as list comprehension
only_small_values = [v for v in values if v < 5]
# using filter
only_small_values = list(filter(lambda v: v < 5, values))
# 0, 1, 2
indices = [i for i, _ in enumerate(values) if v < 5]
values <- c(1, 2, 4, 7, NA, 11)
# will contain the NA value
values[values < 5]
# will not contain the NA value
subset(values, values < 5)
# indices where value < 5: 1, 2, 3
which(values < 5)