verify_expected: Verify inclusion of expected predictions

Description Usage Arguments Value Note Examples

View source: R/verify_expected.R

Description

Function to check a set of predictions for a set of expected predictions (e.g. targets, locations)

Usage

1
verify_expected(x, expected_list, return_df = FALSE, print_output = !return_df)

Arguments

x

predx_df

expected_list

list of lists (see Note)

return_df

if TRUE (default is FALSE) will return a list of missing predictions

print_output

if TRUE (default) prints results

Value

If any predictions in expected_list are not found or if additional predictions are found, the function will print the missing and/or additional rows (print_out = TRUE) or return a data frame with a status designation for each missing and/or additional row (return_df = TRUE).

Note

expected_list is a two-level list of sets of expected predictions. The lower level (e.g. expected_list[[1]]) is a list of named character vectors with specific expected predictions. The names should match column names in x. The function checks that all combinations of those elements are present in x. A named vector predx_class may be used to check predx types.

Examples

 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
predx_demo <- as.predx_df(list(
  location = c("Mercury", "Venus", "Earth"),
  target = "habitability",
  predx = list(Binary(1e-4), Binary(1e-4), Binary(1))
))

expected_demo <- list(
  list(
    location = c("Mercury", "Venus", "Earth"),
    target = "habitability",
    predx_class = "Binary"
  )
)


expected_demo2 <- list(
  list(
    location = c("Mercury", "Mars"),
    target = "habitability",
    predx_class = "Binary"
  )
)

verify_expected(predx_demo, expected_demo)
verify_expected(predx_demo, expected_demo2)

cdcepi/predx documentation built on Dec. 29, 2019, 4:58 p.m.