## Why Quarto?

There are a few reasons for why I would like to try Quarto (Allaire 2022) as my blogging platform. As I want to write more things of scientific nature I would like to be able to easily cite articles. For example later in this example page I use volume functions from the article *Single-tree biomass and stem volume functions for eleven tree species used in Icelandic forestry* (Arnór Snorrason and Stefán Freyr Einarsson 2006).

Other reasons are the capabilities of working with the data right in the blogging system and creating the charts and tables in the same area as I write the post.

## Working with data

For example we have the following data that I would like to work with.

First I would like to do basic manipulation of the data.

```
$dbh <- (trees$diam1 + trees$diam2) / 2
trees$ba <- (trees$dbh/200)^2 * pi trees
```

For the next trick we use linear regressions to calculate the expected height of the trees. We then use `coalesce()`

to copy back the height we already knew. From there we can calculate the volume of each tree using the volume functions (Arnór Snorrason and Stefán Freyr Einarsson 2006).

```
$height <- lm(height_measured ~ ba, data=trees) %>%
treespredict(trees)
$height <- coalesce(trees$height_measured, trees$height)
trees
$v <- 0.1299 * trees$dbh^1.6834 * trees$height^0.8598 trees
```

## Math with R

Using LaTeX math symbols we can communicate mathematical functions in a nice manner. For example we can talk about BAL as described by Arne Pommerening’s excellent article *Basal area in larger trees and the growth compensation point* where he explains BAL as such:

BALis related to available light, since with increasing basal area of larger trees there is less light available for smaller trees. In a senseBALis a surrogate for light measurements with the benefit that stem diameters and basal area are easier to measure.

\[BAL_i(t) = G(t) \cdot (1 - p_i(t)) \text{ where } p_i(t) = \frac{1}{G(t)} \sum_{\leq g_i(t)} g_i(t)\]

He also give us an example function in R. Let us use it to calculate the BAL of individual trees in our example data.

```
<- function(ba, area) {
bal <- sum(ba)
sumba <- 0
basmaller <- 0
pix <- 0
bal for (i in 1 : length(ba)) {
<- ba[i]
bax <- sum(ba[ba <= bax])
basmaller <- basmaller / sumba
pix <- sumba * (1 - pix) / area
bal[i]
}return(bal)
}# An then run it for out 0.54ha example stand.
$bal <- bal(trees$ba, 0.54/10000) trees
```

## References

*Quarto: R Interface to ’Quarto’ Markdown Publishing System*. https://CRAN.R-project.org/package=quarto.

*Icelandic Agricultural Sciences*, 15–24. https://www.semanticscholar.org/paper/Single-tree-biomass-and-stem-volume-functions-for-Snorrason-Einarsson/6668a0d8e81f7c32c0a0926d99b3451c9c69c160.