R interface to the peatland mid infrared database
pmird is an interface to the peatland mid infrared spectra database
(pmird database) (Teickner and Knorr 2025). ‘pmird’ allows to access the
pmird database as dm
object.
The pmird package can be installed as follows:
remotes::install_github("henningte/pmird")
The pmird database can be downloaded from Zotero (Teickner and Knorr 2025). The downloaded database needs to be imported in a running MariaDB instance. In a linux terminal, the downloaded sql file can be imported like so:
mysql -u<user> -p<password> pmird < pmird-backup-2025-04-03.sql
Here, and are the respective database user name and password.
The database itself does not contain the infrared spectra. These data
are in folder pmird_prepared_data
which needs to be stored at any
place in the file system.
Once the database is set up and runs in a ‘MariaDB’ instance, it can be accessed from within R, using the ‘RMariaDB’ package (Müller et al. 2021):
library(pmird)
library(RMariaDB)
library(magrittr)
library(ir)
#> Registered S3 methods overwritten by 'tibble':
#> method from
#> format.tbl pillar
#> print.tbl pillar
library(quantities)
#> Loading required package: units
#> Warning: package 'units' was built under R version 4.0.5
#> udunits database from /usr/share/xml/udunits/udunits2.xml
#> Loading required package: errors
# connect to database
con <-
RMariaDB::dbConnect(
drv = RMariaDB::MariaDB(),
dbname = "pmird",
default.file = "~/my.cnf",
groups = "rs-dbi"
)
Here, my.cnf
is a text file that stores user and password information
for the database server.
From this on, the ‘pmird’ R package can be used to access the database.
The ‘pmird’ R package makes use of the R package ‘dm’ (Schieferdecker,
Müller, and Bergant 2022) to access and manipulate the database
contents. pmird::pm_get_dm()
creates a dm
object which stores the
database structure.
# create the dm object
dm_pmird <- pmird::pm_get_dm(con, learn_keys = TRUE)
The option learn_keys = TRUE
means that information on the primary and
foreign key are added to the dm object.
A dm
object is a representation of the entire database and allows
comfortable manipulation of the database from within R (e.g. addition of
new rows to tables, addition of new tables, data queries)
(Schieferdecker, Müller, and Bergant 2022).
General information on the datasets contained in the ‘pmird’ database
are stored in table datasets
. The ‘pmird’ R package provides a
function to obtain this table from the dm
object
(pmird::pm_get_table(.table_name = "datasets)
).
# extract the datasets table
pmird_datasets <-
dm_pmird %>%
pmird::pm_get_table(.table_name = "datasets")
This table can, for example, be used to select studies for which to extract data from the ‘pmird’ database.
< 8000 div class="markdown-heading" dir="auto">