prep.common.vars.fun: Function to Calculate Common Variables

View source: R/PrepCommonVars.R

prep.common.vars.funR Documentation

Function to Calculate Common Variables

Description

A function to calculate common variables needed to estimate growth, death, etc.

Usage

prep.common.vars.fun(tr, fl, i.period, this.period, common.vars, vars.required,
period.length, n.periods, ...)

Arguments

tr

A trList class object.

fl

A list describing the plot data.

i.period

The number of period (from 0 to nperiods) for which to calculate the comon variables.

this.period

The period for which to calculate the common variables.

common.vars

A list with existing common variables.

vars.required

Variables to be calculated.

period.length

Length of the periods, in years.

n.periods

Number of periods.

...

Details

This is an example of a prep.common.vars file. A prep.common.vars (prepare common variables) is needed for the simulation. It is in this file that additional variables needed for the particular functions used in the simulation are calculated. For example, to calculate quadratic mean diameter, basal area, or volume.

Value

A list

res

A list with the common variables.

fl

Updated fl

Author(s)

Clara Anton Fernandez caf@nibio.no

Examples

foo.matrix <-  matrix(0, nrow = length(tr$dbh), ncol = (5 +1))
colnames(foo.matrix) <- paste("t", 0:5, sep = "")
foo.dbh <- foo.height <- foo.matrix
foo.dbh[,1] <- tr$dbh
foo.height[,1] <- tr$height

trl <- list(
  plot.id  = tr$plot.id,
  treeid    = tr$treeid,
  dbh.mm    = foo.dbh,
  height.dm = foo.height,
  yrs.sim   = rep(0, nrow(tr)),
  tree.sp   = factor(tr$tree.sp)
)
tr.i <- trList$new(data = trl, nperiods = as.integer(5))

common.vars <-  prep.common.vars.fun(
  tr = tr.i,
  fl = fl,
  i.period       = 0,
  this.period    = "t0",
  common.vars    = "NULL",
  vars.required  = c("vol.wo.tr.m3.ha", "vuprha.m3.h"),
  period.length = 5
)
str(common.vars)

sitree documentation built on April 28, 2022, 5:06 p.m.