check_results() checks a results object against the contract of the
results file. It reports each of its 6 rules as PASS, FAIL or SKIP, and it
does not print or stop.
Usage
check_results(x, home = NULL, messages = writeit_messages())Arguments
- x
The results object.
- home
NULL, or the folder that holds the files that the manifest names. The ruleresults_currentcompares each md5 in the manifest with the file atfile.path(home, <name>). WithNULL, it gives SKIP.- messages
The texts that name a function in a detail, a named list as
writeit_messages()gives. The details use its elementwriter.
Value
A data.frame with 6 rows, one for each rule, and the columns
rule, status and detail. status is "PASS", "FAIL" or
"SKIP".
Details
A list with no element manifest is a legacy result: something wrote it
before the manifest. On a legacy result, the rules manifest_data,
manifest_source and results_current give SKIP. The rule
element_names gives FAIL on a fault in the names and SKIP otherwise.
SKIP means that the rule could not compare. It is never a PASS.
The 6 rules, in the order of the rows:
element_names:xis a list and not a data.frame. Each element has a name. Each name is syntactic, somake.names()does not change it, and no name is there twice. The elementmanifestis there at most once.allowed_objects: each element at each depth is a data.frame, an atomic vector of any class,NULL, or a list of any class. The walk goes into each list, each column of a data.frame and each attribute, and it writes the path of an attribute asattr(x$a, "terms"). It skips the attributes that R and data.table set:names,dim,dimnames,row.names,class,levels,tzone,units,comment,sorted,indexand.internal.selfref.The rule fails these objects, and the detail names the path, the class and a fix of each:
a function, an environment, a call, a formula, a name and an external pointer.
an S4 object and an R6 object.
a fitted model of the class
lm,glm,gam,merMod,brmsfit,coxphorlavaan.
no_row_per_person: no element at any depth has one value for each row of the data. The walk skipsmanifestandexclusions.exclusionsis a table with one row for each step, so k steps and k people would fail it. The rule reads the row counts in the optional manifest fieldsn_rows_data,n_rows_before_exclusions,n_rows_after_exclusionsandn_rows_lists. For each countnof 2 or more, it fails these objects:a data.frame with
nrows.an atomic vector of length
n.a matrix or an array with a dimension
n.
When there is no count of 2 or more, it gives PASS and says that it checked nothing.
manifest_data: whenmanifest$data_filesis there, it MUST be a data.frame with the columnsfile,sizeandmtime, or those andmd5. Its values MUST obey these rules:each
fileis a name that is not empty and comes once.each
sizeis a number of 0 or more.each
mtimeis a number.each
md5is 32 lower-case hex digits orNA.
Without
data_files, the rule gives PASS.manifest_source:manifest$source_md5is a named character vector of one or more md5 values, each 32 lower-case hex digits. Each name is there once and is not empty.results_current: each md5 ofsource_md5, and each md5 ofdata_filesthat is notNA, is the md5 of its file inhome. The rule gives FAIL and names each file that differs. It gives SKIP whenhomeisNULL, when a file is not inhome, or when the manifest records no md5. It gives PASS only when it compared each md5.
See also
Other results:
write_results(),
writeit_messages()
Examples
x <- list(
manifest = list(
version = "v01",
source_md5 = c(run.R = "fedcba9876543210fedcba9876543210"),
data_files = data.frame(file = "main/d.csv", size = 120, mtime = 1.8e9),
n_rows_data = 100L
),
estimates = data.frame(term = "x", estimate = 1.2),
p_interaction = 0.04
)
check_results(x)
#> rule status
#> 1 element_names PASS
#> 2 allowed_objects PASS
#> 3 no_row_per_person PASS
#> 4 manifest_data PASS
#> 5 manifest_source PASS
#> 6 results_current SKIP
#> detail
#> 1 manifest, and each other element with a unique syntactic name
#> 2 each element is a data.frame, an atomic vector, NULL or a list of these
#> 3 no data.frame has 100 rows, and no vector or matrix has 100 values in one dimension
#> 4 manifest$data_files names each data file once, with its size and mtime
#> 5 the manifest has source_md5, with the md5 of each source file
#> 6 home is NULL, so no file to compare
# A legacy result, written before the manifest.
check_results(list(estimates = data.frame(term = "x", estimate = 1.2)))
#> rule status
#> 1 element_names SKIP
#> 2 allowed_objects PASS
#> 3 no_row_per_person PASS
#> 4 manifest_data SKIP
#> 5 manifest_source SKIP
#> 6 results_current SKIP
#> detail
#> 1 x has no manifest, so it was written before the manifest. Write it again with writeit::write_results() to check this rule
#> 2 each element is a data.frame, an atomic vector, NULL or a list of these
#> 3 n_rows_data is NA, so nothing to check
#> 4 x has no manifest, so it was written before the manifest. Write it again with writeit::write_results() to check this rule
#> 5 x has no manifest, so it was written before the manifest. Write it again with writeit::write_results() to check this rule
#> 6 x has no manifest, so it was written before the manifest. Write it again with writeit::write_results() to check this rule