first
Syntax
first(X)
Arguments
X is a vector/matrix.
Details
Return the first element of a vector, or the first row of a matrix.
If the first element is NULL, the function returns NULL. To get the first non-NULL element, use firstNot.
Examples
$ first(`hello `world);
hello
$ first(1..10);
1
$ m = matrix(1 2 3, 4 5 6);
$ m;
#0 |
#1 |
---|---|
1 |
4 |
2 |
5 |
3 |
6 |
$ first(m);
[1,4]
Related function: last