Filter data.frame rows by a logical condition

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

    I was working on a dataframe and having no luck with the provided answers, it always returned 0 rows, so I found and used grepl:

    df = df[grepl("downlink",df$Transmit.direction),]
    

    Which basically trimmed my dataframe to only the rows that contained "downlink" in the Transmit direction column. P.S. If anyone can guess as to why I'm not seeing the expected behavior, please leave a comment.

    Specifically to the original question:

    expr[grepl("hesc",expr$cell_type),]
    
    expr[grepl("bj fibroblast|hesc",expr$cell_type),]
    

提交回复
热议问题