I have to delete the highest 30 elements and the lowest 30 elements of a numeric vector. My idea was to sort the vector and then select the elements in between like this:
set.seed(3758)
test.x <- rnorm(1000)
test.x <- sort(test.x)
test.x <- test.x[- seq(length(test.x), length.out = 30)]
test.x <- test.x[- (1:30)]
My problem is that I have to restore the original order of the vector after that, but obviously it has now 60 elements less than before. So I can't use
test.x[ord] with ord being ord <- order(test.x) of the original test.x. Is there a way to do this without changing my strategie, i.e. the sorting and deleting?