获取矩阵或数据框中等于某个值行号和列号
> a<-matrix(1:10,2)
> a
[,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 4 6 8 10
> which(a==3, arr.ind = TRUE)
row col
[1,] 1 2
获取矩阵或数据框中等于某个值行号和列号
> a<-matrix(1:10,2)
> a
[,1] [,2] [,3] [,4] [,5]
[1,] 1 3 5 7 9
[2,] 2 4 6 8 10
> which(a==3, arr.ind = TRUE)
row col
[1,] 1 2
本文标题:R语言-05根据数据值获取位置
本文链接:https://www.haomeiwen.com/subject/pjyxlctx.html
网友评论