Extract a dplyr tbl column as a vector

后端 未结 7 1409

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:47

    @Luke1018 proposed this solution in one of the comments:

    You can also use the magrittr exposition operator (%$%) to pull a vector from a data frame.

    For example:

    iris2 %>% select(Species) %>% collect() %$% Species
    

    I thought it deserved its own answer.

提交回复
热议问题