prepareTreeCompetitionTable: Prepares variables for model input

Description Usage Arguments Value Examples

View source: R/prepareTreeCompetitionTable.R

Description

Prepares tree and competition variables from IFN tree data for model input (used internally in model functions like IFNgrowth).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
prepareTreeCompetitionTable(
  x,
  BAL = TRUE,
  BALext = FALSE,
  sortByDBH = FALSE,
  keep.vars = character(0),
  provinceFromID = FALSE,
  verbose = FALSE
)

prepareSpeciesCompetitionTable(x, provinceFromID = FALSE, verbose = FALSE)

prepareSpatialSpeciesCompetitionTable(
  x,
  nb,
  NspNmatrix,
  sigma = c(0.5, 1, 2, 4),
  provinceFromID = FALSE,
  verbose = FALSE
)

Arguments

x

a data frame with column names.

BAL

A flag to indicate that basal area of larger trees (between inventories) has to be calculated.

BALext

A flag to indicate that basal area of larger extracted trees (between inventories) has to be calculated (requires column 'OIFFIN' in x).

sortByDBH

A flag to sort rows within each plot by increasing diameter at breast height.

keep.vars

A character vector with names of variables in x that should be copied to the output data frame.

provinceFromID

A flag to indicate that province should be extracted from 'ID' assuming they are IFN plot codes.

verbose

A flag to indicate console output during the process.

nb

An object of class listw (see functions IFNknn and nb2listw).

NspNmatrix

A numeric matrix with the density proportion of each species (columns) in each plot (rows).

Value

Function prepareTreeCompetitionTable returns a data frame with as many rows as rows in the input x object and columns:

Additional columns may be returned if required using keep.vars. Function prepareSpeciesCompetitionTable returns a data frame with as many rows as species in plots and columns:

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Load example tree data and coordinates
data(exampleTreeData)
data(examplePlotCoords)

# Prepare input for growth/survival models
prepareTreeCompetitionTable(exampleTreeData)

# Prepare input for ingrowth models
prepareSpeciesCompetitionTable(exampleTreeData)

# Prepare input for ingrowth models including dispersal effects
nb = IFNknn(examplePlotCoords, k = 1)
Nmatrix = tapply(exampleTreeData$N, list(exampleTreeData$ID, exampleTreeData$Species),
                 sum, na.rm=T)
NspNmatrix = sweep(Nmatrix, 1, rowSums(Nmatrix, na.rm=T), "/")
NspNmatrix = rbind(NspNmatrix,c(0.5, NA, NA, NA))
rownames(NspNmatrix)[4] = "80003"
NspNmatrix = cbind(NspNmatrix, c(NA,NA,NA,0.5))
colnames(NspNmatrix)[5] = "25"
prepareSpatialSpeciesCompetitionTable(exampleTreeData, nb, NspNmatrix)

miquelcaceres/IFNdyn documentation built on Feb. 1, 2021, 10:55 a.m.