是否有更简洁的方法将dplyr tbl的一列作为向量,从具有数据库后端的tbl(即数据帧/表不能直接是子集)?
require(dplyr)
db <- src_sqlite(tempfile(), create = TRUE)
iris2 <- copy_to(db, iris)
iris2$Species
# NULL
Run Code Online (Sandbox Code Playgroud)
这太容易了,所以
collect(select(iris2, Species))[, 1]
# [1] "setosa" "setosa" "setosa" "setosa" etc.
Run Code Online (Sandbox Code Playgroud)
但它似乎有点笨拙.