Select n first rows of a matrix

后端 未结 2 2044
长发绾君心
长发绾君心 2021-01-04 11:48

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

2条回答
  •  感情败类
    2021-01-04 11:56

    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)

提交回复
热议问题