Debian Codegraph @

man/last.Rd

raw
1 \name{last}
2 \alias{last}
3 \title{Get Last Elements of a Vector}
4 \description{
5 Extract the last elements of a vector.
6 }
7 \usage{
8 last(x, length.out = 1, na.rm = FALSE)
9 }
10 \arguments{
11 \item{x}{any vector.}
12 \item{length.out}{integer indicating how many element are desired. If
13 positive, return the \code{length.out} last elements of \code{x}; if
14 negative, the last \code{length.out} elements are \emph{dropped}.
15 }
16 \item{na.rm}{logical indicating if the last non-missing value (if any)
17 shall be returned. By default (it is \code{FALSE} and) the last
18 elements (whatever its values) are returned.}
19 }
20 \value{
21 a vector of length \code{abs(length.out)} of \emph{last} values from \code{x}.
22 }
23 \author{Werner Stahel (\email{[email protected]}), and independently,
24 Philippe Grosjean (\email{[email protected]}),
25 Frédéric Ibanez (\email{[email protected]}).}
26 \note{
27 This function may eventually be deprecated for the standard \R
28 function \code{\link{tail}()}.
29
30 Useful for the \code{\link[pastecs]{turnogram}()} function in package
31 \CRANpkg{pastecs}.
32 }
33
34 \seealso{\code{\link[pastecs]{first}}, \code{\link[pastecs]{turnogram}}
35 }
36 \examples{
37 a <- c(NA, 1, 2, NA, 3, 4, NA)
38 last(a)
39 last(a, na.rm=TRUE)
40
41 last(a, length = 2)
42 last(a, length = -3)
43 }
44 \keyword{ manip }