Execute dplyr operation only if column exists

前端 未结 6 1829
青春惊慌失措
青春惊慌失措 2021-02-07 09:18

Drawing on the discussion on conditional dplyr evaluation I would like conditionally execute a step in pipeline depending on whether the reference column exists in the passed da

6条回答
  •  死守一世寂寞
    2021-02-07 09:55

    Edit: Unfortunately, this was too good to be true

    I might be a bit late to the party. But is

    mtcars %>% 
     filter(am == 1) %>%
     try(filter(absent_column== 4))
    

    a solution?

提交回复
热议问题