first

0th

Percentile

First item of an object

Returns the first item of a vector or list, or the first row of a data.frame or data.table.

Keywords
data
Usage
first(x, ...)
Arguments
x

A vector, list, data.frame or data.table. Otherwise the S3 method of xts::first is deployed.

...

Not applicable for data.table::first. Any arguments here are passed through to xts::first.

Value

If no other arguments are supplied it depends on the type of x. The first item of a vector or list. The first row of a data.frame or data.table. Otherwise, whatever xts::first returns (if package xts has been loaded, otherwise a helpful error).

If any argument is supplied in addition to x (such as n or keep in xts::first), regardless of x's type, then xts::first is called if xts has been loaded, otherwise a helpful error.

See Also

NROW, head, tail, last

Aliases
  • first
Examples
# NOT RUN {
first(1:5) # [1] 1
x = data.table(x=1:5, y=6:10)
first(x) # same as x[1]
# }
Documentation reproduced from package data.table, version 1.10.4, License: GPL-3 | file LICENSE

Community examples

doracheng@maxchip.com.tw at Nov 7, 2018 data.table v1.11.8

x = data.table(x=1:5, y=6:10) first(x)