Learn R Programming

quantmod (version 0.2-5)

first: Return First or Last Element of Data

Description

A simple generic function to return the first or last element or row of a vector or two-dimensional data object.

Usage

first(x,...)
last(x,...)

## S3 method for class 'default': first(x,...)

## S3 method for class 'default': last(x,...)

Arguments

x
1 or 2 dimensional data object
...
additional args - unused

Value

  • A one element/row data object

Details

A simple wrapper to extract the first or last element of an object.

Examples

Run this code
first(1:100)
last(1:100)

data(LakeHuron)
first(LakeHuron)
last(LakeHuron)

Run the code above in your browser using DataLab