Filter data.frame rows by a logical condition

前端 未结 9 1370
爱一瞬间的悲伤
爱一瞬间的悲伤 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:01

    Sometimes the column you want to filter may appear in a different position than column index 2 or have a variable name.

    In this case, you can simply refer the column name you want to filter as:

    columnNameToFilter = "cell_type"
    expr[expr[[columnNameToFilter]] == "hesc", ]
    

提交回复
热议问题