FIESTA - Data Tools

FIESTA Overview

The R package, FIESTA (Forest Inventory ESTimation and Analysis) is a research estimation tool for analysts that work with sample-based inventory data like that from the U.S. Department of Agriculture, Forest Service, Forest Inventory and Analysis (FIA) Program to accommodate: unique population boundaries, different evaluation time periods, customized stratification schemes, non-standard variance equations, integration of multi-scale remotely-sensed data and other ancillary information, and interaction with other modeling and estimation tools from CRAN R’s library of packages. FIESTA contains a collection of functions that can access FIA databases, summarize and compile plot and spatial data, and generate estimates with associated sampling errors.

Functions are organized by type or objective and are named with a corresponding prefix:

Core Functions

Estimation Modules

Analysis Tools

Overview of FIESTA data (dat) tools

FIESTA’s dat tools assist with customizing variables as well as summarizing and visualizing FIA data. The datLUTclass and datLUTnm functions help with merging look-up tables to support new variables, standard FIA code names or unique names, or groupings of discrete or continuous data values. The datSum* functions provide tools for aggregating FIA data for estimation, mapping, or exploratory data analyses.

The Green-Book (GB) tree estimators require tree data summarized to the condition (base unit) level and extrapolated to an acre to account for trees sampled from different plot sizes. An adjustment factor is applied (adjsamp=TRUE) to adjust for nonsampled plots within the area of interest.

Objective of tutorial

The objective of this tutorial is to demonstrate the use of FIESTA’s dat tools for customizing, summarizing, and visualizing FIA data. The examples use data from two inventory years of field measurements in the state of Wyoming, from FIADB_1.7.2.00, last updated June 20, 2018, downloaded on June 25, 2018 and stored as internal data objects in FIESTA.

FUNCTION DESCRIPTION
datFilter() Subsets a data table by specified filter(s).
datFreq() Generates frequency table.
datPivot() Generates pivot table.
datBarplot() Generates bar plot.
datBarplotStacked() Generates stacked bar plot.
datPiechart() Generates pie chart.
datLUTclass() Merge look-up table for classifying continuous data (e.g., DIA).
datLUTnm() Merge look-up table to append names or categories.
datSumCond() Aggregates numeric condition data to plot level.
datSumTree() Aggregates numeric tree data to the plot or condition-level.
datSumTreeDom() Aggregates numeric tree data by tree domain to plot or condition level.

Set up

We just load the FIESTA library to get started with the examples.

# Load library
library(FIESTA)

The following examples use FIA data from Wyoming for inventory years 2011-2013.

datFilter()

The datFilter function subsets a data table by specified filter(s) or logical statement and returns a list of the filtered data table and the filter.

Example 1: Subset National Forest Conditions in Wyoming

View Example
WYconddat.nfs <- datFilter(
        x = WYcond, 
        xfilter = "ADFORCD > 0"
        )

names(WYconddat.nfs)
output
## [1] "xf"      "xfilter"
WYcond.nfs <- WYconddat.nfs$xf
dim(WYcond.nfs)
output
## [1] 552  26
head(WYcond.nfs)
output
##            PLT_CN CONDID COND_NONSAMPLE_REASN_CD CONDPROP_UNADJ SUBPPROP_UNADJ
## 1: 40404730010690      1                      NA           1.00           1.00
## 2: 40404737010690      1                      NA           0.75           0.75
## 3: 40404737010690      2                      NA           0.25           0.25
## 4: 40404742010690      1                      NA           1.00           1.00
## 5: 40404818010690      1                      NA           1.00           1.00
## 6: 40404821010690      1                      NA           1.00           1.00
##    MICRPROP_UNADJ MACRPROP_UNADJ OWNCD OWNGRPCD RESERVCD SITECLCD STDORGCD
## 1:           1.00             NA    11       10        0        6        0
## 2:           0.75             NA    11       10        0       NA       NA
## 3:           0.25             NA    11       10        0        7        0
## 4:           1.00             NA    11       10        0        6        0
## 5:           1.00             NA    11       10        0       NA       NA
## 6:           1.00             NA    11       10        0        5        0
##    ADFORCD LIVE_CANOPY_CVR_PCT COND_STATUS_CD NF_COND_STATUS_CD FORTYPCD
## 1:     206                  41              1                NA      201
## 2:     206                   6              2                NA       NA
## 3:     206                  10              1                NA      999
## 4:     206                  24              1                NA      901
## 5:     206                   7              2                NA       NA
## 6:     206                  24              1                NA      266
##    STDSZCD STDAGE GSSTKCD DSTRBCD1 DSTRBYR1 DSTRBCD2 DSTRBYR2 FORTYPGRPCD
## 1:       1    220       3        0       NA        0       NA         200
## 2:      NA     NA      NA       NA       NA       NA       NA          NA
## 3:       5      0       5        0       NA        0       NA         999
## 4:       3      7       3        0       NA        0       NA         900
## 5:      NA     NA      NA       NA       NA       NA       NA          NA
## 6:       1    121       3       10     9999        0       NA         260
##    TIMBERCD
## 1:        1
## 2:       NA
## 3:        2
## 4:        1
## 5:       NA
## 6:        1

Example 2: Subset Trees That Are Standing Dead Aspen Trees in Wyoming

View Example
WYtreedat.dead <- datFilter(
        x = WYtree, 
        xfilter = "STATUSCD == 2 & STANDING_DEAD_CD == 1 & SPCD == 746"
        )

names(WYtreedat.dead)
output
## [1] "xf"      "xfilter"
WYtree.deadasp <- WYtreedat.dead$xf
head(WYtree.deadasp)
output
##            PLT_CN CONDID SUBP TREE STATUSCD SPCD SPGRPCD  DIA HT TREECLCD
## 1: 40404831010690      1    4    1        2  746      44  5.6 14        3
## 2: 40404843010690      1    4    2        2  746      44  7.9 29        3
## 3: 40404920010690      1    1    2        2  746      44  7.4 44        3
## 4: 40404920010690      1    1   16        2  746      44  8.5 38        3
## 5: 40404920010690      1    2    1        2  746      44  8.9 42        3
## 6: 40404920010690      1    2   11        2  746      44 10.3 40        4
##    AGENTCD STANDING_DEAD_CD VOLCFNET VOLCFGRS VOLBFNET TPA_UNADJ  DRYBIO_AG
## 1:      20                1 0.042070 0.056093       NA  6.018046   0.679523
## 2:      70                1 2.329483 3.065109       NA  6.018046  35.836056
## 3:      20                1 4.074443 4.381121       NA  6.018046  98.156004
## 4:      NA                1 4.811647 5.118773       NA  6.018046 113.345699
## 5:      20                1 6.138979 6.394770       NA  6.018046 143.636088
## 6:      NA                1 0.000000 8.407102       NA  6.018046 119.261221
##    CARBON_AG        BA
## 1:  0.339762 0.1710374
## 2: 17.918028 0.3403841
## 3: 49.078002 0.2986610
## 4: 56.672850 0.3940515
## 5: 71.818044 0.4320113
## 6: 59.630611 0.5786149
dim(WYtree.deadasp)
output
## [1] 211  19
dim(WYtree)
output
## [1] 18380    19

Example 3: Subset Trees That Are Standing Dead Aspens in Wyoming, and Subset Other Tables to Match

View Example
WYtreedat.dead2 <- datFilter(
        x = WYtree, 
        xfilter = "STATUSCD == 2 & STANDING_DEAD_CD == 1 & SPCD == 746",
        othertabnms = c("WYplt", "WYcond")
        )

names(WYtreedat.dead2)
output
## [1] "xf"       "xfilter"  "cliptabs"
WYtree.deadasp2 <- WYtreedat.dead2$xf
head(WYtree.deadasp2)
output
##            PLT_CN CONDID SUBP TREE STATUSCD SPCD SPGRPCD  DIA HT TREECLCD
## 1: 40404831010690      1    4    1        2  746      44  5.6 14        3
## 2: 40404843010690      1    4    2        2  746      44  7.9 29        3
## 3: 40404920010690      1    1    2        2  746      44  7.4 44        3
## 4: 40404920010690      1    1   16        2  746      44  8.5 38        3
## 5: 40404920010690      1    2    1        2  746      44  8.9 42        3
## 6: 40404920010690      1    2   11        2  746      44 10.3 40        4
##    AGENTCD STANDING_DEAD_CD VOLCFNET VOLCFGRS VOLBFNET TPA_UNADJ  DRYBIO_AG
## 1:      20                1 0.042070 0.056093       NA  6.018046   0.679523
## 2:      70                1 2.329483 3.065109       NA  6.018046  35.836056
## 3:      20                1 4.074443 4.381121       NA  6.018046  98.156004
## 4:      NA                1 4.811647 5.118773       NA  6.018046 113.345699
## 5:      20                1 6.138979 6.394770       NA  6.018046 143.636088
## 6:      NA                1 0.000000 8.407102       NA  6.018046 119.261221
##    CARBON_AG        BA
## 1:  0.339762 0.1710374
## 2: 17.918028 0.3403841
## 3: 49.078002 0.2986610
## 4: 56.672850 0.3940515
## 5: 71.818044 0.4320113
## 6: 59.630611 0.5786149
dim(WYtree.deadasp2)
output
## [1] 211  19
WYtree.deadasptabs <- WYtreedat.dead2$cliptabs
names(WYtree.deadasptabs)
output
## [1] "clip_WYplt"  "clip_WYcond"
WYplt.deadasp <- WYtree.deadasptabs$clip_WYplt
WYcond.deadasp <- WYtree.deadasptabs$clip_WYcond

dim(WYplt.deadasp)
output
## [1] 40 20
dim(WYcond.deadasp)
output
## [1] 56 26

datFreq()

The datFreq function generates a frequency table from a data frame, including number of records by a specified variable or variables in the data frame with optional totals and/or subtotals.

Example: Multiple Uses

View Example
## Get number of plots by county
datFreq(
      x = WYplt, 
      xvar="COUNTYCD"
      )
output
##    COUNTYCD FREQ
## 1         1  133
## 2         3   98
## 3         5  152
## 4         7  245
## 5         9  133
## 6        11   85
## 7        13  290
## 8        15   70
## 9        17   58
## 10       19  128
## 11       21   86
## 12       23  132
## 13       25  175
## 14       27   79
## 15       29  216
## 16       31   64
## 17       33   82
## 18       35  158
## 19       37  339
## 20       39  125
## 21       41   63
## 22       43   63
## 23       45   73
## Get number of plots by county and plot status
datFreq(
      x = WYplt, 
      xvar=c("COUNTYCD", "PLOT_STATUS_CD")
      )
output
##    COUNTYCD PLOT_STATUS_CD FREQ
## 1         1              1   24
## 2         1              2  109
## 3         3              1   12
## 4         3              2   86
## 5         5              1   14
## 6         5              2  138
## 7         7              1   36
## 8         7              2  209
## 9         9              1   18
## 10        9              2  115
## 11       11              1   26
## 12       11              2   59
## 13       13              1   53
## 14       13              2  237
## 15       15              1    2
## 16       15              2   68
## 17       17              1    8
## 18       17              2   50
## 19       19              1   22
## 20       19              2  106
## 21       21              1    2
## 22       21              2   84
## 23       23              1   38
## 24       23              2   94
## 25       25              1    7
## 26       25              2  168
## 27       27              1    2
## 28       27              2   77
## 29       29              1   99
## 30       29              2  117
## 31       31              1    8
## 32       31              2   56
## 33       33              1   20
## 34       33              2   62
## 35       35              1   44
## 36       35              2  114
## 37       37              1    9
## 38       37              2  330
## 39       39              1   94
## 40       39              2   31
## 41       41              1    6
## 42       41              2   57
## 43       43              1    4
## 44       43              2   59
## 45       45              1    8
## 46       45              2   65
## Get number of plots by county and plot status with subtotals
datFreq(
      x = WYplt, 
      xvar = c("COUNTYCD", "PLOT_STATUS_CD"), 
      subtotal = TRUE
      )
