knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  echo = FALSE
)
library(hera)
library(dplyr)
library(purrr)
library(tidyr)
library(tibble)
library(magrittr)
library(testthat)
#  library(visNetwork)

Welcome

This document has been created following the generic assessment guidance.

Description

Basic details about the assessment. Update the 'response' values as required.

description <- tribble(
  ~question, ~response,
  "name_short", "MPFF Compliance",
  "name_long", "Marine Pen Fish farm Compliance",
  "parameter", "Marine Benthic Inverts",
  "status", "prototype",
  "type", "compliance"
)

knitr::kable(description)

Input

A list of questions required to run the assessment.

file <- system.file("extdat",
  "demo-data/220421-SelfMon-N4952-CAV1-Enhanced.xlsx",
  package = "hera"
)
input <- survey_import(file)

data <- input
data <- select(data, question, response)
data <- data[!duplicated(data[, c("question")]), ]

knitr::kable(data)

Assessment

If applicable, write a function to assess your input data and return an outcome. For example, a metric, statistic, prediction etc.

assessment_function <- function(data, ...) {
  data <- dplyr::filter(data, parameter == "MPFF Compliance")
  if (nrow(data) > 0) {
    results <- kraken::kraken(data, hera_format = TRUE, loess = TRUE)
  } else {
    return(NULL)
  }

  return(results)
}

Outcome

The outcome of your assessment.

outcome <- assessment_function(input)
outcome_table <- select(outcome, question, response)
outcome_table <- outcome_table[!duplicated(outcome_table[, c("question")]), ]
knitr::kable(outcome_table)

Check

Run checks on the assessment.

# No need to edit this code
# Format description
standard_format <- hera:::hera_format(description = description)
# Check description
check_list <- hera:::hera_test(description = description)
knitr::kable(check_list$standard_check)

Update

Update the catalogue of assessments to make them available.

# No need to edit this code
hera:::update_catalogue(
  description = description,
  input = input,
  assessment_function = assessment_function,
  output = outcome
)

After updating the catalogue, rebuild the package, click on Build > Install and Restart menu or 'Install and Restart' button in the Build pane.

Test

This section tests if this assessment is usable using assessment function.

# No need to edit this code
# assess(
#   data = hera::demo_data,
#   name = description$response[description$question == "name_long"]
# )

Launch app

Below is an interactive application displaying the results of your assessment.

# No need to edit this code
# launch_app(new_catalogue = catalogue, data = data)


ecodata1/hera documentation built on April 5, 2025, 1:48 a.m.