Extract a dplyr tbl column as a vector

后端 未结 7 1366

Is there a more succinct way to get one column of a dplyr tbl as a vector, from a tbl with database back-end (i.e. the data frame/table can\'t be subset directly)?



        
7条回答
  •  孤城傲影
    2020-11-22 16:45

    I would use the extract2 convenience function from magrittr:

    library(magrittr)
    library(dplyr)
    
    iris2 %>%
      select(Species) %>%
      extract2(1)  
    

提交回复
热议问题