Select n first rows of a matrix

matrix, r

Solution

Use the `head` function:

head(mat, 100)

Problem

How can I select, say top 100 rows of a matrix in R? All I found is using subset which requires condition parameter. All I need to make smaller matrix by using only first n number of rows with same number of columns

Original source