---
title: "Introduction"
subtitle: "R Statistical Language for EPR - A Comprehensive Rationale"
output: 
  bookdown::html_document2:
    base_format: rmarkdown::html_vignette
    mathjax: "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml-full.js"
toc: FALSE    
number_sections: FALSE
fig_caption: TRUE
link-citations: TRUE
bibliography: introduction.bib
csl: iso690-numeric-en.csl
vignette: >
  %\VignetteIndexEntry{Introduction}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
pkgdown:
  as_is: TRUE
---

```{r knitr-setup, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.width = 7.2,
  fig.height = 4.8
)
```

```{r setup, include = FALSE}
library(eprscope)
library(icons)
library(knitr)
icons::download_ionicons()
```

The usual way of a spectroscopist workflow consists in data transformation from the instrument via creation of figures and tables and finally using them in reports, publications, thesis or presentations. Quite often several software packages/tools may be applied on this path including the proprietary ones. Among them, an acquisition/processing software at the instrument enables basic or more advanced operations with the EPR outcomes/spectra. As already mentioned (see the [README file / Homepage](https://jatanrt.github.io/eprscope/index.html)) there is an excellent open source toolbox for EPR specialists [@Easyspin2024] only working under proprietary *MATLAB* [@Matlab2024]. It can handle the raw files from the EPR machines process them and create reports in an interactive form [@MatlabLE2024] or in `.pdf`. There are, however, only a few examples of fully open source EPR packages working under *Python* `r icons::ionicons("logo-python")` [@FOSSspec2023].

The open source *R statistical language* ![](RcoreLogo.png){width="16" height="12"} [@Rmanual2024] is not so widely used as the general purpose language `r icons::ionicons("logo-python")`, which is also applied in many scientific fields [@Fangohr2024; @Staveren2022; @VaughanPy2023]. Nonetheless, owing to its nature, the ![](RcoreLogo.png){width="16" height="12"} is very much **focused on mathematics, statistics, graphing (it was actually built for such a purpose) and, last but not least, on data processing and analysis especially in research and academia**. Even though so specialized, it actually represents an advantage in data handling. Therefore, it has been very much established also in chemistry and physics [@PhysChemR2024], biology [@BiocondR2024], pharma industry [@PositPharma2024; @Pharmaverse2023] as well as in finance area [@Finance2024]. Unsurprisingly, many big companies, universities or financial and healthcare institutions rely on very robust and multiplatform[^1] ![](RcoreLogo.png){width="16" height="12"} [@Rconsortium2024; @PositDS2024].

[^1]: The ![](RcoreLogo.png){width="16" height="12"} is available for all three main operating systems =\> `r icons::icon_style(ionicons("logo-windows"),fill = "blue")` `r icons::icon_style(ionicons("logo-apple"),fill = "gray")` `r icons::icon_style(ionicons("logo-tux"),fill = "black")`

Because the ![](RcoreLogo.png){width="16" height="12"} belongs to the **family of programming languages** it also **provides reproducible workflow functionality. This is especially important for process validation in research and academia**. Namely, one can easily follow all the data and visualization operations unlike the other software with "icon-based" procedures. Moreover, **such a data wrangling and the related analytics, together with the outstanding visualization/graphing** [@ggplotWickh2016; @ggplotext2016; @ggplot23e2023; @plotly2024] **and publishing capabilities** [@BookdownBook2016; @BoookdownMan2024; @Quarto2022; @RmarkdownBook2020; @RmarkdownMan2024], **makes it a very powerful tool in the research area**. Hence, the decision to create a package for EPR spectroscopy in ![](RcoreLogo.png){width="16" height="12"} is obvious and strongly supported by the aforementioned features, even though the ![](RcoreLogo.png){width="16" height="12"} is not so widely used as the `r icons::ionicons("logo-python")` .

Moreover, **the entire** ![](RcoreLogo.png){width="16" height="12"} **ecosystem with thousands of packages** [@BiocondR2024; @Runiverse2023; @Rmanual2024] **and *RStudio* IDE**[^2] [@Rstudio2024] **support workflows which are almost free from any other additional software/toolboxes** (see also explanation below). Therefore, **together with perfectly and uniformly structured** package documentation (which is already available within the *RStudio*) **it represents an excellent facilitation of the data processing workflows by extensive reducing of many steps which have to be otherwise performed by several programs,** as already mentioned above. Great spectroscopy packages 📦 have been developed in ![](RcoreLogo.png){width="16" height="12"} e.g. for IR, MS, NMR, Fluorescence, UV-Vis(-NIR), Raman. However, non of them, even the general one like [{ChemoSpec}](#0) or [{hyperSpec}](#0), are suitable for EPR, which actually possesses a special position among the spectroscopies due to the paramagnetic (unpaired electronic state) nature of the studied molecules [@epr2022].

[^2]: Integrated Development Environment

Unlike the *EasySpin* [@Easyspin2024], which is more concentrated on the simulation of EPR spectra, **the primary aim of the** `{eprscope}` **package is to process, analyze and visualize the EPR spectral data similarly to functionality of the acquisition/processing software available at spectrometers**. This is otherwise not available in any other software packages/toolboxes. Especially, the function performing an absolute quantitative EPR analysis is just a rarely present within the acquisition programs of the EPR instruments. Subsequently, **the quantitative analysis is tightly connected with the determination of kinetic rate constants,** $k$ **where the radicals (paramagnetic species) are involved in the studied chemical reactions**. Last but not least, the $k$ temperature dependence can be applied to determine the activation parameters ($\Delta G^{\neq}$, $\Delta H^{\neq}$ and $\Delta S^{\neq}$ ) of the elementary radical reactions. Finally, **the EPR spectroscopy is quite often coupled with the *in situ* (directly within the EPR cavity/probehead) radical formation techniques like electrochemistry (usually voltammetry or potentiostatic/galvanostatic electrolysis) and irradiation or UV-Vis(-NIR) spectroscopy** [@dunsch2011]. Therefore, **the presented open source EPR** ![](RcoreLogo.png){width="16" height="12"} 📦 **will address not only the basic processing, simulation and visualization of the EPR spectra but also quantitative description of the radical reaction kinetics as well as that of the electrochemical redox ones**. In the latter, this actually means that one could easily compare the number of transferred electrons from the voltammogram with the number of radical cations/anions determined by the quantitative EPR. Such information reveals if one-electron transfer is associated with the formation of a single radical, otherwise a more complex mechanism must be taken into account [@dunsch2011] (see also the `eval_ECh_QNe_chronoamp()` function).

```{r scheme-intro, echo=FALSE, out.width="91%", fig.cap="Schematic representation of the data workflow in EPR spectroscopy and the compatibility of the newly developed `{eprscope}` software package within the R ecosystem."}
#
include_graphics("introduction_b.png",dpi = 200)
#
```

As mentioned above, the data analysis workflow also covers sharing of the results/outputs. However, quite often, in addition to essential processing of EPR spectra, the spectral analysis (which usually corresponds to determination of the hyperfine coupling/splitting constants and the *g*-factors) requires quantum chemical calculations on the high-performance computing servers and/or the above-mentioned simulations of EPR spectra done within the *MATLAB* by *EasySpin*[^3]*.* Therefore, one must combine diverse outputs in order to gather the entire structural information about the paramagnetic center. As can be seen in Figure \@ref(fig:scheme-intro) **the** `{eprscope}` **together with the** *Rmarkdown* [@RmarkdownBook2020] **and/or the** *Quarto* **publishing system** [@Quarto2022] **are capable** (**without living the** ![](RcoreLogo.png){width="16" height="12"} **ecosystem**) **to process all the input data into suitable dissemination form** (e.g. report, presentation, manuscript, webpage...etc.) and thus very effectively completing the last stage of the reproducible research workflow (please, refer to the `create_qmdReport_proj()` function).

[^3]: A simple simulation of isotropic EPR spectra of paramagnetic centers/radicals is also included in the `{eprscope}` ![](RcoreLogo.png){width="16" height="12"} 📦 .

## References
