I've always been wondering if there were a quick and clean way of selecting the k last element of a vector/matrix...
As far as I know, one can specify positives indices to extract values, negative indices to keep all apart specified indices, but is there a short cut for keeping the k last elements.
For now, considering a vector vect
I've been using:
rev(rev(vect)[1:k])
which is not that bad but doesn't work if I want to keep the last k column of a matrix for example. In this case I write:
vect[(length(vect)-k+1) : length(vect)]
thanks !