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)
This document has been created following the generic assessment guidance.
Basic details about the assessment. Update the 'response' values as required.
description <- tribble( ~question, ~response, "name_short", "Macroinvertebrate Metrics", "name_long", "Freshwater Macroinvertebrate Metrics", "parameter", "River Invertebrates", "status", "prototype", "type", "metric" ) knitr::kable(description)
A list of questions required to run the assessment.
input <- tribble( ~sample_id, ~question, ~response, ~label, ~parameter, ~type, ~max, ~min, ~source, "12345", "Taxon abundance", "12", "Baetidae", "River Family Inverts", "number", NA, NA, "sepa_ecology_results", "12345", "Live abundance", "12", "Baetidae", "BANKSIDE_INVERTS", "number", NA, NA, "sepa_ecology_results" ) data <- input data <- select(data, question, response) data <- data[!duplicated(data[, c("question")]), ] knitr::kable(data)
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, ...) { # Calculated invert metrics... # Note, any non-standard base R library must be call using require(). require(dplyr) require(whpt) require(macroinvertebrateMetrics) input <- data input$label <- trimws(input$label) input <- dplyr::filter( input, parameter %in% c( "River Family Inverts", "BANKSIDE_INVERTS" ) ) input <- dplyr::filter(input, question %in% c( "Taxon abundance", "Live abundance" )) if(nrow(input) < 1) { return(NULL) } input <- ungroup(input) input <- dplyr::select( input, "sample_id", "question", "response", "label", "parameter" ) output <- macroinvertebrateMetrics::calc_metric(input) # riverfly <- macroinvertebrateMetrics::calc_riverfly(input) # output <- dplyr::bind_rows(whpt, riverfly) output <- dplyr::select( output, "sample_id", "question", "response","parameter" ) names(output) <- c("sample_id", "question", "response","parameter") return(output) }
The outcome of your assessment.
# data <- get_data(location_id = 8175) # outcome <- assessment_function(data) outcome <- assessment_function(input) outcome_table <- select(outcome, question, response) outcome_table <- outcome_table[!duplicated(outcome_table[, c("question")]), ] knitr::kable(outcome_table)
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 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.
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_short"] # )
Below is an interactive application displaying the results of your assessment.
# No need to edit this code # launch_app(new_catalogue = catalogue, data = data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.