---
title: "stratcols"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{stratcols}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
```

```{r setup}
library(stratcols)
```

## Introduction to the stratcols package

`stratcols` is an R package to handle stratigraphic columns.

## Getting started

Stratigraphic columns are constructed using `as_stratcol`:

```{r}
thickness = runif(10) #bed thicknesses
facies = rep(c(1,2), 5) # facies codes

s = as_stratcol(thickness = thickness,
                facies = facies)
```

The optional argument `L_unit` can be used to associate a length unit with the bed thicknesses. The optional argument `base` specifies the position of the base of the lowest bed.

`is_stratcol` can be used to test if any object is a valid stratigraphic column:

```{r}
is_stratcol(s)
```

Bed thicknesses can be extracted using `bed_thickness`:

```{r}
bed_thickness(s)

```

You can extract (unique) facies names as follows:

```{r}
facies_names(s)
unique_facies_names(s)
```

Further functionality includes

```{r}
no_beds(s) # number of beds
no_facies(s) # number of distinct facies.

total_thickness(s) # total thickness of column

get_base(s) # lowest bed boundary
get_L_unit(s) # length unit of beds

facies_repetitions(s) # do at least two successive beds have identical facies?
merge_beds(s, mode = "identical facies") # merge successive beds with identical facies
```

## Plotting stratigraphic columns

`stratcols` wraps `StratigrapheR` to plot stratigraphic columns. Facies codes are interpreted as hardness

```{r, fig.alt="Stratigraphic column"}
plot(s)
```

## Modifying stratigraphic columns

Facies names can be changed using `rename_facies`:

```{r, fig.alt="stratigraphic column with changed facies codes"}
s2 = rename_facies(s, new_names = c(2,3))
plot(s2)
```

The optional argument `old_names` can be used to replace specific facies.

You can assign a stratigraphic column a length unit using

```{r}
s3 = set_L_unit(s, "m")
get_L_unit(s3)
```

## Further reading

See

```{r, eval=FALSE}
vignette("stratcols_doc")
```

for an explanation of the larger structure of the package and definitions of the classes.

See

```{r, eval=FALSE}
vignette("stratorder")
```

for available methods to estimate stratigraphic order metrics, such as the runs order metric (ROM) and the Markov order metric (MOM).
