---
title: "Code usage"
output: 
  bookdown::html_document2:
    base_format: rmarkdown::html_vignette
    toc: true
    number_sections: true
    always_allow_html: yes
pkgdown: 
    as_is: true
bibliography: hadex2_docs.bib
vignette: >
  %\VignetteIndexEntry{Code usage}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---
  
```{r setup, include = FALSE, echo = FALSE, warning = FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(dev = "png", dev.args = list(type = "cairo-png"))
```

# Convention

Purpose of groups of functions in the package:

* calculate_* - calculates one specific value. e.q. deuterium uptake values for specific time point.
* create_* - creates a dataset for set of values e.q. multiple time points.
* plot_* - plots a visualization of provided data, accepts calculate_* and create_*  outputs.
* show_* - subsets the dataset to show specific values, accepts calculate_* and create_*  outputs. 

Variables:

* deut_uptake - deuterium uptake [Da]
* frac_deut_uptake - fractional deuterium uptake [%]
* theo_deut_uptake - theoretical deuterium uptake [Da]
* theo_frac_deut_uptake - theoretical fractional deuterium uptake [%]
* diff_deut_uptake - differential deuterium uptake [Da]
* frac_diff_deut_uptake - theoretical differential fractional deuterium uptake [%]
* theo_diff_deut_uptake - differential deuterium uptake [Da]
* theo_frac_diff_deut_uptake - theoretical differential fractional deuterium uptake [%]


# Example of use

```{r message=FALSE, warning=FALSE, echo=FALSE}
library(HaDeX2)
library(magrittr)
```

## Read data file 
```{r, include=TRUE}
dat <- read_hdx(system.file(package = "HaDeX2", "HaDeX/data/alpha.csv"))
```



## Different forms of visualization

Create data frame with uptake values for state in all time points:

```{r}
uptake_dat <- create_state_uptake_dataset(dat)
```

Butterfly:

```{r}
plot_butterfly(uptake_dat)
```

Chiclet:

```{r}
plot_chiclet(uptake_dat)
```

