update_table | R Documentation |
updates the data.table-like object to
based on the data.frame-like from
object,
using date_column
to determine which rows have been updated and updating only those with matching primary_keys
.
update_table(
from,
to,
date_column = NULL,
primary_keys = NULL,
delete = FALSE,
incremental = TRUE,
...
)
## Default S3 method:
update_table(
from,
to,
date_column = NULL,
primary_keys = NULL,
delete = FALSE,
incremental = TRUE,
...
)
## S3 method for class 'data.table'
update_table(
from,
to,
date_column = NULL,
primary_keys = NULL,
delete = FALSE,
incremental = TRUE,
...
)
update_table_date_only(from, to, date_column = NULL, prefer = "to")
## S3 method for class 'data.table'
update_table_date_only(from, to, date_column = NULL, prefer = "to")
## Default S3 method:
update_table_date_only(from, to, date_column = NULL, prefer = "to")
from |
the source object |
to |
the object to be updated |
date_column |
string or tidy-selected column identifying the date column to use to determine which rows to update |
primary_keys |
vector of strings or tidy-selected columns identifying the primary keys to determine which rows to update |
delete |
whether to delete rows in |
incremental |
whether or not to update the table incrementally or to simply overwrite the existing table with a new one,
the default is |
... |
Arguments passed on to |
prefer |
"from" or "to": which table to prefer on conflict during a date-only update.
The default is to prefer the destination table, so that existing data in |
a data.table updated in-place
update_table_date_only()
: update incrementally when primary_keys not given but date_column given
update_table_date_only(data.table)
: update incrementally when primary_keys not given but date_column given
update_table_date_only(default)
: update incrementally when primary_keys not given but date_column given
library(data.table)
expect <- data.table(expand.grid(x = 1:100, y = 1:100))[, data := runif(.N)]
# divide the data
from <- copy(expect)[1:9000]
to <- copy(expect)[1000:10000]
# and mung it up
to[1:5000, data := runif(.N)]
update_table(from, to, primary_keys = c(x, y)) == expect
# TRUE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.