So I would like to split a string, in this instance on a space, into rows. I would like to do this using dbplyr, which is proving to be an issue. Obviously, if I collect there area tons of ways to do this. Although I need to do this without collecting. Here is some dummy data, one way to do with collecting, and the same way not working without collecting
library(dbplyr)
library(dplyr)
library(tidyr)
con <- DBI::dbConnect(...)
df <- tbl(
src = con,
from = sql(
"SELECT 1 AS ID, 'I LIKE CATS' AS TEXT FROM DUAL
UNION ALL
SELECT 2 AS ID, 'I LIVE IN A BIG HOUSE' AS TEXT FROM DUAL
UNION ALL
SELECT 3 AS ID, 'ARE THERE MANY ORANGES IN THE CUPBOARD' AS TEXT FROM DUAL")
)
df %>%
collect() %>%
mutate(WORD = strsplit(TEXT, " ")) %>%
unnest(WORD)
df %>%
mutate(WORD = strsplit(TEXT, " "))
There was a similar (ish) question that went unanswered here: How to split one SQL column into multiple columns in r
There is the use of purrr::map and purrr::reduce with dbplyr to union function outputs that I've tried to use, but still to no avail: Using purrr::map2() with dbplyr
Any help would be massively appreciated, thanks!