# Twigs

## Background

Twigs are the smallest above ground woody component of a tree. Twigs are responsible for supporting the delicate tissues needed to grow leaves and protect the buds during the dormant season. Because twig measurements are the basis for the Real Twig method, and publicly available databases of twigs are limited, we present a database of twig measurements for a wide range of tree genera and species.

## Installation

You can install the package directly from CRAN:

    install.packages("rTwig")

Or the latest development version from GitHub:

    devtools::install_github("https://github.com/aidanmorales/rTwig")

## Load Packages

The first step is to load the rTwig package.

    library(rTwig)

    # Useful packages
    library(dplyr)
    library(ggplot2)

## Twig Database

The twig database is built directly into rTwig and can be called as follows:

    # If the rTwig library has been loaded
    twigs

    # If rTwig hasn't been loaded, but just the twigs are needed
    rTwig::twigs
    #> # A tibble: 102 × 7
    #>    scientific_name  radius_mm     n   min   max   std    cv
    #>    <chr>                <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
    #>  1 Abies concolor        1.43    21  0.89  1.9   0.28  0.19
    #>  2 Abies spp.            1.43    21  0.89  1.9   0.28  0.19
    #>  3 Acer platanoides      1.39    30  0.89  2.03  0.3   0.21
    #>  4 Acer rubrum           1.18    30  0.89  1.52  0.16  0.14
    #>  5 Acer saccharinum      1.41    14  0.89  1.9   0.27  0.2
    #>  6 Acer saccharum        1.2     30  0.89  1.65  0.23  0.19
    #>  7 Acer spp.             1.29   104  0.89  2.03  0.23  0.18
    #>  8 Aesculus flava        2.67     8  2.29  2.79  0.2   0.08
    #>  9 Aesculus spp.         2.67     8  2.29  2.79  0.2   0.08
    #> 10 Betula nigra          0.85    30  0.51  1.52  0.23  0.27
    #> # ℹ 92 more rows

The database is broken into 7 different columns. scientific_name is the specific epithet. Genus spp. is the average of all of the species in the genus. radius_mm is the twig radius in millimeters. For each species, n is the number of unique twig samples taken, min is the minimum twig radius, max is the max twig radius, std is the standard deviation, and cv is the coefficient of variation.

Let’s see the breakdown of species.

    unique(twigs$scientific_name)
    #>   [1] "Abies concolor"               "Abies spp."
    #>   [3] "Acer platanoides"             "Acer rubrum"
    #>   [5] "Acer saccharinum"             "Acer saccharum"
    #>   [7] "Acer spp."                    "Aesculus flava"
    #>   [9] "Aesculus spp."                "Betula nigra"
    #>  [11] "Betula spp."                  "Carya cordiformis"
    #>  [13] "Carya ovata"                  "Carya spp."
    #>  [15] "Cercis canadensis"            "Cercis spp."
    #>  [17] "Cladrastis kentukea"          "Cladrastis spp."
    #>  [19] "Cornus mas"                   "Cornus officinalis"
    #>  [21] "Cornus spp."                  "Crataegus spp."
    #>  [23] "Fagus grandifolia"            "Fagus spp."
    #>  [25] "Fagus sylvatica"              "Fraxinus americana"
    #>  [27] "Fraxinus pennsylvanica"       "Fraxinus quadrangulata"
    #>  [29] "Fraxinus spp."                "Ginkgo biloba"
    #>  [31] "Ginkgo spp."                  "Gleditsia spp."
    #>  [33] "Gleditsia triacanthos"        "Gymnocladus dioicus"
    #>  [35] "Gymnocladus spp."             "Gymnopodium floribundum"
    #>  [37] "Gymnopodium spp."             "Juglans cinerea"
    #>  [39] "Juglans nigra"                "Juglans spp."
    #>  [41] "Laguncularia racemosa"        "Laguncularia spp."
    #>  [43] "Larix laricina"               "Larix spp."
    #>  [45] "Liquidambar spp."             "Liquidambar styraciflua"
    #>  [47] "Liriodendron spp."            "Liriodendron tulipifera"
    #>  [49] "Magnolia acuminata"           "Magnolia spp."
    #>  [51] "Malus spp."                   "Metasequoia glyptostroboides"
    #>  [53] "Metasequoia spp."             "Nyssa spp."
    #>  [55] "Nyssa sylvatica"              "Ostrya spp."
    #>  [57] "Ostrya virginiana"            "Phellodendron amurense"
    #>  [59] "Phellodendron spp."           "Picea abies"
    #>  [61] "Picea omorika"                "Picea pungens"
    #>  [63] "Picea spp."                   "Pinus nigra"
    #>  [65] "Pinus spp."                   "Pinus strobus"
    #>  [67] "Platanus acerifolia"          "Platanus occidentalis"
    #>  [69] "Platanus spp."                "Populus deltoides"
    #>  [71] "Populus spp."                 "Prunus serotina"
    #>  [73] "Prunus spp."                  "Prunus virginiana"
    #>  [75] "Quercus acutissima"           "Quercus alba"
    #>  [77] "Quercus bicolor"              "Quercus coccinea"
    #>  [79] "Quercus ellipsoidalis"        "Quercus imbricaria"
    #>  [81] "Quercus macrocarpa"           "Quercus michauxii"
    #>  [83] "Quercus muehlenbergii"        "Quercus palustris"
    #>  [85] "Quercus robur"                "Quercus rubra"
    #>  [87] "Quercus shumardii"            "Quercus spp."
    #>  [89] "Quercus velutina"             "Rhizophora mangle"
    #>  [91] "Rhizophora spp."              "Thuja occidentalis"
    #>  [93] "Thuja spp."                   "Tilia americana"
    #>  [95] "Tilia spp."                   "Tilia tomentosa"
    #>  [97] "Tsuga canadensis"             "Tsuga spp."
    #>  [99] "Ulmus americana"              "Ulmus pumila"
    #> [101] "Ulmus rubra"                  "Ulmus spp."

## Visualization

Let’s visualize some of the twig data!

    # Lets look at a subset of oak species
    twigs %>%
      filter(grepl("Quercus", scientific_name)) %>%
      ggplot(aes(x = scientific_name, y = radius_mm, color = scientific_name)) +
      geom_point(aes(size = n)) +
      geom_errorbar(aes(ymax = max, ymin = min)) +
      coord_flip() +
      labs(
        title = "Quercus Twig Radii",
        x = "",
        y = "Twig Radius (mm)",
        color = "Species",
        size = "Sample Size"
      ) +
      scale_x_discrete(limits = rev) +
      theme_classic()