# Don't show R code in output
knitr::opts_chunk$set(echo = FALSE)
# Load useful libraries
library(hera)
library(tidyverse)
library(ggmap)
library(ggrepel)

Introduction

This is a demo report...

Results

Some results...

# Import data
data <- get_data(
  location_id = params$location_id
)

# Add all calculated metrics like DARLEQ2 and ePSI etc
# data <- assess(data)

# Filter on NEMS or calculated determinands if provided
data <- filter(data, question %in% c(params$question))

# Convert response to numeric
data$response <- as.numeric(data$response)

# Select a few columns to display - to check import worked and data looks okay
selected_data <- select(data, location_id, question, response, date_taken)
# Format date_taken into more readable format
selected_data$date_taken <- format(selected_data$date_taken, "%d-%b-%Y")
# Display the 'head' - in other words, first few lines of data
knitr::kable(head(selected_data), format = "simple")

Analysis

Determinand Summary

# Make line/point plot showing 'date_date' and WHPT ASPT Abund 'value'
plot <- ggplot(data, aes(x = date_taken, y = response)) +
  geom_line() +
  geom_point() +
  xlab("Date Sampled") +
  ylab("Value") 
# +
  # facet_wrap(vars(location_id, question),
  #   ncol = 3,
  #   labeller = label_wrap_gen(width = 25, multi_line = TRUE)
  # ) # give each 'location' or facet a separate plot and wrap
# label over multiple lines.

plot

Sampling Location Map

# Select required columns and get unique for each location
# map_data <- select(
#   data,
#   location_id,
#   latitude,
#   longitude
# ) %>%
#   unique()
# 
# # Create map using ggmap and point/scatter plot using ggplot2 libraries.
# # Note, geom_label_repel prevents overlapping labels.
# plot <- qmplot(
#   x = longitude,
#   y = latitude,
#   data = map_data,
#   colour = location
# ) +
#   geom_point(aes(x = longitude, y = latitude),
#     size = 0.5
#   ) +
#   geom_label_repel(
#     data = map_data,
#     aes(longitude, latitude, label = location_code),
#     color = "black",
#     alpha = 0.5,
#     point.padding = unit(0.3, "lines")
#   )
# 
# plot

Conclusion

There are a total of r length(unique(data$location)) # example of "inline" code sampling locations within this dataset...



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