如何获取R中的行索引号? [英] How to get row index number in R?
本文介绍了如何获取R中的行索引号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
我将你的问题解释为关于获得行号。
- 您可以尝试
as.numeric(rownames(df))
不要设置rownames。否则使用序列1:nrow(df)
。 -
which()
函数将TRUE / FALSE行索引转换为行号。
Suppose I have a list or data frame in R, and I would like to get the row index, how do I do that? That is, I would like to know how many rows a certain matrix consists of.
解决方案
I'm interpreting your question to be about getting row numbers.
- You can try
as.numeric(rownames(df))
if you haven't set the rownames. Otherwise use a sequence of1:nrow(df)
. - The
which()
function converts a TRUE/FALSE row index into row numbers.
这篇关于如何获取R中的行索引号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文