Description Usage Arguments Value Examples
View source: R/OutputDatabase.R
Check that cells of dbOutput agree with corresponding cells of another database
1 2 3 4 5 6 7 | dbOut_check_values(
dbOut_fname,
dbNew_fname,
fields_check = NULL,
tol = 0.001,
verbose = FALSE
)
|
dbOut_fname |
A character string. The file path of the main
|
dbNew_fname |
A character string. The file path of a database with
values that are to be compared against |
fields_check |
A named list of vectors with character strings. The
field names per table that are used must have equal values in the original
and the new database for a record to be checked. If |
tol |
A numeric value. Differences smaller than tolerance are not considered. |
verbose |
A logical value. |
The connection to an in-memory database with one table that tracks
which records (identified by P_id
) agree (value 1) and which
records do not agree (value 0) for each table (as field names). Value of
records that were not compared is NA
/NULL
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ## Not run:
if (requireNamespace("RSQLite") && exists("SFSW2_prj_meta")) {
con_dbCheck <- dbOut_check_values(
dbOut_fname = SFSW2_prj_meta[["fnames_out"]][["dbOutput"]],
dbNew_fname = "path/to/new.sqlite3",
fields_check = list(
aggregation_overall_mean = c("MAT_C_mean", "MAP_mm_mean"),
aggregation_overall_sd = c("MAT_C_sd", "MAP_mm_sd"),
)
)
tables <- RSQLite::dbListTables(con_dbCheck)
tables <- tables[1] # example table
fields <- RSQLite::dbQuoteIdentifier(con_dbCheck,
RSQLite::dbListFields(con_dbCheck, tables))
# Extract Pids from records that matched up for example table
sql <- paste("SELECT P_id FROM", tables, "WHERE",
paste(fields[-1], "= 1", collapse = " AND "))
is_good <- RSQLite::dbGetQuery(con_dbCheck, sql)
# Extract Pids from records that did not match up; this should be empty
sql <- paste("SELECT P_id FROM", tables, "WHERE",
paste(fields[-1], "= 0", collapse = " OR "))
is_bad <- RSQLite::dbGetQuery(con_dbCheck, sql)
}
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.