powered by
Extract or replace the ultimate (last) element of a vector or a list, or an element counting from the end.
ult(x, i = 1L)ult(x, i = 1L) <- value
ult(x, i = 1L) <- value
a vector or a list.
index from the end of the list to extract or replace (where 1 is the last element, 2 is the penultimate element, etc.).
Replacement value for the ith element from the end.
i
An element of x.
x
# NOT RUN { x <- 1:5 (last <- ult(x)) (penultimate <- ult(x, 2)) # 2nd last. # } # NOT RUN { (ult(x) <- 6) (ult(x, 2) <- 7) # 2nd last. x # } # NOT RUN { # }
Run the code above in your browser using DataLab