Select 在 R 中使用 dbplyr 来自 sqlite 数据库的特定行
Select specific rows from sqlite database using dbplyr in R
我想 select 使用 R 中的 dbplyr /dplyr 包从 table 中的 table 特定行(比如行号 1、8 和 20),但不加载整个 table 在内存中。有人可以帮忙吗?
filter
可以与 sqlitedb
一起使用
library(dplyr)
con <- DBI::dbConnect(RSQLite::SQLite(), dbname = ":memory:")
copy_to(con, iris, "iris")
iris_db <- tbl(con, "iris")
iris_db %>%
filter(row_number() %in% c(1, 8, 20))
# Source: lazy query [?? x 5]
# Database: sqlite 3.29.0 [:memory:]
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
# <dbl> <dbl> <dbl> <dbl> <chr>
#1 5.1 3.5 1.4 0.2 setosa
#2 5 3.4 1.5 0.2 setosa
#3 5.1 3.8 1.5 0.3 setosa
我想 select 使用 R 中的 dbplyr /dplyr 包从 table 中的 table 特定行(比如行号 1、8 和 20),但不加载整个 table 在内存中。有人可以帮忙吗?
filter
可以与 sqlitedb
library(dplyr)
con <- DBI::dbConnect(RSQLite::SQLite(), dbname = ":memory:")
copy_to(con, iris, "iris")
iris_db <- tbl(con, "iris")
iris_db %>%
filter(row_number() %in% c(1, 8, 20))
# Source: lazy query [?? x 5]
# Database: sqlite 3.29.0 [:memory:]
# Sepal.Length Sepal.Width Petal.Length Petal.Width Species
# <dbl> <dbl> <dbl> <dbl> <chr>
#1 5.1 3.5 1.4 0.2 setosa
#2 5 3.4 1.5 0.2 setosa
#3 5.1 3.8 1.5 0.3 setosa