I want to remove some rows from some data frame using row index numbers. But sometimes the index vector that I'm going to fall becomes a zero-length vector. In this case, I expect that nothing should be removed from the original data frame. But instead of nothing, everything is discarded.
For example, it dropworks as expected here
df = data_frame( a = 10:12 )
drop = c(1,2)
df[ -drop, ]
But when drop- a vector of zero length, then deleting these lines does not work, as I expect.
drop = integer()
df[ -drop, ]
I expected to get the whole object dfwithout any changes.
How to remove rows from a data frame using row indices where row indices can become a zero-length vector?