knitr::opts_chunk$set(echo = TRUE)

Check data

This is an R Markdown document that checks data that has passed initial delivery QC and is now in the test phase.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document.

Load library and data

scriptstart = Sys.time()
library(SHARK4R)
library(tidyverse)
library(DT)
setwd(params$targetDirectory)
myfile = shark_read_zip(params$targetDataset)

Set conditions

# execute code depending on datatype
do_it_bact = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'Bacterioplankton'
do_it_chl = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'Chlorophyll'
do_it_epi = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'Epibenthos'
do_it_grey = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'GreySeal'
do_it_harbp = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'HarbourPorpoise'
do_it_harbs = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'HarbourSeal'
do_it_phychem = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'PhysicalChemical'
do_it_phyto = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'Phytoplankton'
do_it_pico = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'Picoplankton'
do_it_pp = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'PrimaryProduction'
do_it_ring = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'RingedSeal'
do_it_sealpath = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'SealPathology'
do_it_sed = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'Sedimentation'
do_it_zoob = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'Zoobenthos'
do_it_zoop = sub("^[^_]*_([^_]*).*", "\\1", params$targetDataset) == 'Zooplankton'

Check fields

Uses check_fields() function to control if all required fields are present.

check_datatype(myfile)
check_Bacterioplankton(myfile)
check_Chlorophyll(myfile)
check_Epibenthos(myfile)
check_EpibenthosDropvideo(myfile)
check_GreySeal(myfile)
check_HarbourPorpoise(myfile)
check_HarbourSeal(myfile)
check_PhysicalChemical(myfile)
check_Phytoplankton(myfile)
check_Picoplankton(myfile)
check_PrimaryProduction(myfile)
check_RingedSeal(myfile)
check_Sedimentation(myfile)
check_SealPathology(myfile)
check_Zoobenthos(myfile)
check_Zooplankton(myfile)

Overview of data

glimpse(myfile)
DT::datatable(myfile)

Check map

Uses plot_map_leaflet to render an interactive leaflet map of sampled stations in the data.

plot_map_leaflet(myfile)

Check station name and geographical bounding box

Uses check_stations() to control if station name is found in the SMHI curated list and location is within preset distance limit

# check_stations(myfile)

Check onland

Uses check_onland() to control if any locations are on land.

# check_onland(myfile)

Check depth

Uses check_depth() to control if any sample depths are incorrect.

# check_depth(myfile)

Check outliers

Uses check_outliers() function to control if all values are within range.

check_bacterial_carbon(myfile)
check_bacterial_concentration(myfile)
check_bacterial_production(myfile)
check_chlorophyll_conc(myfile)
check_epibenthos_counted(myfile)
check_epibenthos_dryweight(myfile)
check_epibenthos_specdistr_maxdepth(myfile)
check_epibenthos_specdistr_mindepth(myfile)
check_greyseal_counted(myfile)
check_harbporp_positivemin(myfile)
check_harbourseal_counted(myfile)
#check_phychem_(myfile)
check_phytoplankton_abund(myfile)
check_phytoplankton_biovol(myfile)
check_phytoplankton_carbon(myfile)
check_picoplankton_abundance(myfile)
check_picoplankton_biovol(myfile)
check_picoplankton_carbon(myfile)
check_picoplankton_counted(myfile)
check_primaryproduction_carbonprod(myfile)
check_primaryproduction_carbonprod_hour(myfile)
check_primaryproduction_carbonprodlight(myfile)
check_ringedseal_calccounted(myfile)
#check_sealpathology_(myfile)
#check_sedimentation_(myfile)
check_zoobenthos_abund(myfile)
check_zoobenthos_BQIm(myfile)
check_zoobenthos_counted(myfile)
check_zoobenthos_wetweight(myfile)
check_zooplankton_abund(myfile)
check_zooplankton_carbon(myfile)
check_zooplankton_counted(myfile)
check_zooplankton_length_mean(myfile)
check_zooplankton_length_median(myfile)
check_zooplankton_wetweight(myfile)
check_zooplankton_wetweight_area(myfile)
check_zooplankton_wetweight_volume(myfile)

Check logical

Uses check_logical() function to control if data follows logical assumptions.

check_value_logical(myfile)
check_value_logical(myfile)
check_epibenthos_abundclass_logical(myfile)
check_epibenthos_cover_logical(myfile)
check_epibenthos_coverclass_logical(myfile)
check_epibenthos_coverpercent_logical(myfile)
check_epibenthos_sedimentdepos_logical(myfile)
check_epibenthos_totcover_logical(myfile)
check_zoobenthos_BQIm_logical(myfile)
check_zoobenthos_wetweight_logical(myfile)

Check codes

Uses check_codes() function to control if data follows the SMHI codelist.

check_code_proj(myfile)

Match taxa

Uses match_dyntaxa_taxa() to find and match taxa names provided in the data against the Dyntaxa database. In addition to the Dyntaxa match it is recommended to run the match_taxa() function to match against the WoRMS database.

match_dyntaxa(myfile$scientific_name)
# match_taxa(myfile$scientific_name)

Reproducibility

# Date time
Sys.time()

# Here we store the session info for this script
sessioninfo::session_info()

Runtime of script

scriptend = Sys.time()
print(scriptend-scriptstart)


sharksmhi/SHARK4R documentation built on Jan. 9, 2025, 5:15 p.m.