Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当矩阵的两列与r中的给定值匹配时,如何查找矩阵的行号_R - Fatal编程技术网

当矩阵的两列与r中的给定值匹配时,如何查找矩阵的行号

当矩阵的两列与r中的给定值匹配时,如何查找矩阵的行号,r,R,我有一个4X5矩阵示例: a = 1 2 3 4 5 2 3 3 4 1 5 6 77 8 9 10 9 3 4 17 这里我想知道行号,其中a[,3]==3和a[,4]==4。 我想得到的答案是1,2和4 如何在r中获得它使用此 a = matrix(c(1,2,3,4,5,2,3,3,4,1,5,6,77,8,9,10,9,3,4,17), byrow = T, ncol = 5) which(a[, 3] == 3 & a[ ,4] == 4) [1]

我有一个4X5矩阵示例:

a = 1 2 3 4 5
    2 3 3 4 1
    5 6 77 8 9
    10 9 3 4 17
这里我想知道行号,其中a[,3]==3和a[,4]==4。 我想得到的答案是1,2和4 如何在r中获得它使用此

a = matrix(c(1,2,3,4,5,2,3,3,4,1,5,6,77,8,9,10,9,3,4,17), byrow = T, ncol = 5)
which(a[, 3] == 3 & a[ ,4] == 4)
[1] 1 2 4