head#
Purpose#
Returns the first n
rows of a matrix, dataframe or string array.
Format#
- h = head(X[, n])#
- Parameters:
X (Matrix, dataframe or string array) – the data to preview.
n (Scalar) – Optional input, the number of rows to return. Default = 5. If a negative number is supplied, all except the first n rows will be returned.
- Returns:
h (Matrix, dataframe or string array) – The first n rows of X (or all but the first n rows of X, if n is negative).
Examples#
X = { 11 14,
27 19,
44 12,
81 17,
23 22,
14 43 };
head(X);
The above code will print:
11.000000 14.000000
27.000000 19.000000
44.000000 12.000000
81.000000 17.000000
23.000000 22.000000
head(X, 3);
will print out:
11.000000 14.000000
27.000000 19.000000
44.000000 12.000000
head(X, -2);
will print out:
44.000000 12.000000
81.000000 17.000000
23.000000 22.000000
14.000000 43.000000