compileTrees: Compile tree data

View source: R/compileTrees.R

compileTreesR Documentation

Compile tree data

Description

Compute tree level attributes using optional and custom functions, e.g., ba, volume, Lorey's height

Usage

compileTrees(
  tlDF,
  fnCompute = list(tpa, ba_ft, dbcl, dbclY, sppY, dbclSppY),
  ...
)

ba_ft(x, dbNm, ...)

tpa(x, acresNm = NA, nTreesNm = NA, ...)

tph(x, haNm = NA, nTreesNm = NA, ...)

dbcl(x, dbNm = "dbh", dbcl = c(seq(0, 32, 4), 50, 1000), dbclNm = "dbcl", ...)

dbclY(x, trID, dbclNm, dbclY, ...)

sppY(x, trID, sppY, sppNm, ...)

dbclSppY(x, trID, sppY, dbclNm, sppNm, ...)

Arguments

tlDF

data frame of tree records

fnCompute

sequential list of functions to apply to tree data, earlier results (e.g. ba) are available to later functions. Every function should accept an elipsis

...

arguments to functions in fnCompute

Details

Accepts a list of trees and a series of functions (some provided) and additively applies the functions to the tree list. Something like computeVolume(computeBA(computeTPA(treeList))) ... A number of functions are provided - feel free to modify or update them to meet your needs

ba_ft(x, dbNm, ...)

tpa(x, acresNm = NA, nTreesNm = NA, ...)

tph(x, haNm = NA, nTreesNm = NA, ...)

dbcl(x, dbNm = "dbh", dbcl = c(seq(0, 32, 4), 50, 1000), dbclNm = "dbcl", ...)

dbclY(x, trID, dbclNm, dbclY, ...)

sppY(x, trID, sppY, sppNm, ...)

dbclSppY(x, trID, sppY, dbclNm, sppNm, ...)

This program is free software but it is provided WITHOUT WARRANTY and with ABSOLUTELY NO GUARANTEE of fitness or functionality for any purpose; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.


Revision History

1.0 6/10/2020 Created

Value

typically an updated tlDF data.frame (compileTrees function argument) with additional columns. This behavior can be broken using fnCompute functions that behave improperly or have "features" to meet specific user objectives.

Author(s)

Jacob Strunk <Jstrunk@fs.fed.us>

See Also

dcast
melt
compilePlots

Examples



  set.seed=111
  nfake=50
  dbh_fk = 10*abs(rnorm(nfake))
  df_fake = data.frame(
    pltId = sample((1:7),nfake,replace=T)
    ,trid=1:50
    ,db= dbh_fk
    ,ht=75*dbh_fk + rnorm(nfake)*10
    ,spp = sample(c("df","wh","cw","ra") , nfake , T)
    ,acres = 0.1
    ,trees = round(1+ abs(rnorm(nfake)/3))

  )

  testTL =
    compileTrees(
      df_fake

      #arguments to fnCompute functions
      ,trID = "trid"
      ,sppNm = "spp"
      ,dbNm = "db"
      ,htNm = "ht"
      ,dbclNm = "dbcl"
      ,dbcl = c(seq(0,32,4),50,1000)
      ,dbclY = c("ba_ft")
      ,sppY = c("ba_ft")
      ,sppDbclY = c("ba_ft")
      ,acresNm = "acres"
      ,nTreesNm = NA

      #optional functions to run against tree data
      #must accept ...
      ,fnCompute =
        list(
          tpa
          ,ba_ft
          ,dbcl
          ,dbclY
          ,sppY
          ,dbclSppY
        )

    )

  testTL




jstrunk001/RSForInvt documentation built on April 18, 2022, 11:03 p.m.