last.RdExtract the last elements of a vector.
last(x, length.out = 1, na.rm = FALSE)any vector.
integer indicating how many element are desired. If
positive, return the length.out last elements of x; if
negative, the last length.out elements are dropped.
logical indicating if the last non-missing value (if any)
shall be returned. By default (it is FALSE and) the last
elements (whatever its values) are returned.
a vector of length abs(length.out) of last values from x.
This function may eventually be deprecated for the standard R
function tail().
Useful for the turnogram() function in package
pastecs.
first, turnogram
a <- c(NA, 1, 2, NA, 3, 4, NA)
last(a)
#> [1] NA
last(a, na.rm=TRUE)
#> [1] 4
last(a, length = 2)
#> [1] 4 NA
last(a, length = -3)
#> [1] NA 1 2 NA