output
##     COUNTYCD PLOT_STATUS_CD FREQ
## 1          1              1   24
## 3          3              1   12
## 5          5              1   14
## 7          7              1   36
## 9          9              1   18
## 11        11              1   26
## 13        13              1   53
## 15        15              1    2
## 17        17              1    8
## 19        19              1   22
## 21        21              1    2
## 23        23              1   38
## 25        25              1    7
## 27        27              1    2
## 29        29              1   99
## 31        31              1    8
## 33        33              1   20
## 35        35              1   44
## 37        37              1    9
## 39        39              1   94
## 41        41              1    6
## 43        43              1    4
## 45        45              1    8
## 24                 Subtotal  556
## 2          1              2  109
## 4          3              2   86
## 6          5              2  138
## 8          7              2  209
## 10         9              2  115
## 12        11              2   59
## 14        13              2  237
## 16        15              2   68
## 18        17              2   50
## 20        19              2  106
## 22        21              2   84
## 241       23              2   94
## 26        25              2  168
## 28        27              2   77
## 30        29              2  117
## 32        31              2   56
## 34        33              2   62
## 36        35              2  114
## 38        37              2  330
## 40        39              2   31
## 42        41              2   57
## 44        43              2   59
## 46        45              2   65
## 48                 Subtotal 2491
## Get number of plots by county and plot status with subtotals
datFreq(
      x = WYplt, 
      xvar = c("COUNTYCD", "PLOT_STATUS_CD"), 
      subtotal = TRUE,
      subtotalcol = "COUNTYCD"
      )
output
##     COUNTYCD PLOT_STATUS_CD FREQ
## 1          1              1   24
## 2          1              2  109
## 3                  Subtotal  133
## 31         3              1   12
## 4          3              2   86
## 6                  Subtotal   98
## 5          5              1   14
## 61         5              2  138
## 9                  Subtotal  152
## 7          7              1   36
## 8          7              2  209
## 12                 Subtotal  245
## 91         9              1   18
## 10         9              2  115
## 15                 Subtotal  133
## 11        11              1   26
## 121       11              2   59
## 18                 Subtotal   85
## 13        13              1   53
## 14        13              2  237
## 21                 Subtotal  290
## 151       15              1    2
## 16        15              2   68
## 24                 Subtotal   70
## 17        17              1    8
## 181       17              2   50
## 27                 Subtotal   58
## 19        19              1   22
## 20        19              2  106
## 30                 Subtotal  128
## 211       21              1    2
## 22        21              2   84
## 33                 Subtotal   86
## 23        23              1   38
## 241       23              2   94
## 36                 Subtotal  132
## 25        25              1    7
## 26        25              2  168
## 39                 Subtotal  175
## 271       27              1    2
## 28        27              2   77
## 42                 Subtotal   79
## 29        29              1   99
## 301       29              2  117
## 45                 Subtotal  216
## 311       31              1    8
## 32        31              2   56
## 48                 Subtotal   64
## 331       33              1   20
## 34        33              2   62
## 51                 Subtotal   82
## 35        35              1   44
## 361       35              2  114
## 54                 Subtotal  158
## 37        37              1    9
## 38        37              2  330
## 57                 Subtotal  339
## 391       39              1   94
## 40        39              2   31
## 60                 Subtotal  125
## 41        41              1    6
## 421       41              2   57
## 63                 Subtotal   63
## 43        43              1    4
## 44        43              2   59
## 66                 Subtotal   63
## 451       45              1    8
## 46        45              2   65
## 69                 Subtotal   73

datPivot()

The datPivot function generates a pivot table.

Example: Multiple Uses

View Example
## Get summed condition proportions by forest type class and stand size class
datPivot(
      x = WYcond, 
      pvar = "CONDPROP_UNADJ", 
      xvar = "FORTYPCD", 
      yvar = "STDSZCD"
      )
output
##     FORTYPCD     1     2     3     5
##  1:      182 23.23  3.00  4.50  0.00
##  2:      184 15.50  0.00  1.00  0.00
##  3:      185  0.75  0.00  0.00  0.00
##  4:      201 27.85  5.50  8.50  0.00
##  5:      221 39.97  2.25  2.75  0.00
##  6:      265 16.25  3.25  3.25  0.00
##  7:      266 48.25 12.51 10.50  0.00
##  8:      268 28.38  7.50  9.49  0.00
##  9:      269  1.00  0.00  0.00  0.00
## 10:      281 43.95 39.43 34.68  0.00
## 11:      366  3.50  0.00  7.59  0.00
## 12:      367  4.37  5.75  7.50  0.00
## 13:      509  1.00  1.75  2.00  0.00
## 14:      517  0.00  0.00  1.00  0.00
## 15:      703  3.03  0.25  1.00  0.00
## 16:      706  0.00  0.50  0.00  0.00
## 17:      901  2.00  8.12 19.25  0.00
## 18:      999  0.00  0.00  0.00 40.75
## Get average height by species group code and status code
datPivot(
      x = WYtree, 
      pvar = "HT", 
      xvar = "SPGRPCD", 
      yvar = "TREECLCD", 
      pfun = mean
      )
output
##     SPGRPCD     2     3     4
##  1:      10 46.28 50.86 68.00
##  2:      11 39.71 32.64 54.54
##  3:      12 41.68 45.98 57.22
##  4:      18 47.15 59.76 66.70
##  5:      21 44.84 52.95 56.60
##  6:      23  0.00 11.67 10.00
##  7:      24 29.78 35.39 35.38
##  8:      44 37.61 35.57 41.47
##  9:      47 26.82 28.13 39.50
## 10:      48  0.00 12.20  0.00

datLUTclass()

The datLUTclass function merges a look-up table to define categories of continuous data in x (e.g., DIACL). Adds a variable to x, setting the variable to VARCLNM where: xvar >= MIN and xvar < MAX.

Example 1: Reference Table Stored in FIESTA with 2-inch Diameter Classes

View Example
FIESTAutils::ref_diacl2in
output
##    MIN  MAX  DIACL2IN
## 1    1  2.9   1.0-2.9
## 2    3  4.9   3.0-4.9
## 3    5  6.9   5.0-6.9
## 4    7  8.9   7.0-8.9
## 5    9 10.9  9.0-10.9
## 6   11 12.9 11.0-12.9
## 7   13 14.9 13.0-14.9
## 8   15 16.9 15.0-16.9
## 9   17 18.9 17.0-18.9
## 10  19 20.9 19.0-20.9
## 11  21 22.9 21.0-22.9
## 12  23 24.9 23.0-24.9
## 13  25 26.9 25.0-26.9
## 14  27 28.9 27.0-28.9
## 15  29 30.9 29.0-30.9
## 16  31 32.9 31.0-32.9
## 17  33 34.9 33.0-34.9
## 18  35 36.9 35.0-36.9
## 19  37 38.9 37.0-38.9
## 20  39 40.9 39.0-40.9
## 21  41 42.9 41.0-42.9
## 22  43 44.9 43.0-44.9
## 23  45 46.9 45.0-46.9
## 24  47 48.9 47.0-48.9
## 25  49 50.9 49.0-50.9
## 26  51 52.9 51.0-52.9
## 27  53 54.9 53.0-54.9
## 28  55 56.9 55.0-56.9
## 29  57 58.9 57.0-58.9
## 30  59 60.9 59.0-60.9
## 31  61 62.9 61.0-62.9
## 32  63 64.9 63.0-64.9
## 33  65 66.9 65.0-66.9
## 34  67 68.9 67.0-68.9
## 35  69 70.9 69.0-70.9
## 36  71 72.9 71.0-72.9
## 37  73 74.9 73.0-74.9
## 38  75 76.9 75.0-76.9
## 39  77 78.9 77.0-78.9
## 40  79 80.9 79.0-80.9
WYtreelut <- datLUTclass(
                x = WYtree, 
                xvar = "DIA",
                LUT = FIESTAutils::ref_diacl2in, 
                LUTclassnm = "DIACL2IN"
                )

names(WYtreelut)
output
## [1] "xLUT"       "LUTclassnm" "LUT"
WYtree2 <- WYtreelut$xLUT
head(WYtree2)
output
##           PLT_CN CONDID SUBP TREE STATUSCD SPCD SPGRPCD DIA HT TREECLCD AGENTCD
## 1 40404738010690      1    2    3        2   19      12  NA NA       NA      70
## 2 40404738010690      1    2    4        2   19      12  NA NA       NA      70
## 3 40404738010690      1    2    7        1   19      12 5.3 26        2      NA
## 4 40404821010690      1    1    7        1   19      12 5.9 48        2      NA
## 5 40404821010690      1    1    8        1   19      12 8.1 45        2      NA
## 6 40404821010690      1    1   11        2   19      12  NA NA       NA      70
##   STANDING_DEAD_CD VOLCFNET VOLCFGRS VOLBFNET TPA_UNADJ DRYBIO_AG CARBON_AG
## 1                0       NA       NA       NA        NA   0.00000        NA
## 2                0       NA       NA       NA        NA   0.00000        NA
## 3               NA 0.864289 0.864289       NA  6.018046  25.48605  12.74303
## 4               NA 3.046342 3.046342       NA  6.018046  88.91319  44.45660
## 5               NA 6.019584 6.019584       NA  6.018046 171.35480  85.67740
## 6                0       NA       NA       NA        NA   0.00000        NA
##          BA DIACL2IN
## 1        NA     <NA>
## 2        NA     <NA>
## 3 0.1532029  5.0-6.9
## 4 0.1898537  5.0-6.9
## 5 0.3578369  7.0-8.9
## 6        NA     <NA>
dim(WYtree)
output
## [1] 18380    19
dim(WYtree2)
output
## [1] 18380    20

Example 2: Create New Reference Table and Merge to Tree Table

View Example
diacl25 <- data.frame(
              MIN = c(5,25), 
              MAX = c(25, 100), 
              DIACL25 = c("5.0-24.9", "25.0+" )
              )
diacl25
output
##   MIN MAX  DIACL25
## 1   5  25 5.0-24.9
## 2  25 100    25.0+
WYtreelut2 <- datLUTclass(
                  x = WYtree, 
                  xvar = "DIA", 
                  LUT = diacl25, 
                  LUTclassnm = "DIACL25"
                  )

names(WYtreelut2)
output
## [1] "xLUT"       "LUTclassnm" "LUT"
WYtree2 <- WYtreelut2$xLUT
head(WYtree2)
output
##           PLT_CN CONDID SUBP TREE STATUSCD SPCD SPGRPCD DIA HT TREECLCD AGENTCD
## 1 40404738010690      1    2    3        2   19      12  NA NA       NA      70
## 2 40404738010690      1    2    4        2   19      12  NA NA       NA      70
## 3 40404738010690      1    2    7        1   19      12 5.3 26        2      NA
## 4 40404821010690      1    1    7        1   19      12 5.9 48        2      NA
## 5 40404821010690      1    1    8        1   19      12 8.1 45        2      NA
## 6 40404821010690      1    1   11        2   19      12  NA NA       NA      70
##   STANDING_DEAD_CD VOLCFNET VOLCFGRS VOLBFNET TPA_UNADJ DRYBIO_AG CARBON_AG
## 1                0       NA       NA       NA        NA   0.00000        NA
## 2                0       NA       NA       NA        NA   0.00000        NA
## 3               NA 0.864289 0.864289       NA  6.018046  25.48605  12.74303
## 4               NA 3.046342 3.046342       NA  6.018046  88.91319  44.45660
## 5               NA 6.019584 6.019584       NA  6.018046 171.35480  85.67740
## 6                0       NA       NA       NA        NA   0.00000        NA
##          BA  DIACL25
## 1        NA     <NA>
## 2        NA     <NA>
## 3 0.1532029 5.0-24.9
## 4 0.1898537 5.0-24.9
## 5 0.3578369 5.0-24.9
## 6        NA     <NA>
dim(WYtree)
output
## [1] 18380    19
dim(WYtree2)
output
## [1] 18380    20

Example 3: Use Cutbreaks to Classify LIVE_CANOPY_CVR_PCT variable from WYcond Table

View Example
cutbreaks <- c(0,25,50,100)
WYcondlut <- datLUTclass(
                x = WYcond, 
                xvar = "LIVE_CANOPY_CVR_PCT", 
                cutbreaks = cutbreaks
                )

