Hi,
I have a method to create a list column of a categorical variable grouped by an id variable using dplyr. However this does not work in dbplyr. Does anyone know of a way to do this in dbplyr??
Thanks
David
library(tidyverse)
library(dplyr)
library(nycflights13)
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
copy_to(con, flights)
flights2 <- tbl(con, "flights")
flights |>
head(100) |>
select(carrier, flight) |>
nest_by(carrier)
#> # A tibble: 11 × 2
#> # Rowwise: carrier
#> carrier data
#> <chr> <list<tibble[,1]>>
#> 1 AA [17 × 1]
#> 2 AS [1 × 1]
#> 3 B6 [25 × 1]
#> 4 DL [13 × 1]
#> 5 EV [3 × 1]
#> 6 FL [1 × 1]
#> 7 MQ [6 × 1]
#> 8 UA [26 × 1]
#> 9 US [5 × 1]
#> 10 VX [2 × 1]
#> 11 WN [1 × 1]
flights2 |>
head(100) |>
select(carrier, flight) |>
nest_by(carrier)
#> Error in UseMethod("nest_by"): no applicable method for 'nest_by' applied to an object of class "c('tbl_SQLiteConnection', 'tbl_dbi', 'tbl_sql', 'tbl_lazy', 'tbl')"
Created on 2023-07-03 with reprex v2.0.2