Select rows of a matrix that meet a condition

前端 未结 6 617
半阙折子戏
半阙折子戏 2020-11-29 15:26

In R with a matrix:

     one two three four
 [1,]   1   6    11   16
 [2,]   2   7    12   17
 [3,]   3   8    11   18
 [4,]   4   9    11   19
 [5,]   5  10         


        
6条回答
  •  迷失自我
    2020-11-29 15:56

    I will choose a simple approach using the dplyr package.

    If the dataframe is data.

    library(dplyr)
    result <- filter(data, three == 11)
    

提交回复
热议问题