names(WYcondlut)
output
## [1] "xLUT"       "LUTclassnm" "LUT"
head(WYcondlut$xLUT)
output
##           PLT_CN CONDID COND_NONSAMPLE_REASN_CD CONDPROP_UNADJ SUBPPROP_UNADJ
## 1 40404728010690      1                      NA              1              1
## 2 40404729010690      1                      NA              1              1
## 3 40404730010690      1                      NA              1              1
## 4 40404731010690      1                      NA              1              1
## 5 40404733010690      1                      NA              1              1
## 6 40404734010690      1                      NA              1              1
##   MICRPROP_UNADJ MACRPROP_UNADJ OWNCD OWNGRPCD RESERVCD SITECLCD STDORGCD
## 1              1             NA    46       40        0       NA       NA
## 2              1             NA    46       40        0        7        0
## 3              1             NA    11       10        0        6        0
## 4              1             NA    22       20        0       NA       NA
## 5              1             NA    46       40        0       NA       NA
## 6              1             NA    22       20        0       NA       NA
##   ADFORCD LIVE_CANOPY_CVR_PCT COND_STATUS_CD NF_COND_STATUS_CD FORTYPCD STDSZCD
## 1      NA                   0              2                NA       NA      NA
## 2      NA                  17              1                NA      366       1
## 3     206                  41              1                NA      201       1
## 4      NA                   0              2                NA       NA      NA
## 5      NA                   0              2                NA       NA      NA
## 6      NA                   0              2                NA       NA      NA
##   STDAGE GSSTKCD DSTRBCD1 DSTRBYR1 DSTRBCD2 DSTRBYR2 FORTYPGRPCD TIMBERCD
## 1     NA      NA       NA       NA       NA       NA          NA       NA
## 2     46       5        0       NA        0       NA         360        2
## 3    220       3        0       NA        0       NA         200        1
## 4     NA      NA       NA       NA       NA       NA          NA       NA
## 5     NA      NA       NA       NA       NA       NA          NA       NA
## 6     NA      NA       NA       NA       NA       NA          NA       NA
##   LIVE_CANOPY_CVR_PCTCL
## 1                0-24.9
## 2                0-24.9
## 3               25-49.9
## 4                0-24.9
## 5                0-24.9
## 6                0-24.9
WYcondlut$LUT
output
##    LIVE_CANOPY_CVR_PCT_cutbreaks LIVE_CANOPY_CVR_PCTCL
## 1:                             0                0-24.9
## 2:                            25               25-49.9
## 3:                            50                   50+

datLUTnm()

The datLUTnm function merges a look-up table to append new variables, names, or categories to x.

Example: Multiple Uses

View Example

First, we can look at a reference table stored in FIESTA with code descriptions of common FIA attributes.

head(FIESTAutils::ref_codes)
output
##   VARIABLE VALUE              MEANING COLORHEX GROUPCD GROUPNM GROUPHEX
## 1  ADFORCD   102 Beaverhead-Deerlodge       NA      NA                 
## 2  ADFORCD   103           Bitterroot       NA      NA                 
## 3  ADFORCD   104      Idaho Panhandle       NA      NA                 
## 4  ADFORCD   105           Clearwater       NA      NA                 
## 5  ADFORCD   108               Custer       NA      NA                 
## 6  ADFORCD   109            Deerlodge       NA      NA
unique(FIESTAutils::ref_codes$VARIABLE)
output
##  [1] "ADFORCD"                 "AGENTCD"                
##  [3] "ALSTKCD"                 "COND_NONSAMPLE_REASN_CD"
##  [5] "COND_STATUS_CD"          "DSTRBCD"                
##  [7] "DSTRBGRP"                "FLDSZCD"                
##  [9] "FORINDCD"                "FORTYPCD"               
## [11] "FORTYPGRPCD"             "GSSTKCD"                
## [13] "KINDCD"                  "LAND_COVER_CLASS_CD"    
## [15] "LANDCLCD"                "LANDUSECD"              
## [17] "MIST_CL_CD"              "NF_COND_STATUS_CD"      
## [19] "NF_PLOT_STATUS_CD"       "OWNCD"                  
## [21] "OWNGRPCD"                "PHYSCLCD"               
## [23] "PLOT_STATUS_CD"          "PRESNFCD"               
## [25] "RDDISTCD"                "RESERVCD"               
## [27] "SITECLCD"                "SPCD"                   
## [29] "SPGRPCD"                 "STATIONCD"              
## [31] "STATUSCD"                "STDORGCD"               
## [33] "STDSZCD"                 "SURVEY"                 
## [35] "TIMBERCD"                "TIMBERCD.PROD"          
## [37] "TREECLCD"                "TRTCD"

Next, we set the code descriptions for FIA disturbance variable.

ref_dstrbcd <- FIESTAutils::ref_codes[FIESTAutils::ref_codes$VARIABLE == "DSTRBCD",]
head(ref_dstrbcd)
output
##     VARIABLE VALUE                          MEANING COLORHEX GROUPCD
## 224  DSTRBCD     0           No visible disturbance       NA       0
## 225  DSTRBCD    10                           Insect       NA      10
## 226  DSTRBCD    11  Insect to understory vegetation       NA      10
## 227  DSTRBCD    12                  Insect to trees       NA      10
## 228  DSTRBCD    20                          Disease       NA      20
## 229  DSTRBCD    21 Disease to understory vegetation       NA      20
##                    GROUPNM GROUPHEX
## 224 No visible disturbance         
## 225                 Insect         
## 226                 Insect         
## 227                 Insect         
## 228                Disease         
## 229                Disease

Next, we can append forest type names using the reference table above.

WYcondlut <- datLUTnm(
              x = WYcond, 
              xvar = "DSTRBCD1", 
              LUT = ref_dstrbcd, 
              LUTvar = "VALUE",
              LUTnewvar = "MEANING", 
              LUTnewvarnm = "DSTRB1NM"
              )

names(WYcondlut)
output
## [1] "xLUT"   "xLUTnm" "LUT"
WYcond2 <- WYcondlut$xLUT
head(WYcond2[WYcond2$DSTRBCD1 > 0, ])
output
##            PLT_CN CONDID COND_NONSAMPLE_REASN_CD CONDPROP_UNADJ SUBPPROP_UNADJ
## 1: 40404738010690      1                      NA              1              1
## 2: 40404821010690      1                      NA              1              1
## 3: 40404838010690      1                      NA              1              1
## 4: 40404844010690      1                      NA              1              1
## 5: 40404845010690      1                      NA              1              1
## 6: 40404864010690      1                      NA              1              1
##    MICRPROP_UNADJ MACRPROP_UNADJ OWNCD OWNGRPCD RESERVCD SITECLCD STDORGCD
## 1:              1             NA    31       30        0        7        0
## 2:              1             NA    11       10        0        5        0
## 3:              1             NA    11       10        0        6        0
## 4:              1             NA    11       10        0        6        0
## 5:              1             NA    11       10        0        6        0
## 6:              1             NA    11       10        0        6        0
##    ADFORCD LIVE_CANOPY_CVR_PCT COND_STATUS_CD NF_COND_STATUS_CD FORTYPCD
## 1:      NA                  17              1                NA      366
## 2:     206                  24              1                NA      266
## 3:     206                  30              1                NA      901
## 4:     206                  49              1                NA      266
## 5:     206                  22              1                NA      281
## 6:     206                  49              1                NA      268
##    STDSZCD STDAGE GSSTKCD DSTRBCD1 DSTRBYR1 DSTRBCD2 DSTRBYR2 FORTYPGRPCD
## 1:       3      5       4       10     9999        0       NA         360
## 2:       1    121       3       10     9999        0       NA         260
## 3:       3     20       3       10     2009        0       NA         900
## 4:       2     82       3       10     2006        0       NA         260
## 5:       2    129       4       10     2011        0       NA         280
## 6:       2    115       3       10     2008        0       NA         260
##    TIMBERCD DSTRB1NM
## 1:        2   Insect
## 2:        1   Insect
## 3:        1   Insect
## 4:        1   Insect
## 5:        1   Insect
## 6:        1   Insect

Now, we can append forest type names using datLUTnm. If the xvar is in the stored reference table, the name and values will automatically be appended.

WYcondlut2 <- datLUTnm(
                x = WYcond, 
                xvar = "DSTRBCD1", 
                FIAname = TRUE
                )

names(WYcondlut2)
output
## [1] "xLUT"   "xLUTnm" "LUT"
WYcond3 <- WYcondlut2$xLUT
head(WYcond3[WYcond3$DSTRBCD1 > 0, ])
output
##            PLT_CN CONDID COND_NONSAMPLE_REASN_CD CONDPROP_UNADJ SUBPPROP_UNADJ
## 1: 40404738010690      1                      NA              1              1
## 2: 40404821010690      1                      NA              1              1
## 3: 40404838010690      1                      NA              1              1
## 4: 40404844010690      1                      NA              1              1
## 5: 40404845010690      1                      NA              1              1
## 6: 40404864010690      1                      NA              1              1
##    MICRPROP_UNADJ MACRPROP_UNADJ OWNCD OWNGRPCD RESERVCD SITECLCD STDORGCD
## 1:              1             NA    31       30        0        7        0
## 2:              1             NA    11       10        0        5        0
## 3:              1             NA    11       10        0        6        0
## 4:              1             NA    11       10        0        6        0
## 5:              1             NA    11       10        0        6        0
## 6:              1             NA    11       10        0        6        0
##    ADFORCD LIVE_CANOPY_CVR_PCT COND_STATUS_CD NF_COND_STATUS_CD FORTYPCD
## 1:      NA                  17              1                NA      366
## 2:     206                  24              1                NA      266
## 3:     206                  30              1                NA      901
## 4:     206                  49              1                NA      266
## 5:     206                  22              1                NA      281
## 6:     206                  49              1                NA      268
##    STDSZCD STDAGE GSSTKCD DSTRBCD1 DSTRBYR1 DSTRBCD2 DSTRBYR2 FORTYPGRPCD
## 1:       3      5       4       10     9999        0       NA         360
## 2:       1    121       3       10     9999        0       NA         260
## 3:       3     20       3       10     2009        0       NA         900
## 4:       2     82       3       10     2006        0       NA         260
## 5:       2    129       4       10     2011        0       NA         280
## 6:       2    115       3       10     2008        0       NA         260
##    TIMBERCD DSTRBNM
## 1:        2  Insect
## 2:        1  Insect
## 3:        1  Insect
## 4:        1  Insect
## 5:        1  Insect
## 6:        1  Insect

datSumCond()

The datSumCond functions aggregates the CONDPROP_UNADJ variable or other continuous condition variables to plot level with option to apply condition filters. If condition variable is not CONDPROP_UNADJ the variable is multiplied by CONDPROP_UNADJ for a weighted sum.

The function returns a list of the following:
condsum - plot-level table with aggregated condition attribute.
cfilter - condition filter

Example: Multiple Uses

View Example

First, we aggregate LIVE_CANOPY_CVR_PCT to plot, weighted by CONDPROP_UNADJ.

condsumdat <- datSumCond(
                cond = WYcond, 
                csumvar = "LIVE_CANOPY_CVR_PCT"
                )

names(condsumdat)
output
## [1] "condsum"   "csumvarnm"
condsum <- condsumdat$condsum
head(condsum)
output
##            PLT_CN LIVE_CANOPY_CVR_PCT_PLT
## 1: 40404728010690                       0
## 2: 40404729010690                      17
## 3: 40404730010690                      41
## 4: 40404731010690                       0
## 5: 40404733010690                       0
## 6: 40404734010690                       0

Next, we check results.

condsum[condsum$PLT_CN == 40405596010690,]
output
##            PLT_CN LIVE_CANOPY_CVR_PCT_PLT
## 1: 40405596010690                      27
WYcond[WYcond$PLT_CN == 40405596010690,]
output
##             PLT_CN CONDID COND_NONSAMPLE_REASN_CD CONDPROP_UNADJ SUBPPROP_UNADJ
## 875 40405596010690      1                      NA           0.75           0.75
## 876 40405596010690      2                      NA           0.25           0.25
##     MICRPROP_UNADJ MACRPROP_UNADJ OWNCD OWNGRPCD RESERVCD SITECLCD STDORGCD
## 875           0.75             NA    46       40        0        6        0
## 876           0.25             NA    46       40        0        6        0
##     ADFORCD LIVE_CANOPY_CVR_PCT COND_STATUS_CD NF_COND_STATUS_CD FORTYPCD
## 875      NA                  33              1                NA      221
## 876      NA                   9              1                NA      999
##     STDSZCD STDAGE GSSTKCD DSTRBCD1 DSTRBYR1 DSTRBCD2 DSTRBYR2 FORTYPGRPCD
## 875       1    110       4        0       NA        0       NA         220
## 876       5      0       5        0       NA        0       NA         999
##     TIMBERCD
## 875        1
## 876        1

Next, we can append results to plot table.

condsum <- datSumCond(
              cond = WYcond, 
              plt = WYplt, 
              csumvar = "LIVE_CANOPY_CVR_PCT"
              )$condsum
head(condsum)
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2: 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3: 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4: 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5: 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6: 40404734010690  2013      56     3      2        1 83304  -106.0363
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.41013     2013       NA                     0              2
## 2:   42.40928     2011        1                     0              1
## 3:   42.40953     2013        6                     0              1
## 4:   42.35599     2012       NA                     0              2
## 5:   42.31655     2012       NA                     0              2
## 6:   42.26546     2013       NA                     0              2
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1:                NA      1          1         0         0 Sampled-Nonforest
## 2:                NA      1          1         1        17    Sampled-Forest
## 3:                NA      1          1         1        41    Sampled-Forest
## 4:                NA      1          1         0         0 Sampled-Nonforest
## 5:                NA      1          1         0         0 Sampled-Nonforest
## 6:                NA      1          1         0         0 Sampled-Nonforest
##           PLOT_ID LIVE_CANOPY_CVR_PCT_PLT
## 1: ID560200186688                       0
## 2: ID560200184596                      17
## 3: ID560200188993                      41
## 4: ID560200182340                       0
## 5: ID560200182869                       0
## 6: ID560200183304                       0

