Skip to contents

The function checks the requirements for terms for queries provided by the user. The terms could have been provided directly in the query definition or via a user provided function for accessing a SMQ or SDG database.

Usage

assert_terms(
  terms,
  expect_query_name = FALSE,
  expect_query_id = FALSE,
  source_text
)

Arguments

terms

Terms provided by user

expect_query_name

Is the QUERY_NAME column expected?

expect_query_id

Is the QUERY_ID column expected?

source_text

Text describing the source of the terms, e.g., "the data frame provided for the definition element".

Value

An error is issued if

  • terms is not a data frame,

  • terms has zero observations,

  • the TERM_LEVEL variable is not in terms,

  • neither the TERM_NAME nor the TERM_ID variable is in terms,

  • expect_query_name == TRUE and the QUERY_NAME variable is not in terms,

  • expect_query_id == TRUE and the QUERY_ID variable is not in terms,

Examples


try(
  assert_terms(
    terms = 42,
    source_text = "object provided by the `definition` element"
  )
)
#> Error in assert_terms(terms = 42, source_text = "object provided by the `definition` element") : 
#>   object provided by the `definition` element is not a data frame but `42`.