I am looking for the most efficient way (i.e. pressing smaller keys) to index the last element of an array.
Then something like
a <- c(1,2,3) n <- length(a) b <- a[n]
should not be used, I would like to use only one command.
In the above example, I could use
b <- a[length(a)]
but I wonder if something shorter exists.
Let me select part of an array, for example
a <- seq(from = 1, to = 10, by = 1) b <- a[3:length(a)]
Is there a shorter way to do this?
source share