I'm trying to add rows to a SQLite data base using dplyr. Based on StatSandwich's answer to this post I would have thought that the following may work:
library(dplyr)
data1 <- filter(mtcars, cyl == 6)
data2 <- filter(mtcars, cyl == 4)
my_db <- src_sqlite(path="Test.DB", create = TRUE)
copy_to(my_db, data1, temporary = FALSE)
db_insert_into(my_db, table=data1, values=data2) # Error
However, I get the following error:
Error in UseMethod("db_insert_into") : no applicable method for 'db_insert_into' applied to an object of class "c('src_sqlite', 'src_sql', 'src')"
Would anyone be able to point out what I'm doing wrong?
Thanks, Philipp