Filter data.frame rows by a logical condition

前端 未结 9 1392
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-21 05:43

I want to filter rows from a data.frame based on a logical condition. Let\'s suppose that I have data frame like

   expr_value     cell_type
1           


        
9条回答
  •  感情败类
    2020-11-21 06:10

    The reason expr[expr[2] == 'hesc'] doesn't work is that for a data frame, x[y] selects columns, not rows. If you want to select rows, change to the syntax x[y,] instead:

    > expr[expr[2] == 'hesc',]
      expr_value cell_type
    4   5.929771      hesc
    5   5.873096      hesc
    6   5.665857      hesc
    

提交回复
热议问题