export | R Documentation |
This function is convenient if you plan on repeatedly appending to a table in a database.
All that is required is a database connection and a data.frame you want to export to that database.
If you want to initiate a table with more columns use the template
argument.
Note that if the table already exists, the template
argument will be ignored.
export(connect, value, name, template, ...)
connect |
database connection. |
value |
local data frame. |
name |
name of the remote table. |
template |
a named character vector. The names of the vector should contain the names of |
... |
arguments passed onto |
## Not run:
library(dplyr)
my_db <- src_sqlite("DB.sqlite3")
data(pitches, package="pitchRx")
# Creates the 'pitches' table in the database
export(connect=my_db$con, value=pitches, name="pitches")
# Appends to the 'pitches' tables, but with the first column missing
export(connect=my_db$con, value=pitches[,-1], name="pitches")
tail(data.frame(collect(tbl(my_db, "pitches")))) #verify it appends correctly
# This data frame has a column that doesn't exist in the pitches table --
# so a new table is created.
export(connect=my_db$con, value=cbind(pitches, test="works"), name="pitches")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.