knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Just as the correctness of data analysis code should be tested automatically, the
consistency of data should be evaluated and monitored as well. Using BacDive's advanced search
and BacDiveR's bd_retrieve_by_search()
several examples of geographic inconsistencies have been found. Presumably due to
an overly strict location-to-country-to-continent mapping, several samples collected
from seas neighbouring Russia (like the Sea of Japan),
were assigned to Europe.
While one may debate where exactly in Russia the Asian-European border is located, it is clear that its Eastern shoreline is located well within Asia. These and other datasets with East Russian locations have been reported to the BacDive team and a portion of those was corrected in BacDive's 04.07.2018 release.
library(BacDiveR) mismatched <- list(location = "Japan", continent = "Europe") inconsistent_data <- bd_retrieve_by_search( paste0( "https://bacdive.dsmz.de/advsearch?advsearch=search&site=advsearch", "&searchparams[20][typecontent]=contains", "&searchparams[20][searchterm]=", mismatched$location, "&searchparams[17][searchterm]=", mismatched$continent ) )
As long as this specific inconsistency is not corrected in the datasets, some should be found and downloaded here.
If a BacDive user finds an inconsistency within the datasets they use, BacDiveR's
bd_retrieve_by_search()
can be used to construct a test-case for such a problem.
In the following example, the test fails as long as BacDive contains datasets with
the above-described discrepancy between the geo_loc_name
and continent
fields.
library(testthat) test_that("No inconsistent datasets exist", { expect_null(inconsistent_data) })
Once the inconsistency is corrected in BacDive, the advanced search returns no results any more, and the above test passes. It can thus be used to monitor the resolution of such a problem after reporting it. Furthermore, the users is alerted (by the test failing again) in case new datasets appear in BacDive with the same inconsistency.
See testthat.R-lib.org and the related "R Packages" chapter to learn more about testing in R [@TT; @T].
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.