`r params$title`"

knitr::opts_chunk$set(echo = FALSE, comment="");

if (!exists('headingLevel') || !is.numeric(headingLevel) || (length(headingLevel) != 1)) {
  headingLevel <- 0;
}
codeLabels <-
  stats::setNames(x$codes$code_label, x$codes$code_id);
codeDescriptions <-
  stats::setNames(x$codes$code_description, x$codes$code_id);
codeInstructions <-
  stats::setNames(x$codes$code_instruction, x$codes$code_id);

for (currentCodeId in x$codes$code_id) {

  rock::heading(
    paste0(
      codeLabels[currentCodeId],
      " (code identifier: `", currentCodeId, "`)"
    ),
    headingLevel = headingLevel
  );

  rock::heading(
    "Description",
    headingLevel = headingLevel + 1
  );

  cat("\n\n",
      codeDescriptions[currentCodeId],
      "\n\n");

  rock::heading(
    "Coding instruction",
    headingLevel = headingLevel + 1
  );

  cat("\n\n",
      codeInstructions[currentCodeId],
      "\n\n");

  tmpDf <-
    x$examples[
      x$examples$code_id == currentCodeId,
      c("example_fragment", "core_or_edge", "hit_or_miss", "example_explanation")
    ];

  if (nrow(tmpDf) > 0) {

    rock::heading(
      "Examples",
      headingLevel = headingLevel + 1
    );

    cat(
      paste0(
        "\n- ",
        tmpDf[, "example_fragment"],
        " *(",
        tmpDf[, "core_or_edge"],
        " ",
        tmpDf[, "hit_or_miss"],
        "; ",
        tmpDf[, "example_explanation"],
        ")*",
        collapse = "\n"
      ),
      sep = ""
    );

  }

}


Try the rock package in your browser

Any scripts or data that you put into this service are public.

rock documentation built on May 29, 2024, 11:30 a.m.