knitr::opts_chunk$set(echo = FALSE)
library(tidyverse)
library(visNetwork)
library(knitr)
library(kableExtra)
library(hera)
library(shiny)

Vocabulary

  hera::catalogue$data
vocab <- read_csv(system.file("extdat",
  "data-flow/vocab.csv",
  package = "hera"
))

html_output <- purrr::map(split(vocab, vocab$Name), function(assessment) {
  output <- c(
    paste("<h2>", unique(assessment$Name), "</h2>"),
    kable(assessment[, c(3, 2)], row.names = FALSE, col.names = c("", ""), format = "html"),
    "<button><a href = 'https://github.com/ecodata1/hera/issues'>Create Issue</a></button>",
    "<button><a href = 'https://github.com/ecodata1/hera/tree/main/inst/extdat/data-flow/vocab.csv'>Edit Source</a></button>"
  )
})

shiny::HTML(unlist(html_output))
questions <- questions()

kable(questions[, 1:3], format = "html", escape = FALSE) %>%
  kable_styling(bootstrap_options = c("hover", "condensed"))
high_level_flows <- read_csv(system.file("extdat",
  "data-flow/high-level-flows.csv",
  package = "hera"
))

nodes <- high_level_flows %>%
  select(label, group, level, shape) %>%
  unique() %>%
  na.omit() %>%
  rename("id" = label)

visNetwork(nodes, high_level_flows, width = "100%") %>%
  visEdges(arrows = "to") %>%
  visNodes(
    shadow = list(enabled = TRUE, size = 10),
    size = 50
  ) %>%
  # visGroups(groupname = "question", color = "lightgreen") %>%
  # visGroups(groupname = "data_source", color = "lightblue") %>%
  # visLegend() %>%
  visOptions(highlightNearest = list(enabled = T, degree = 2, hover = T)) %>%
  visHierarchicalLayout(direction = "LR", levelSeparation = 150) %>%
  visOptions(
    highlightNearest = list(enabled = T, hover = T),
    nodesIdSelection = T
  ) %>%
  visInteraction(
    dragNodes = FALSE,
    dragView = FALSE,
    zoomView = FALSE
  ) %>%
  visExport(type = "png")
high_level_flows <- read_csv("../inst/extdat/data-flow/high-level-flows.csv")

high_level_flows <- high_level_flows %>%
  filter(assessment == "visual survey")


nodes <- high_level_flows %>%
  select(label, group, level, shape) %>%
  unique() %>%
  na.omit() %>%
  rename("id" = label)

visNetwork(nodes, high_level_flows, width = "100%") %>%
  visEdges(arrows = "to") %>%
  visNodes(
    shadow = list(enabled = TRUE, size = 10),
    size = 50
  ) %>%
  # visGroups(groupname = "question", color = "lightgreen") %>%
  # visGroups(groupname = "data_source", color = "lightblue") %>%
  # visLegend() %>%
  visOptions(highlightNearest = list(enabled = T, degree = 2, hover = T)) %>%
  visHierarchicalLayout(direction = "LR", levelSeparation = 150) %>%
  visOptions(
    highlightNearest = list(enabled = T, hover = T),
    nodesIdSelection = T
  )
high_level_flows <- read_csv("../inst/extdat/data-flow/high-level-flows.csv")


# high_level_flows <- high_level_flows %>%
#   filter(assessment == "Benthic Marine eDNA")


nodes <- high_level_flows %>%
  select(label, group, level, shape) %>%
  unique() %>%
  na.omit() %>%
  rename("id" = label)

high_level_flows <- high_level_flows %>% select(-label)

visNetwork(nodes, high_level_flows, width = "100%") %>%
  visEdges(arrows = "to") %>%
  visNodes(
    shadow = list(enabled = TRUE, size = 10),
    size = 50
  ) %>%
  # visGroups(groupname = "question", color = "lightgreen") %>%
  # visGroups(groupname = "data_source", color = "lightblue") %>%
  # visLegend() %>%
  visOptions(highlightNearest = list(enabled = T, degree = 2, hover = T)) %>%
  visHierarchicalLayout(direction = "LR", levelSeparation = 150) %>%
  visOptions(
    highlightNearest = list(enabled = T, hover = T),
    nodesIdSelection = T 
  )


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