Reputation: 4470
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
Upvotes: 14
Views: 43729
Reputation: 771
The simplest way to do it would be a[1:100,]
(unless there are fewer than 100 rows, in which case head(a,100) works better)
Upvotes: 13