last {relevance} | R Documentation |
Last Elements of a Vector or of a Matrix
Description
Selects or drops the last element or the last n
elements of a
vector or the last n
rows or ncol
columns of a matrix
Usage
last(data, n = NULL, ncol=NULL, drop=is.matrix(data))
Arguments
data |
vector or matrix or data.frame from which to select or drop |
n |
if >0, |
ncol |
if |
drop |
if only one row or column of a matrix (or one column of a data.frame) is selected or left over, should the result be a vector or a row or column matrix (or one variable data.frame) |
Value
The selected elements of the vector or matrix or data.frame
Note
This is a very simple function. It is defined mainly for selecting from the results of other functions without storing them.
Author(s)
Werner Stahel
Examples
x <- runif(rpois(1,10))
last(sort(x), 3)
last(sort(x), -5)
##
df <- data.frame(X=c(2,5,3,8), F=LETTERS[1:4], G=c(TRUE,FALSE,FALSE,TRUE))
last(df,3,-2)