Using if else on a dataframe across multiple columns

后端 未结 6 1481
情书的邮戳
情书的邮戳 2021-01-14 21:43

I have a large dataset of samples with descriptors of whether the sample is viable - it looks (kind of) like this, where \'desc\' is the description column and \'blank\' ind

6条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-14 22:32

    This should work. Though honestly, if the data is unusable, why not delete the rows altogether?

    library(dplyr)
    
    blanks = 
      dat %>%
      filter(desc == "blank") %>%
      select(desc)
    
    dat %>%
      filter(desc == "sample") %>%
      bind_rows(blanks)
    

提交回复
热议问题