null_replace | R Documentation |
Replace NA/NULL is specified columns with the given replacement value.
null_replace(src, cols, value, ..., note_col = NULL, env = parent.frame())
src |
relop or data.frame data source. |
cols |
character, columns to work on. |
value |
scalar, value to write. |
... |
force later arguments to bind by name. |
note_col |
character, if not NULL record number of columns altered per-row in this column. |
env |
environment to look to. |
null_replace node or data.frame.
count_null_cols
, mark_null_cols
if (requireNamespace("DBI", quietly = TRUE) && requireNamespace("RSQLite", quietly = TRUE)) {
my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
d1 <- rq_copy_to(my_db, 'd1',
data.frame(A = c(NA, 2, 3, NA), B = c(3, NA, 4, NA)))
optree <- null_replace(d1, qc(A, B),
0.0, note_col = "alterations")
cat(format(optree))
sql <- to_sql(optree, my_db)
cat(sql)
print(DBI::dbGetQuery(my_db, sql))
DBI::dbDisconnect(my_db)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.