This may be redundant but I could not find a similar question on SO.
Is there a shortcut to getting the last n elements/entries in a vector or array without using the length of the vector in the calculation?
foo <- 1:23
> foo
[1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Let say one wants the last 7 entities, I want to avoid this cumbersome syntax:
> foo[(length(foo)-6):length(foo)]
[1] 17 18 19 20 21 22 23
Python has foo[-7:]
. Is there something similar in R? Thanks!