Is array/vector handling this hard?

Using a vector of indices is completely fine by itself. However in your case, where you also want a complement it is not the best choice. You could just use a BitVector of indexing.

mask = falses(size(features, 1))
mask[selected] .= true
# now you can do
features[mask, :] # selected features
features[.!(mask), :]  # not selected features

If the data is very large you can also consider using views. For that just prepend a slicing operation with @view like in @view features[.!(mask), :]

Also Julia arrays are column-major, so array[indices, :] will generically be slower than array[:, indices]

5 Likes