rules_to_query: Transform a rule set in a search query

View source: R/Rule_building.R

rules_to_queryR Documentation

Transform a rule set in a search query

Description

The rules produced by extract_rules() and modified by the other tools in the framework are in a format ready for using as boolean filtering tools in R, for example by using eval(str2expression(rule))). To be used online with citation database they need to be converted in another format.

Usage

rules_to_query(rules)

Arguments

rules

A vector of rules.

Value

A string with the rules joined and transformed into a format ready for online use.

Examples


rules <- c(
  'V__network._.patient %in% "1" & V__patient_transport %in% "1" &
  V__transmission %in% "1" & V__personnel %in% "0" & V__therapy %in% "0"',
  'V__Donker_T %in% "1" & V__bacterium_isolate %in% "0" & V__able %in% "0"',
  'V__network._.patient %in% "1" & V__resistant_staphylococcus_aureus %in% "1"
  & V__carlo.monte.carlo._.monte %in% "0"'
)

new_query <- rules_to_query(rules)

## Not run: 
# Produce a new query from a rule review file:

candidate_queries <- readRDS(file.path("Sessions", "Session1", "rule_data.rds"))

Target <- candidate_queries$DTM$Target
SpecificDTM <- candidate_queries$SpecificDTM

simplified_rules <- file.path(
  "Sessions", "Session1",
  "Selected_rules_reviewed.xlsx"
) %>%
  import_data() %>%
  simplify_ruleset(target_vec = Target, target_data = SpecificDTM) %>%
  pull(rule)

new_query <- rules_to_query(simplified_rules)

writeLines(rules_to_query, file.path("Sessions", "Session1", "Resulting_query.txt"))

## End(Not run)

bakaburg1/BaySREn documentation built on March 30, 2022, 12:16 a.m.