We can also add a filter.

condsum <- datSumCond(
              cond = WYcond, 
              plt = WYplt, 
              csumvar = "LIVE_CANOPY_CVR_PCT",
              cfilter = "STDSZCD == 1" 
              )$condsum
head(condsum)
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2: 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3: 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4: 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5: 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6: 40404734010690  2013      56     3      2        1 83304  -106.0363
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.41013     2013       NA                     0              2
## 2:   42.40928     2011        1                     0              1
## 3:   42.40953     2013        6                     0              1
## 4:   42.35599     2012       NA                     0              2
## 5:   42.31655     2012       NA                     0              2
## 6:   42.26546     2013       NA                     0              2
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1:                NA      1          1         0         0 Sampled-Nonforest
## 2:                NA      1          1         1        17    Sampled-Forest
## 3:                NA      1          1         1        41    Sampled-Forest
## 4:                NA      1          1         0         0 Sampled-Nonforest
## 5:                NA      1          1         0         0 Sampled-Nonforest
## 6:                NA      1          1         0         0 Sampled-Nonforest
##           PLOT_ID LIVE_CANOPY_CVR_PCT_PLT
## 1: ID560200186688                      NA
## 2: ID560200184596                      17
## 3: ID560200188993                      41
## 4: ID560200182340                      NA
## 5: ID560200182869                      NA
## 6: ID560200183304                      NA
## Check results
condsum[condsum$CN == 40405596010690,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40405596010690  2012      56     3      3       11 88759  -104.1922
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   44.25247     2012        5                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 1:                NA      2          2         2        27 Sampled-Forest
##           PLOT_ID LIVE_CANOPY_CVR_PCT_PLT
## 1: ID560301188759                   24.75
WYcond[WYcond$PLT_CN == 40405596010690,]
output
##             PLT_CN CONDID COND_NONSAMPLE_REASN_CD CONDPROP_UNADJ SUBPPROP_UNADJ
## 875 40405596010690      1                      NA           0.75           0.75
## 876 40405596010690      2                      NA           0.25           0.25
##     MICRPROP_UNADJ MACRPROP_UNADJ OWNCD OWNGRPCD RESERVCD SITECLCD STDORGCD
## 875           0.75             NA    46       40        0        6        0
## 876           0.25             NA    46       40        0        6        0
##     ADFORCD LIVE_CANOPY_CVR_PCT COND_STATUS_CD NF_COND_STATUS_CD FORTYPCD
## 875      NA                  33              1                NA      221
## 876      NA                   9              1                NA      999
##     STDSZCD STDAGE GSSTKCD DSTRBCD1 DSTRBYR1 DSTRBCD2 DSTRBYR2 FORTYPGRPCD
## 875       1    110       4        0       NA        0       NA         220
## 876       5      0       5        0       NA        0       NA         999
##     TIMBERCD
## 875        1
## 876        1

Next, we look at summed nonforest condition proportions by plot.

condnf <- datSumCond(
              cond = WYcond, 
              plt = WYplt, 
              csumvar = "CONDPROP_UNADJ", 
              csumvarnm = "cond_nf", 
              cfilter = "COND_STATUS_CD %in% c(2,3)"
              )$condsum

condnf[condnf$CN == 40404737010690,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404737010690  2011      56     3      2        1 81546  -105.6062
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.27355     2011        3                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 1:                NA      2          2         1         7 Sampled-Forest
##           PLOT_ID cond_nf
## 1: ID560200181546    0.75
WYcond[WYcond$PLT_CN == 40404737010690,]
output
##            PLT_CN CONDID COND_NONSAMPLE_REASN_CD CONDPROP_UNADJ SUBPPROP_UNADJ
## 9  40404737010690      1                      NA           0.75           0.75
## 10 40404737010690      2                      NA           0.25           0.25
##    MICRPROP_UNADJ MACRPROP_UNADJ OWNCD OWNGRPCD RESERVCD SITECLCD STDORGCD
## 9            0.75             NA    11       10        0       NA       NA
## 10           0.25             NA    11       10        0        7        0
##    ADFORCD LIVE_CANOPY_CVR_PCT COND_STATUS_CD NF_COND_STATUS_CD FORTYPCD
## 9      206                   6              2                NA       NA
## 10     206                  10              1                NA      999
##    STDSZCD STDAGE GSSTKCD DSTRBCD1 DSTRBYR1 DSTRBCD2 DSTRBYR2 FORTYPGRPCD
## 9       NA     NA      NA       NA       NA       NA       NA          NA
## 10       5      0       5        0       NA        0       NA         999
##    TIMBERCD
## 9        NA
## 10        2

Finally, we can look at summed reserved condition proportions by plot.

condres <- datSumCond(
              cond = WYcond, 
              plt = WYplt, 
              csumvar = "CONDPROP_UNADJ",
              csumvarnm = "cond_reserved", 
              cfilter = "RESERVCD == 1"
              )$condsum

WYcond[WYcond$PLT_CN == 46792188020004,]
output
##              PLT_CN CONDID COND_NONSAMPLE_REASN_CD CONDPROP_UNADJ
## 3224 46792188020004      1                      NA              1
##      SUBPPROP_UNADJ MICRPROP_UNADJ MACRPROP_UNADJ OWNCD OWNGRPCD RESERVCD
## 3224              1              1             NA    11       10        1
##      SITECLCD STDORGCD ADFORCD LIVE_CANOPY_CVR_PCT COND_STATUS_CD
## 3224        6        0     214                  48              1
##      NF_COND_STATUS_CD FORTYPCD STDSZCD STDAGE GSSTKCD DSTRBCD1 DSTRBYR1
## 3224                NA      201       1    109       3        0       NA
##      DSTRBCD2 DSTRBYR2 FORTYPGRPCD TIMBERCD
## 3224        0       NA         200        1

datSumTree()

The datSumTree function aggregates tree-level data to plot or condition, including options for filtering tree data or extrapolating to plot acre by multiplying by trees per acre (TPA*).

Returns a list of the following:
treedat - plot or condition-level table with aggregated tree attribute(s).
sumvars - Name(s) of the output aggregated tree attributes.

Example 1: Sum of Basal Area and Net Cubic-foot Volume of Live Trees by Plot (TPA=FALSE)

View Example
treesumdat1 <- datSumTree(
                tree = WYtree, 
                plt = WYplt, 
                tsumvarlst = c("BA", "VOLCFNET"),
                TPA = FALSE, 
                tfilter = "STATUSCD == 1", 
                bycond = FALSE, 
                tround = 2
                )

names(treesumdat1)
output
## [1] "treedat"  "sumvars"  "estunits" "tfilter"  "meta"
treesum1 <- treesumdat1$treedat
head(treesum1)
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2: 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3: 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4: 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5: 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6: 40404734010690  2013      56     3      2        1 83304  -106.0363
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.41013     2013       NA                     0              2
## 2:   42.40928     2011        1                     0              1
## 3:   42.40953     2013        6                     0              1
## 4:   42.35599     2012       NA                     0              2
## 5:   42.31655     2012       NA                     0              2
## 6:   42.26546     2013       NA                     0              2
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1:                NA      1          1         0         0 Sampled-Nonforest
## 2:                NA      1          1         1        17    Sampled-Forest
## 3:                NA      1          1         1        41    Sampled-Forest
## 4:                NA      1          1         0         0 Sampled-Nonforest
## 5:                NA      1          1         0         0 Sampled-Nonforest
## 6:                NA      1          1         0         0 Sampled-Nonforest
##           PLOT_ID BA_live VOLCFNET_live
## 1: ID560200186688      NA            NA
## 2: ID560200184596    2.37         17.03
## 3: ID560200188993   19.33        284.46
## 4: ID560200182340      NA            NA
## 5: ID560200182869      NA            NA
## 6: ID560200183304      NA            NA
treesumdat1$sumvars
output
## [1] "BA_live"       "VOLCFNET_live"

Example 2: Sum of Basal Area Per Acre and Net Cubic-foot Volume Per Acre of Live Trees by Plot (TPA=TRUE)

View Example
treesumdat2 <- datSumTree(
                  tree = WYtree, 
                  plt = WYplt, 
                  tsumvarlst = c("BA", "VOLCFNET"),
                  TPA = TRUE, 
                  tfilter = "STATUSCD == 1", 
                  bycond = FALSE, 
                  tround = 2
                  )

names(treesumdat2)
output
## [1] "treedat"  "sumvars"  "estunits" "tfilter"  "meta"
treesum2 <- treesumdat2$treedat
head(treesum2)
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2: 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3: 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4: 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5: 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6: 40404734010690  2013      56     3      2        1 83304  -106.0363
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.41013     2013       NA                     0              2
## 2:   42.40928     2011        1                     0              1
## 3:   42.40953     2013        6                     0              1
## 4:   42.35599     2012       NA                     0              2
## 5:   42.31655     2012       NA                     0              2
## 6:   42.26546     2013       NA                     0              2
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1:                NA      1          1         0         0 Sampled-Nonforest
## 2:                NA      1          1         1        17    Sampled-Forest
## 3:                NA      1          1         1        41    Sampled-Forest
## 4:                NA      1          1         0         0 Sampled-Nonforest
## 5:                NA      1          1         0         0 Sampled-Nonforest
## 6:                NA      1          1         0         0 Sampled-Nonforest
##           PLOT_ID BA_TPA_live VOLCFNET_TPA_live
## 1: ID560200186688          NA                NA
## 2: ID560200184596       14.27            102.46
## 3: ID560200188993      119.74           1711.92
## 4: ID560200182340          NA                NA
## 5: ID560200182869          NA                NA
## 6: ID560200183304          NA                NA

Example 1 & 2 Check: Test BA Results for 1 Plot

View Check
checkvars <- c("PLT_CN", "CONDID", "SUBP", "TREE", "STATUSCD", "SPCD", "DIA", "HT", 
    "BA", "VOLCFNET", "TPA_UNADJ")
testplt <- WYtree[WYtree$PLT_CN == 40404758010690, checkvars]
testplt
output
##               PLT_CN CONDID SUBP TREE STATUSCD SPCD  DIA HT        BA VOLCFNET
## 14392 40404758010690      1    3    2        2  113   NA NA        NA       NA
## 14972 40404758010690      1    1    1        2  122 13.2 26 0.9503050  6.35026
## 14973 40404758010690      1    1    2        1  122  9.5 23 0.4922235  4.03692
## 14974 40404758010690      1    2    1        1  122  9.0 25 0.4417740  3.92730
## 14975 40404758010690      1    2    2        1  122  8.4 26 0.3848342  3.51595
## 14976 40404758010690      1    2    5        1  122  6.3 24 0.2164693  1.61083
## 14977 40404758010690      1    3    1        1  122  6.5 19 0.2304315  1.28724
## 14978 40404758010690      1    3    3        1  122  6.0 23 0.1963440  1.34178
## 14979 40404758010690      1    4    1        1  122 10.7 27 0.6244285  6.10575
## 14980 40404758010690      1    4    2        1  122  8.0 18 0.3490560  2.04162
## 14981 40404758010690      1    4    3        1  122 15.6 35 1.3272854 17.95132
##       TPA_UNADJ
## 14392        NA
## 14972  6.018046
## 14973  6.018046
## 14974  6.018046
## 14975  6.018046
## 14976  6.018046
## 14977  6.018046
## 14978  6.018046
## 14979  6.018046
## 14980  6.018046
## 14981  6.018046
sum(testplt[testplt$STATUSCD == 1, "BA"], na.rm=TRUE)
output
## [1] 4.262846
sum(testplt[testplt$STATUSCD == 1, "BA"] * testplt[testplt$STATUSCD == 1, "TPA_UNADJ"], na.rm=TRUE)
output
## [1] 25.65401
treesum1[treesum1$CN == 40404758010690,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404758010690  2011      56     3      2        1 87404  -105.4328
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.05634     2011        2                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 1:                NA      1          1         1        18 Sampled-Forest
##           PLOT_ID BA_live VOLCFNET_live
## 1: ID560200187404    4.26         41.82
treesum2[treesum2$CN == 40404758010690,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404758010690  2011      56     3      2        1 87404  -105.4328
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.05634     2011        2                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 1:                NA      1          1         1        18 Sampled-Forest
##           PLOT_ID BA_TPA_live VOLCFNET_TPA_live
## 1: ID560200187404       25.65            251.67

Example 3: Average Diameter and Height of Live Trees by Plot

View Example
treesumdat3 <- datSumTree(
                  tree = WYtree, 
                  plt = WYplt, 
                  tsumvarlst = c("DIA", "HT"),
                  TPA = FALSE, 
                  tfun = mean, 
                  tfilter = "STATUSCD == 1", 
                  bycond = FALSE, 
                  tround = 2
                  )

names(treesumdat3)
output
## [1] "treedat" "sumvars" "tfilter" "meta"
treesum3 <- treesumdat3$treedat
head(treesum3)
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2: 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3: 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4: 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5: 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6: 40404734010690  2013      56     3      2        1 83304  -106.0363
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.41013     2013       NA                     0              2
## 2:   42.40928     2011        1                     0              1
## 3:   42.40953     2013        6                     0              1
## 4:   42.35599     2012       NA                     0              2
## 5:   42.31655     2012       NA                     0              2
## 6:   42.26546     2013       NA                     0              2
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1:                NA      1          1         0         0 Sampled-Nonforest
## 2:                NA      1          1         1        17    Sampled-Forest
## 3:                NA      1          1         1        41    Sampled-Forest
## 4:                NA      1          1         0         0 Sampled-Nonforest
## 5:                NA      1          1         0         0 Sampled-Nonforest
## 6:                NA      1          1         0         0 Sampled-Nonforest
##           PLOT_ID DIA_NA_MEAN HT_NA_MEAN
## 1: ID560200186688          NA         NA
## 2: ID560200184596        9.06      20.00
## 3: ID560200188993        8.68      33.07
## 4: ID560200182340          NA         NA
## 5: ID560200182869          NA         NA
## 6: ID560200183304          NA         NA
## Test DIA and HT results for 1 plot
testplt
output
##               PLT_CN CONDID SUBP TREE STATUSCD SPCD  DIA HT        BA VOLCFNET
## 14392 40404758010690      1    3    2        2  113   NA NA        NA       NA
## 14972 40404758010690      1    1    1        2  122 13.2 26 0.9503050  6.35026
## 14973 40404758010690      1    1    2        1  122  9.5 23 0.4922235  4.03692
## 14974 40404758010690      1    2    1        1  122  9.0 25 0.4417740  3.92730
## 14975 40404758010690      1    2    2        1  122  8.4 26 0.3848342  3.51595
## 14976 40404758010690      1    2    5        1  122  6.3 24 0.2164693  1.61083
## 14977 40404758010690      1    3    1        1  122  6.5 19 0.2304315  1.28724
## 14978 40404758010690      1    3    3        1  122  6.0 23 0.1963440  1.34178
## 14979 40404758010690      1    4    1        1  122 10.7 27 0.6244285  6.10575
## 14980 40404758010690      1    4    2        1  122  8.0 18 0.3490560  2.04162
## 14981 40404758010690      1    4    3        1  122 15.6 35 1.3272854 17.95132
##       TPA_UNADJ
## 14392        NA
## 14972  6.018046
## 14973  6.018046
## 14974  6.018046
## 14975  6.018046
## 14976  6.018046
## 14977  6.018046
## 14978  6.018046
## 14979  6.018046
## 14980  6.018046
## 14981  6.018046
mean(testplt[testplt$STATUSCD == 1, "DIA"], na.rm=TRUE)
output
## [1] 8.888889
mean(testplt[testplt$STATUSCD == 1, "HT"], na.rm=TRUE)
output
## [1] 24.44444
treesum3[treesum3$CN == 40404758010690,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404758010690  2011      56     3      2        1 87404  -105.4328
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.05634     2011        2                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 1:                NA      1          1         1        18 Sampled-Forest
##           PLOT_ID DIA_NA_MEAN HT_NA_MEAN
## 1: ID560200187404        8.89      24.44

Example 4a: Number of Live Trees by Plot (TPA=TRUE)

View Example
treesumdat4a <- datSumTree(
                  tree = WYtree, 
                  plt = WYplt, 
                  tsumvarlst = "TPA_UNADJ",
                  TPA = TRUE, 
                  tfilter = "STATUSCD == 1", 
                  bycond = FALSE, 
                  tround = 2
                  )

names(treesumdat4a)
output
## [1] "treedat" "sumvars" "tfilter" "meta"
treesum4a <- treesumdat4a$treedat
head(treesum4a)
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2: 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3: 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4: 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5: 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6: 40404734010690  2013      56     3      2        1 83304  -106.0363
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.41013     2013       NA                     0              2
## 2:   42.40928     2011        1                     0              1
## 3:   42.40953     2013        6                     0              1
## 4:   42.35599     2012       NA                     0              2
## 5:   42.31655     2012       NA                     0              2
## 6:   42.26546     2013       NA                     0              2
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1:                NA      1          1         0         0 Sampled-Nonforest
## 2:                NA      1          1         1        17    Sampled-Forest
## 3:                NA      1          1         1        41    Sampled-Forest
## 4:                NA      1          1         0         0 Sampled-Nonforest
## 5:                NA      1          1         0         0 Sampled-Nonforest
## 6:                NA      1          1         0         0 Sampled-Nonforest
##           PLOT_ID COUNT_TPA_live
## 1: ID560200186688             NA
## 2: ID560200184596          30.09
## 3: ID560200188993         315.69
## 4: ID560200182340             NA
## 5: ID560200182869             NA
## 6: ID560200183304             NA

Example 4b: Adjust Summed Live Tree Volume to Account for Nonsampled Conditions on Plot

View Example

Note: Must include condition table for condition proportion variables

treesumdat4b <- datSumTree(
                  tree = WYtree, 
                  plt = WYplt, 
                  cond = WYcond, 
                  tsumvarlst = "VOLCFNET",
                  tfilter = "STATUSCD == 1", 
                  bycond = FALSE, 
                  getadjplot = TRUE
                  )

names(treesumdat4b)
output
## [1] "treedat"  "sumvars"  "estunits" "tfilter"  "meta"
treesum4b <- treesumdat4b$treedat
head(treesum4b)
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2: 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3: 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4: 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5: 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6: 40404734010690  2013      56     3      2        1 83304  -106.0363
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.41013     2013       NA                     0              2
## 2:   42.40928     2011        1                     0              1
## 3:   42.40953     2013        6                     0              1
## 4:   42.35599     2012       NA                     0              2
## 5:   42.31655     2012       NA                     0              2
## 6:   42.26546     2013       NA                     0              2
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1:                NA      1          1         0         0 Sampled-Nonforest
## 2:                NA      1          1         1        17    Sampled-Forest
## 3:                NA      1          1         1        41    Sampled-Forest
## 4:                NA      1          1         0         0 Sampled-Nonforest
## 5:                NA      1          1         0         0 Sampled-Nonforest
## 6:                NA      1          1         0         0 Sampled-Nonforest
##           PLOT_ID VOLCFNET_TPA_live_ADJ
## 1: ID560200186688                    NA
## 2: ID560200184596              102.4599
## 3: ID560200188993             1711.9177
## 4: ID560200182340                    NA
## 5: ID560200182869                    NA
## 6: ID560200183304                    NA

Example 4c: Compare with Unadjusted Estimate for Plot Where 25% of Plot is Nonsampled (COND_STATUS_CD = 5 and CONDPROP_UNADJ = 0.25)

View Example
treesumdat4c <- datSumTree(
                  tree = WYtree, 
                  plt = WYplt, 
                  cond = WYcond, 
                  tsumvarlst = "VOLCFNET",
                  tfilter = "STATUSCD == 1", 
                  bycond = FALSE, 
                  getadjplot = FALSE
                  )

treesum4c <- treesumdat4c$treedat

cn <- 40407815010690
WYcond[WYcond$PLT_CN == cn, ]
output
##              PLT_CN CONDID COND_NONSAMPLE_REASN_CD CONDPROP_UNADJ
## 3168 40407815010690      1                      NA            0.5
## 3169 40407815010690      2                       3            0.5
##      SUBPPROP_UNADJ MICRPROP_UNADJ MACRPROP_UNADJ OWNCD OWNGRPCD RESERVCD
## 3168            0.5            0.5             NA    22       20        0
## 3169            0.5            0.5             NA    22       20        0
##      SITECLCD STDORGCD ADFORCD LIVE_CANOPY_CVR_PCT COND_STATUS_CD
## 3168        6        0      NA                  76              1
## 3169       NA       NA      NA                  NA              5
##      NF_COND_STATUS_CD FORTYPCD STDSZCD STDAGE GSSTKCD DSTRBCD1 DSTRBYR1
## 3168                NA      706       2     50       4        0       NA
## 3169                NA       NA      NA     NA      NA       NA       NA
##      DSTRBCD2 DSTRBYR2 FORTYPGRPCD TIMBERCD
## 3168        0       NA         700        1
## 3169       NA       NA          NA       NA
treesum4b[treesum4b$CN == cn, ]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40407815010690  2011      56     3      3       45 88008  -104.0586
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   43.97663     2011        2                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 1:                NA      2          1         1        38 Sampled-Forest
##           PLOT_ID VOLCFNET_TPA_live_ADJ
## 1: ID560304588008              465.2634
treesum4c[treesum4c$CN == cn, ]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40407815010690  2011      56     3      3       45 88008  -104.0586
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   43.97663     2011        2                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 1:                NA      2          1         1        38 Sampled-Forest
##           PLOT_ID VOLCFNET_TPA_live
## 1: ID560304588008          232.6317

Example 5a: Number of Live Trees Plus Seedlings by Plot (TPA=TRUE)

View Example
treesumdat5a <- datSumTree(
                  tree = WYtree, 
                  plt = WYplt, 
                  seed = WYseed, 
                  tsumvarlst = "TPA_UNADJ",
                  TPA = TRUE, 
                  addseed = TRUE, 
                  tfilter = "STATUSCD == 1", 
                  bycond = FALSE, 
                  tround = 2
                  )

names(treesumdat5a)
output
## [1] "treedat" "sumvars" "tfilter" "meta"
treesum5a <- treesumdat5a$treedat
head(treesum5a)
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2: 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3: 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4: 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5: 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6: 40404734010690  2013      56     3      2        1 83304  -106.0363
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.41013     2013       NA                     0              2
## 2:   42.40928     2011        1                     0              1
## 3:   42.40953     2013        6                     0              1
## 4:   42.35599     2012       NA                     0              2
## 5:   42.31655     2012       NA                     0              2
## 6:   42.26546     2013       NA                     0              2
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1:                NA      1          1         0         0 Sampled-Nonforest
## 2:                NA      1          1         1        17    Sampled-Forest
## 3:                NA      1          1         1        41    Sampled-Forest
## 4:                NA      1          1         0         0 Sampled-Nonforest
## 5:                NA      1          1         0         0 Sampled-Nonforest
## 6:                NA      1          1         0         0 Sampled-Nonforest
##           PLOT_ID COUNT_TPA_live SEED_COUNT_TPA_live TREE_COUNT_TPA_live
## 1: ID560200186688             NA                  NA                  NA
## 2: ID560200184596         105.06               74.97               30.09
## 3: ID560200188993         540.59              224.90              315.69
## 4: ID560200182340             NA                  NA                  NA
## 5: ID560200182869             NA                  NA                  NA
## 6: ID560200183304             NA                  NA                  NA
treesum5a[treesum5a$CN %in% cn,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40407815010690  2011      56     3      3       45 88008  -104.0586
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   43.97663     2011        2                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 1:                NA      2          1         1        38 Sampled-Forest
##           PLOT_ID COUNT_TPA_live SEED_COUNT_TPA_live TREE_COUNT_TPA_live
## 1: ID560304588008         273.04               224.9               48.14
WYseed[WYseed$PLT_CN == cn,]
output
##              PLT_CN SUBP CONDID SPCD SPGRPCD TPA_UNADJ TREECOUNT TREECOUNT_CALC
## 1603 40407815010690    1      1  313      47  224.8958         3              3
##      SEEDCNT6 SEEDSUBP6
## 1603        3         0

Example 5b: Number of Live Trees Plus Seedlings by Plot (TPA=TRUE) - Adjusted

View Example
treesumdat5b <- datSumTree(
                  tree = WYtree, 
                  plt = WYplt, 
                  cond = WYcond, 
                  seed = WYseed, 
                  tsumvarlst = "TPA_UNADJ",
                  TPA = TRUE, 
                  addseed = TRUE, 
                  tfilter = "STATUSCD == 1", 
                  bycond = FALSE, 
                  tround = 2,
                  getadjplot  =TRUE
                  )

names(treesumdat5b)
output
## [1] "treedat" "sumvars" "tfilter" "meta"
treesum5b <- treesumdat5b$treedat
head(treesum5b)
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2: 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3: 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4: 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5: 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6: 40404734010690  2013      56     3      2        1 83304  -106.0363
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   42.41013     2013       NA                     0              2
## 2:   42.40928     2011        1                     0              1
## 3:   42.40953     2013        6                     0              1
## 4:   42.35599     2012       NA                     0              2
## 5:   42.31655     2012       NA                     0              2
## 6:   42.26546     2013       NA                     0              2
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1:                NA      1          1         0         0 Sampled-Nonforest
## 2:                NA      1          1         1        17    Sampled-Forest
## 3:                NA      1          1         1        41    Sampled-Forest
## 4:                NA      1          1         0         0 Sampled-Nonforest
## 5:                NA      1          1         0         0 Sampled-Nonforest
## 6:                NA      1          1         0         0 Sampled-Nonforest
##           PLOT_ID COUNT_TPA_live_ADJ SEED_COUNT_TPA_live_ADJ
## 1: ID560200186688                 NA                      NA
## 2: ID560200184596             105.06                   74.97
## 3: ID560200188993             540.59                  224.90
## 4: ID560200182340                 NA                      NA
## 5: ID560200182869                 NA                      NA
## 6: ID560200183304                 NA                      NA
##    TREE_COUNT_TPA_live_ADJ
## 1:                      NA
## 2:                   30.09
## 3:                  315.69
## 4:                      NA
## 5:                      NA
## 6:                      NA
treesum5a[treesum5a$CN %in% cn,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40407815010690  2011      56     3      3       45 88008  -104.0586
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   43.97663     2011        2                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 1:                NA      2          1         1        38 Sampled-Forest
##           PLOT_ID COUNT_TPA_live SEED_COUNT_TPA_live TREE_COUNT_TPA_live
## 1: ID560304588008         273.04               224.9               48.14
treesum5b[treesum5b$CN %in% cn,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1: 40407815010690  2011      56     3      3       45 88008  -104.0586
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1:   43.97663     2011        2                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 1:                NA      2          1         1        38 Sampled-Forest
##           PLOT_ID COUNT_TPA_live_ADJ SEED_COUNT_TPA_live_ADJ
## 1: ID560304588008             546.08                  449.79
##    TREE_COUNT_TPA_live_ADJ
## 1:                   96.29
WYcond[WYcond$PLT_CN %in% cn,]
output
##              PLT_CN CONDID COND_NONSAMPLE_REASN_CD CONDPROP_UNADJ
## 3168 40407815010690      1                      NA            0.5
## 3169 40407815010690      2                       3            0.5
##      SUBPPROP_UNADJ MICRPROP_UNADJ MACRPROP_UNADJ OWNCD OWNGRPCD RESERVCD
## 3168            0.5            0.5             NA    22       20        0
## 3169            0.5            0.5             NA    22       20        0
##      SITECLCD STDORGCD ADFORCD LIVE_CANOPY_CVR_PCT COND_STATUS_CD
## 3168        6        0      NA                  76              1
## 3169       NA       NA      NA                  NA              5
##      NF_COND_STATUS_CD FORTYPCD STDSZCD STDAGE GSSTKCD DSTRBCD1 DSTRBYR1
## 3168                NA      706       2     50       4        0       NA
## 3169                NA       NA      NA     NA      NA       NA       NA
##      DSTRBCD2 DSTRBYR2 FORTYPGRPCD TIMBERCD
## 3168        0       NA         700        1
## 3169       NA       NA          NA       NA

datSumTreeDom()

The datSumTreeDom function aggregates tree-level data to plot or condition, including options for filtering tree data or extrapolating to plot acre by multiplying by TPA.

It returns a list of the following:
tdomdat - plot or condition-level table with aggregated tree domain attributes.
tdomsum - the tdom look-up table with data aggregated by species.
tsumvar - name of aggregated output variable.
tdomlst - list of the aggregated data in tdomdat.
tdomdat.pres - if presence=TRUE, plot or condition-level table with aggregated domain attributes represented as presence/absence (1/0).
tdomdat.prop - if presence=TRUE, plot or condition-level table with aggregated domain attributes represented as proportion of total by plot.
tdomdat.pres - if presence=TRUE, plot or condition-level table with aggregated domain attributes represented as percent cover, multiplying cover attribute by tdom proportion by plot.

Example 1: Sum of Live Basal Area Per Acre by Species

View Example
treedomBA <- datSumTreeDom(
                tree = WYtree, 
                cond = WYcond, 
                plt = WYplt, 
                puniqueid = "CN", 
                bycond = FALSE, 
                tsumvar = "BA", 
                TPA = TRUE, 
                tdomtot = TRUE, 
                tdomtotnm = "BA_LIVE", 
                tdomprefix = "BA_LIVE", 
                tround = 2, 
                tfilter = "STATUSCD==1"
                )

names(treedomBA)
output
## [1] "tdomdat"    "estunits"   "tdomvarlut" "tdomlst"    "tdomtotnm"
tdomdat <- treedomBA$tdomdat
tdomvarlut <- treedomBA$tdomvarlut
tdomlst <- treedomBA$tdomlst
tdomtotnm <- treedomBA$tdomtotnm

head(tdomdat)
output
##               CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6 40404734010690  2013      56     3      2        1 83304  -106.0363
##   LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1   42.41013     2013       NA                     0              2
## 2   42.40928     2011        1                     0              1
## 3   42.40953     2013        6                     0              1
## 4   42.35599     2012       NA                     0              2
## 5   42.31655     2012       NA                     0              2
## 6   42.26546     2013       NA                     0              2
##   NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1                NA      1          1         0         0 Sampled-Nonforest
## 2                NA      1          1         1        17    Sampled-Forest
## 3                NA      1          1         1        41    Sampled-Forest
## 4                NA      1          1         0         0 Sampled-Nonforest
## 5                NA      1          1         0         0 Sampled-Nonforest
## 6                NA      1          1         0         0 Sampled-Nonforest
##          PLOT_ID BA_LIVE019 BA_LIVE065 BA_LIVE066 BA_LIVE093 BA_LIVE096
## 1 ID560200186688          0          0       0.00          0          0
## 2 ID560200184596          0          0       8.24          0          0
## 3 ID560200188993          0          0       0.00          0          0
## 4 ID560200182340          0          0       0.00          0          0
## 5 ID560200182869          0          0       0.00          0          0
## 6 ID560200183304          0          0       0.00          0          0
##   BA_LIVE101 BA_LIVE106 BA_LIVE108 BA_LIVE113 BA_LIVE122 BA_LIVE202 BA_LIVE313
## 1          0          0       0.00       0.00       0.00       0.00          0
## 2          0          0       0.00       6.03       0.00       0.00          0
## 3          0          0       1.61      12.56      41.04      64.53          0
## 4          0          0       0.00       0.00       0.00       0.00          0
## 5          0          0       0.00       0.00       0.00       0.00          0
## 6          0          0       0.00       0.00       0.00       0.00          0
##   BA_LIVE375 BA_LIVE475 BA_LIVE544 BA_LIVE745 BA_LIVE746 BA_LIVE749 BA_LIVE823
## 1          0          0          0          0          0          0          0
## 2          0          0          0          0          0          0          0
## 3          0          0          0          0          0          0          0
## 4          0          0          0          0          0          0          0
## 5          0          0          0          0          0          0          0
## 6          0          0          0          0          0          0          0
##   BA_TPA
## 1   0.00
## 2  14.27
## 3 119.74
## 4   0.00
## 5   0.00
## 6   0.00
tdomvarlut
output
##    SPCD                        SPNM     SPCDNM       BA_TPA NBRPLOTS
## 1    19               subalpine fir BA_LIVE019 7.418824e+03      217
## 2    65                Utah juniper BA_LIVE065 2.209716e+03       20
## 3    66      Rocky Mountain juniper BA_LIVE066 1.355606e+03       65
## 4    93            Engelmann spruce BA_LIVE093 6.306562e+03      185
## 5    96                 blue spruce BA_LIVE096 7.334475e+01        3
## 6   101              whitebark pine BA_LIVE101 1.616618e+03       90
## 7   106 common or two-needle pinyon BA_LIVE106 4.570194e+00        1
## 8   108              lodgepole pine BA_LIVE108 1.104169e+04      232
## 9   113                 limber pine BA_LIVE113 6.582401e+02       69
## 10  122              ponderosa pine BA_LIVE122 3.885423e+03       86
## 11  202                 Douglas-fir BA_LIVE202 3.345905e+03       95
## 12  313                    boxelder BA_LIVE313 2.761876e+01        2
## 13  375                 paper birch BA_LIVE375 5.887593e-01        1
## 14  475  curlleaf mountain-mahogany BA_LIVE475 8.472780e+00        2
## 15  544                   green ash BA_LIVE544 3.091347e+01        2
## 16  745           plains cottonwood BA_LIVE745 2.263776e+02        3
## 17  746               quaking aspen BA_LIVE746 1.241932e+03       63
## 18  749       narrowleaf cottonwood BA_LIVE749 1.668582e+02        4
## 19  823                     bur oak BA_LIVE823 1.804395e+02       12
tdomlst
output
##  [1] "BA_LIVE019" "BA_LIVE065" "BA_LIVE066" "BA_LIVE093" "BA_LIVE096"
##  [6] "BA_LIVE101" "BA_LIVE106" "BA_LIVE108" "BA_LIVE113" "BA_LIVE122"
## [11] "BA_LIVE202" "BA_LIVE313" "BA_LIVE375" "BA_LIVE475" "BA_LIVE544"
## [16] "BA_LIVE745" "BA_LIVE746" "BA_LIVE749" "BA_LIVE823"
tdomtotnm
output
## [1] "BA_TPA"
dim(WYplt)
output
## [1] 3047   20
dim(tdomdat)
output
## [1] 3047   40

Example 2: Number of Live Trees by Species

View Example
treedomCNT <- datSumTreeDom(
                tree = WYtree, 
                cond = WYcond, 
                plt = WYplt, 
                puniqueid = "CN", 
                bycond = FALSE, 
                tsumvar = "PLT_CN", 
                TPA = TRUE, 
                tdomtot = TRUE, 
                tdomprefix = "CNT", 
                tround = 0, 
                tfilter = "STATUSCD==1"
                )

names(treedomCNT)
output
## [1] "tdomdat"    "tdomvarlut" "tdomlst"    "tdomtotnm"
tdomdat.tree <- treedomCNT$tdomdat
tdomvarlut <- treedomCNT$tdomvarlut
tdomlst <- treedomCNT$tdomlst
tdomtotnm <- treedomCNT$tdomtotnm

head(tdomdat.tree)
output
##               CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6 40404734010690  2013      56     3      2        1 83304  -106.0363
##   LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1   42.41013     2013       NA                     0              2
## 2   42.40928     2011        1                     0              1
## 3   42.40953     2013        6                     0              1
## 4   42.35599     2012       NA                     0              2
## 5   42.31655     2012       NA                     0              2
## 6   42.26546     2013       NA                     0              2
##   NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1                NA      1          1         0         0 Sampled-Nonforest
## 2                NA      1          1         1        17    Sampled-Forest
## 3                NA      1          1         1        41    Sampled-Forest
## 4                NA      1          1         0         0 Sampled-Nonforest
## 5                NA      1          1         0         0 Sampled-Nonforest
## 6                NA      1          1         0         0 Sampled-Nonforest
##          PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT106 CNT108 CNT113
## 1 ID560200186688      0      0      0      0      0      0      0      0      0
## 2 ID560200184596      0      0     12      0      0      0      0      0     18
## 3 ID560200188993      0      0      0      0      0      0      0      6     36
## 4 ID560200182340      0      0      0      0      0      0      0      0      0
## 5 ID560200182869      0      0      0      0      0      0      0      0      0
## 6 ID560200183304      0      0      0      0      0      0      0      0      0
##   CNT122 CNT202 CNT313 CNT375 CNT475 CNT544 CNT745 CNT746 CNT749 CNT823
## 1      0      0      0      0      0      0      0      0      0      0
## 2      0      0      0      0      0      0      0      0      0      0
## 3    135    138      0      0      0      0      0      0      0      0
## 4      0      0      0      0      0      0      0      0      0      0
## 5      0      0      0      0      0      0      0      0      0      0
## 6      0      0      0      0      0      0      0      0      0      0
##   COUNT_TPA
## 1         0
## 2        30
## 3       315
## 4         0
## 5         0
## 6         0

Example 3: Number of Live Trees by Species - Seedlings

View Example
treedomCNTs <- datSumTreeDom(
                cond = WYcond, 
                plt = WYplt, 
                seed = WYseed, 
                puniqueid = "CN", 
                bycond = FALSE, 
                tsumvar = "PLT_CN", 
                TPA = TRUE, 
                tdomtot = TRUE, 
                tdomprefix = "CNT", 
                tround = 0
                )

names(treedomCNTs)
output
## [1] "tdomdat"    "tdomvarlut" "tdomlst"    "tdomtotnm"
tdomdat.seed <- treedomCNTs$tdomdat
tdomvarlut <- treedomCNTs$tdomvarlut
tdomlst <- treedomCNTs$tdomlst
tdomtotnm <- treedomCNTs$tdomtotnm

head(tdomdat.seed)
output
##               CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6 40404734010690  2013      56     3      2        1 83304  -106.0363
##   LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1   42.41013     2013       NA                     0              2
## 2   42.40928     2011        1                     0              1
## 3   42.40953     2013        6                     0              1
## 4   42.35599     2012       NA                     0              2
## 5   42.31655     2012       NA                     0              2
## 6   42.26546     2013       NA                     0              2
##   NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1                NA      1          1         0         0 Sampled-Nonforest
## 2                NA      1          1         1        17    Sampled-Forest
## 3                NA      1          1         1        41    Sampled-Forest
## 4                NA      1          1         0         0 Sampled-Nonforest
## 5                NA      1          1         0         0 Sampled-Nonforest
## 6                NA      1          1         0         0 Sampled-Nonforest
##          PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT108 CNT113 CNT122
## 1 ID560200186688      0      0      0      0      0      0      0      0      0
## 2 ID560200184596      0      0      0      0      0      0      0     75      0
## 3 ID560200188993      0      0      0      0      0      0      0      0      0
## 4 ID560200182340      0      0      0      0      0      0      0      0      0
## 5 ID560200182869      0      0      0      0      0      0      0      0      0
## 6 ID560200183304      0      0      0      0      0      0      0      0      0
##   CNT202 CNT313 CNT375 CNT544 CNT746 CNT749 CNT823 COUNT_TPA
## 1      0      0      0      0      0      0      0         0
## 2      0      0      0      0      0      0      0        75
## 3    225      0      0      0      0      0      0       225
## 4      0      0      0      0      0      0      0         0
## 5      0      0      0      0      0      0      0         0
## 6      0      0      0      0      0      0      0         0

Example 4: Number of Live Trees by Species, Including Seedlings

View Example
treedomCNTs <- datSumTreeDom(
                tree = WYtree, 
                cond = WYcond, 
                plt = WYplt, 
                seed = WYseed, 
                puniqueid = "CN", 
                bycond  =FALSE, 
                tsumvar = "PLT_CN", 
                TPA = TRUE, 
                tdomtot = TRUE, 
                tdomprefix = "CNT", 
                tround = 0, 
                tfilter = "STATUSCD==1", 
                addseed = TRUE
                )

names(treedomCNTs)
output
## [1] "tdomdat"    "tdomvarlut" "tdomlst"    "tdomtotnm"
tdomdat.treeseed <- treedomCNTs$tdomdat
tdomvarlut <- treedomCNTs$tdomvarlut
tdomlst <- treedomCNTs$tdomlst
tdomtotnm <- treedomCNTs$tdomtotnm

head(tdomdat.treeseed)
output
##               CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6 40404734010690  2013      56     3      2        1 83304  -106.0363
##   LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1   42.41013     2013       NA                     0              2
## 2   42.40928     2011        1                     0              1
## 3   42.40953     2013        6                     0              1
## 4   42.35599     2012       NA                     0              2
## 5   42.31655     2012       NA                     0              2
## 6   42.26546     2013       NA                     0              2
##   NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1                NA      1          1         0         0 Sampled-Nonforest
## 2                NA      1          1         1        17    Sampled-Forest
## 3                NA      1          1         1        41    Sampled-Forest
## 4                NA      1          1         0         0 Sampled-Nonforest
## 5                NA      1          1         0         0 Sampled-Nonforest
## 6                NA      1          1         0         0 Sampled-Nonforest
##          PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT106 CNT108 CNT113
## 1 ID560200186688      0      0      0      0      0      0      0      0      0
## 2 ID560200184596      0      0     12      0      0      0      0      0     93
## 3 ID560200188993      0      0      0      0      0      0      0      6     36
## 4 ID560200182340      0      0      0      0      0      0      0      0      0
## 5 ID560200182869      0      0      0      0      0      0      0      0      0
## 6 ID560200183304      0      0      0      0      0      0      0      0      0
##   CNT122 CNT202 CNT313 CNT375 CNT475 CNT544 CNT745 CNT746 CNT749 CNT823
## 1      0      0      0      0      0      0      0      0      0      0
## 2      0      0      0      0      0      0      0      0      0      0
## 3    135    363      0      0      0      0      0      0      0      0
## 4      0      0      0      0      0      0      0      0      0      0
## 5      0      0      0      0      0      0      0      0      0      0
## 6      0      0      0      0      0      0      0      0      0      0
##   COUNT_TPA
## 1         0
## 2       105
## 3       540
## 4         0
## 5         0
## 6         0
cn <- 40404730010690
tdomdat.tree[tdomdat.tree$CN == cn,]
output
##               CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 3 40404730010690  2013      56     3      2        1 88993  -105.6679
##   LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 3   42.40953     2013        6                     0              1
##   NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 3                NA      1          1         1        41 Sampled-Forest
##          PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT106 CNT108 CNT113
## 3 ID560200188993      0      0      0      0      0      0      0      6     36
##   CNT122 CNT202 CNT313 CNT375 CNT475 CNT544 CNT745 CNT746 CNT749 CNT823
## 3    135    138      0      0      0      0      0      0      0      0
##   COUNT_TPA
## 3       315
tdomdat.seed[tdomdat.seed$CN == cn,]
output
##               CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 3 40404730010690  2013      56     3      2        1 88993  -105.6679
##   LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 3   42.40953     2013        6                     0              1
##   NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 3                NA      1          1         1        41 Sampled-Forest
##          PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT108 CNT113 CNT122
## 3 ID560200188993      0      0      0      0      0      0      0      0      0
##   CNT202 CNT313 CNT375 CNT544 CNT746 CNT749 CNT823 COUNT_TPA
## 3    225      0      0      0      0      0      0       225
tdomdat.treeseed[tdomdat.treeseed$CN == cn,]
output
##               CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 3 40404730010690  2013      56     3      2        1 88993  -105.6679
##   LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 3   42.40953     2013        6                     0              1
##   NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 3                NA      1          1         1        41 Sampled-Forest
##          PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT106 CNT108 CNT113
## 3 ID560200188993      0      0      0      0      0      0      0      6     36
##   CNT122 CNT202 CNT313 CNT375 CNT475 CNT544 CNT745 CNT746 CNT749 CNT823
## 3    135    363      0      0      0      0      0      0      0      0
##   COUNT_TPA
## 3       540

Example 5: Presence of Live Trees by Species, Including Seedlings

View Example
treedomCNTs <- datSumTreeDom(
                  tree = WYtree, 
                  cond = WYcond, 
                  plt = WYplt, 
                  seed = WYseed, 
                  puniqueid ="CN", 
                  bycond = FALSE, 
                  tsumvar = "PLT_CN", 
                  TPA = TRUE, 
                  tdomtot = TRUE, 
                  tdomprefix = "CNT", 
                  savedata = FALSE, 
                  tfilter = "STATUSCD==1", 
                  addseed = TRUE, 
                  presence = TRUE
                  )

names(treedomCNTs)
output
## [1] "tdomdat"      "tdomdat.pres" "tdomvarlut"   "tdomlst"      "tdomtotnm"
tdomdat.pres <- treedomCNTs$tdomdat.pres

head(tdomdat.pres)
output
##               CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6 40404734010690  2013      56     3      2        1 83304  -106.0363
##   LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1   42.41013     2013       NA                     0              2
## 2   42.40928     2011        1                     0              1
## 3   42.40953     2013        6                     0              1
## 4   42.35599     2012       NA                     0              2
## 5   42.31655     2012       NA                     0              2
## 6   42.26546     2013       NA                     0              2
##   NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1                NA      1          1         0         0 Sampled-Nonforest
## 2                NA      1          1         1        17    Sampled-Forest
## 3                NA      1          1         1        41    Sampled-Forest
## 4                NA      1          1         0         0 Sampled-Nonforest
## 5                NA      1          1         0         0 Sampled-Nonforest
## 6                NA      1          1         0         0 Sampled-Nonforest
##          PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT106 CNT108 CNT113
## 1 ID560200186688      0      0      0      0      0      0      0      0      0
## 2 ID560200184596      0      0      1      0      0      0      0      0      1
## 3 ID560200188993      0      0      0      0      0      0      0      1      1
## 4 ID560200182340      0      0      0      0      0      0      0      0      0
## 5 ID560200182869      0      0      0      0      0      0      0      0      0
## 6 ID560200183304      0      0      0      0      0      0      0      0      0
##   CNT122 CNT202 CNT313 CNT375 CNT475 CNT544 CNT745 CNT746 CNT749 CNT823
## 1      0      0      0      0      0      0      0      0      0      0
## 2      0      0      0      0      0      0      0      0      0      0
## 3      1      1      0      0      0      0      0      0      0      0
## 4      0      0      0      0      0      0      0      0      0      0
## 5      0      0      0      0      0      0      0      0      0      0
## 6      0      0      0      0      0      0      0      0      0      0
##   COUNT_TPA
## 1         0
## 2         1
## 3         1
## 4         0
## 5         0
## 6         0

Example 6: Presence and Proportion of Live Trees by Species, Including Seedlings

View Example
treedomCNTs <- datSumTreeDom(tree=WYtree, cond=WYcond, plt=WYplt, seed=WYseed, 
        puniqueid="CN", bycond=FALSE, tsumvar="PLT_CN", TPA=TRUE, tdomtot=TRUE,
        tdomprefix="CNT", savedata=FALSE, tround=0, tfilter="STATUSCD==1",
          addseed=TRUE, presence=TRUE, proportion=TRUE)
names(treedomCNTs)
output
## [1] "tdomdat"      "tdomdat.prop" "tdomdat.pres" "tdomvarlut"   "tdomlst"     
## [6] "tdomtotnm"
tdomdat.pres <- treedomCNTs$tdomdat.pres
tdomdat.prop <- treedomCNTs$tdomdat.prop

head(tdomdat.pres)
output
##               CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6 40404734010690  2013      56     3      2        1 83304  -106.0363
##   LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1   42.41013     2013       NA                     0              2
## 2   42.40928     2011        1                     0              1
## 3   42.40953     2013        6                     0              1
## 4   42.35599     2012       NA                     0              2
## 5   42.31655     2012       NA                     0              2
## 6   42.26546     2013       NA                     0              2
##   NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1                NA      1          1         0         0 Sampled-Nonforest
## 2                NA      1          1         1        17    Sampled-Forest
## 3                NA      1          1         1        41    Sampled-Forest
## 4                NA      1          1         0         0 Sampled-Nonforest
## 5                NA      1          1         0         0 Sampled-Nonforest
## 6                NA      1          1         0         0 Sampled-Nonforest
##          PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT106 CNT108 CNT113
## 1 ID560200186688      0      0      0      0      0      0      0      0      0
## 2 ID560200184596      0      0      1      0      0      0      0      0      1
## 3 ID560200188993      0      0      0      0      0      0      0      1      1
## 4 ID560200182340      0      0      0      0      0      0      0      0      0
## 5 ID560200182869      0      0      0      0      0      0      0      0      0
## 6 ID560200183304      0      0      0      0      0      0      0      0      0
##   CNT122 CNT202 CNT313 CNT375 CNT475 CNT544 CNT745 CNT746 CNT749 CNT823
## 1      0      0      0      0      0      0      0      0      0      0
## 2      0      0      0      0      0      0      0      0      0      0
## 3      1      1      0      0      0      0      0      0      0      0
## 4      0      0      0      0      0      0      0      0      0      0
## 5      0      0      0      0      0      0      0      0      0      0
## 6      0      0      0      0      0      0      0      0      0      0
##   COUNT_TPA
## 1         0
## 2         1
## 3         1
## 4         0
## 5         0
## 6         0

Example 7: Presence and Proportion and Cover of Live Trees by Species, Including Seedlings (Add Barplot)

View Example
treedomCNTs <- datSumTreeDom(
                tree = WYtree, 
                cond = WYcond, 
                plt = WYplt, 
                seed = WYseed, 
                puniqueid = "CN", 
                bycond = FALSE, 
                tsumvar = "PLT_CN", 
                TPA = TRUE, 
                tdomtot = TRUE, 
                tdomprefix = "CNT", 
                tround = 0, 
                tfilter = "STATUSCD==1",
                addseed = TRUE, 
                presence = TRUE, 
                proportion = TRUE, 
                cover = TRUE, 
                tdombarplot = TRUE
                )
plot

plot

names(treedomCNTs)
output
## [1] "tdomdat"      "tdomdat.prop" "tdomdat.pres" "tdomdat.cov"  "tdomvarlut"  
## [6] "tdomlst"      "tdomtotnm"
tdomdat.pres <- treedomCNTs$tdomdat.pres
tdomdat.prop <- treedomCNTs$tdomdat.prop
tdomdat.cov <- treedomCNTs$tdomdat.cov

cn=40404742010690
tdomdat.tree[tdomdat.tree$CN == cn,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 13 40404742010690  2011      56     3      2        1 83075  -105.4286
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 13   42.22974     2011        6                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 13                NA      1          1         1        24 Sampled-Forest
##           PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT106 CNT108
## 13 ID560200183075      0      0      0      0      0      0      0      0
##    CNT113 CNT122 CNT202 CNT313 CNT375 CNT475 CNT544 CNT745 CNT746 CNT749 CNT823
## 13      0     42      0      0      0      0      0      0      0      0      0
##    COUNT_TPA
## 13        42
tdomdat.seed[tdomdat.seed$CN == cn,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 13 40404742010690  2011      56     3      2        1 83075  -105.4286
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 13   42.22974     2011        6                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 13                NA      1          1         1        24 Sampled-Forest
##           PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT108 CNT113
## 13 ID560200183075      0      0      0      0      0      0      0      0
##    CNT122 CNT202 CNT313 CNT375 CNT544 CNT746 CNT749 CNT823 COUNT_TPA
## 13      0      0      0      0      0   1124      0      0      1124
tdomdat.treeseed[tdomdat.treeseed$CN == cn,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 13 40404742010690  2011      56     3      2        1 83075  -105.4286
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 13   42.22974     2011        6                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 13                NA      1          1         1        24 Sampled-Forest
##           PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT106 CNT108
## 13 ID560200183075      0      0      0      0      0      0      0      0
##    CNT113 CNT122 CNT202 CNT313 CNT375 CNT475 CNT544 CNT745 CNT746 CNT749 CNT823
## 13      0     42      0      0      0      0      0      0   1124      0      0
##    COUNT_TPA
## 13      1166
tdomdat.pres[tdomdat.pres$CN == cn,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 13 40404742010690  2011      56     3      2        1 83075  -105.4286
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 13   42.22974     2011        6                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 13                NA      1          1         1        24 Sampled-Forest
##           PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT106 CNT108
## 13 ID560200183075      0      0      0      0      0      0      0      0
##    CNT113 CNT122 CNT202 CNT313 CNT375 CNT475 CNT544 CNT745 CNT746 CNT749 CNT823
## 13      0      1      0      0      0      0      0      0      1      0      0
##    COUNT_TPA
## 13         1
tdomdat.prop[tdomdat.prop$CN == cn,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 13 40404742010690  2011      56     3      2        1 83075  -105.4286
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 13   42.22974     2011        6                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 13                NA      1          1         1        24 Sampled-Forest
##           PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT106 CNT108
## 13 ID560200183075      0      0      0      0      0      0      0      0
##    CNT113 CNT122 CNT202 CNT313 CNT375 CNT475 CNT544 CNT745 CNT746 CNT749 CNT823
## 13      0      0      0      0      0      0      0      0      1      0      0
##    COUNT_TPA
## 13         1
tdomdat.cov[tdomdat.cov$CN == cn,]
output
##                CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 13 40404742010690  2011      56     3      2        1 83075  -105.4286
##    LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 13   42.22974     2011        6                     0              1
##    NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT     FORNONSAMP
## 13                NA      1          1         1        24 Sampled-Forest
##           PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT106 CNT108
## 13 ID560200183075      0      0      0      0      0      0      0      0
##    CNT113 CNT122 CNT202 CNT313 CNT375 CNT475 CNT544 CNT745 CNT746 CNT749 CNT823
## 13      0      0      0      0      0      0      0      0     24      0      0
##    COUNT_TPA
## 13        24

Example 8: Presence and Proportion of Live Trees by Species, Including Seedlings (Add Barplot)

View Example
treedomCNTs <- datSumTreeDom(
                tree = WYtree, 
                cond = WYcond, 
                plt = WYplt, 
                seed = WYseed, 
                puniqueid = "CN", 
                bycond = FALSE, 
                tsumvar = "PLT_CN", 
                TPA = TRUE, 
                tdomtot = TRUE, 
                tdomprefix = "CNT", 
                tround = 0, 
                tfilter = "STATUSCD==1", 
                addseed = TRUE, 
                presence = TRUE, 
                proportion = TRUE, 
                tdombarplot = TRUE
                )
plot

plot

names(treedomCNTs)
output
## [1] "tdomdat"      "tdomdat.prop" "tdomdat.pres" "tdomvarlut"   "tdomlst"     
## [6] "tdomtotnm"
tdomdat.pres <- treedomCNTs$tdomdat.pres
tdomdat.prop <- treedomCNTs$tdomdat.prop

head(tdomdat.pres)
output
##               CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6 40404734010690  2013      56     3      2        1 83304  -106.0363
##   LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1   42.41013     2013       NA                     0              2
## 2   42.40928     2011        1                     0              1
## 3   42.40953     2013        6                     0              1
## 4   42.35599     2012       NA                     0              2
## 5   42.31655     2012       NA                     0              2
## 6   42.26546     2013       NA                     0              2
##   NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1                NA      1          1         0         0 Sampled-Nonforest
## 2                NA      1          1         1        17    Sampled-Forest
## 3                NA      1          1         1        41    Sampled-Forest
## 4                NA      1          1         0         0 Sampled-Nonforest
## 5                NA      1          1         0         0 Sampled-Nonforest
## 6                NA      1          1         0         0 Sampled-Nonforest
##          PLOT_ID CNT019 CNT065 CNT066 CNT093 CNT096 CNT101 CNT106 CNT108 CNT113
## 1 ID560200186688      0      0      0      0      0      0      0      0      0
## 2 ID560200184596      0      0      1      0      0      0      0      0      1
## 3 ID560200188993      0      0      0      0      0      0      0      1      1
## 4 ID560200182340      0      0      0      0      0      0      0      0      0
## 5 ID560200182869      0      0      0      0      0      0      0      0      0
## 6 ID560200183304      0      0      0      0      0      0      0      0      0
##   CNT122 CNT202 CNT313 CNT375 CNT475 CNT544 CNT745 CNT746 CNT749 CNT823
## 1      0      0      0      0      0      0      0      0      0      0
## 2      0      0      0      0      0      0      0      0      0      0
## 3      1      1      0      0      0      0      0      0      0      0
## 4      0      0      0      0      0      0      0      0      0      0
## 5      0      0      0      0      0      0      0      0      0      0
## 6      0      0      0      0      0      0      0      0      0      0
##   COUNT_TPA
## 1         0
## 2         1
## 3         1
## 4         0
## 5         0
## 6         0

Example 9: Total Basal Area Per Acre of Limber Pine (SPCD=113) Trees >= 1.0 DIA

View Example
treedomBA <- datSumTreeDom(
                tree = WYtree, 
                cond = WYcond, 
                plt = WYplt, 
                puniqueid = "CN", 
                bycond = FALSE, 
                tsumvar = "BA", 
                TPA = TRUE, 
                tdomprefix = "BA", 
                tdomvarlst = 113, 
                tround = 2, 
                tfilter = "STATUSCD==1"
                )

names(treedomBA)
output
## [1] "tdomdat"    "estunits"   "tdomvarlut" "tdomlst"    "tdomtotnm"
ba.limber <- treedomBA$tdomdat

head(ba.limber)
output
##               CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6 40404734010690  2013      56     3      2        1 83304  -106.0363
##   LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1   42.41013     2013       NA                     0              2
## 2   42.40928     2011        1                     0              1
## 3   42.40953     2013        6                     0              1
## 4   42.35599     2012       NA                     0              2
## 5   42.31655     2012       NA                     0              2
## 6   42.26546     2013       NA                     0              2
##   NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1                NA      1          1         0         0 Sampled-Nonforest
## 2                NA      1          1         1        17    Sampled-Forest
## 3                NA      1          1         1        41    Sampled-Forest
## 4                NA      1          1         0         0 Sampled-Nonforest
## 5                NA      1          1         0         0 Sampled-Nonforest
## 6                NA      1          1         0         0 Sampled-Nonforest
##          PLOT_ID BA113
## 1 ID560200186688  0.00
## 2 ID560200184596  6.03
## 3 ID560200188993 12.56
## 4 ID560200182340  0.00
## 5 ID560200182869  0.00
## 6 ID560200183304  0.00

Example 10: Species and Diameter Class

View Example
## Total basal area per acre by species and diameter class
DIALUT <- FIESTAutils::ref_diacl2in[FIESTAutils::ref_diacl2in$MIN <= 37, ]
names(DIALUT)[names(DIALUT) == "MEANING"] <- "DIACL2IN"

## Append diameter classes to tree table
datlut <- datLUTclass(
                    x = WYtree, 
                    xvar = "DIA", 
                    LUT = DIALUT, 
                    LUTclassnm = "DIACL2IN"
                    )
WYtree2 <- datlut$xLUT

## Species and diameter class
treedomDIACNTs <- datSumTreeDom(
                    tree = WYtree2, 
                    cond = WYcond, 
                    plt = WYplt, 
                    puniqueid = "CN", 
                    bycond = FALSE, 
                    tsumvar = "PLT_CN", 
                    TPA = TRUE, 
                    tdomtot = TRUE, 
                    tdomprefix = "CNT", 
                    tround = 2, 
                    tfilter = "STATUSCD==1 & DIA > 30", 
                    presence = TRUE, 
                    proportion = TRUE, 
                    tdomvar2 = "DIACL2IN", 
                    tdombarplot = TRUE
                    )
plot

plot

names(treedomDIACNTs)
output
## [1] "tdomdat"      "tdomdat.prop" "tdomdat.pres" "tdomvarlut"   "tdomlst"     
## [6] "tdomtotnm"
tdomdat.pres <- treedomDIACNTs$tdomdat.pres
tdomdat.prop <- treedomDIACNTs$tdomdat.prop

head(tdomdat.pres)
output
##               CN INVYR STATECD CYCLE UNITCD COUNTYCD  PLOT LON_PUBLIC
## 1 40404728010690  2013      56     3      2        1 86688  -105.9625
## 2 40404729010690  2011      56     3      2        1 84596  -105.7277
## 3 40404730010690  2013      56     3      2        1 88993  -105.6679
## 4 40404731010690  2012      56     3      2        1 82340  -106.0313
## 5 40404733010690  2012      56     3      2        1 82869  -105.8509
## 6 40404734010690  2013      56     3      2        1 83304  -106.0363
##   LAT_PUBLIC MEASYEAR RDDISTCD NF_SAMPLING_STATUS_CD PLOT_STATUS_CD
## 1   42.41013     2013       NA                     0              2
## 2   42.40928     2011        1                     0              1
## 3   42.40953     2013        6                     0              1
## 4   42.35599     2012       NA                     0              2
## 5   42.31655     2012       NA                     0              2
## 6   42.26546     2013       NA                     0              2
##   NF_PLOT_STATUS_CD NBRCND NBRCNDSAMP NBRCNDFOR CCLIVEPLT        FORNONSAMP
## 1                NA      1          1         0         0 Sampled-Nonforest
## 2                NA      1          1         1        17    Sampled-Forest
## 3                NA      1          1         1        41    Sampled-Forest
## 4                NA      1          1         0         0 Sampled-Nonforest
## 5                NA      1          1         0         0 Sampled-Nonforest
## 6                NA      1          1         0         0 Sampled-Nonforest
##          PLOT_ID CNT019#31.0-32.9 CNT065#29.0-30.9 CNT065#31.0-32.9
## 1 ID560200186688                0                0                0
## 2 ID560200184596                0                0                0
## 3 ID560200188993                0                0                0
## 4 ID560200182340                0                0                0
## 5 ID560200182869                0                0                0
## 6 ID560200183304                0                0                0
##   CNT065#33.0-34.9 CNT065#35.0-36.9 CNT093#29.0-30.9 CNT093#31.0-32.9
## 1                0                0                0                0
## 2                0                0                0                0
## 3                0                0                0                0
## 4                0                0                0                0
## 5                0                0                0                0
## 6                0                0                0                0
##   CNT093#35.0-36.9 CNT096#31.0-32.9 CNT202#33.0-34.9 COUNT_TPA
## 1                0                0                0         0
## 2                0                0                0         0
## 3                0                0                0         0
## 4                0                0                0         0
## 5                0                0                0         0
## 6                0                0                0         0