RecruitmentCorrection: RecruitmentCorrection

View source: R/RecruitmentCorrection.R

RecruitmentCorrectionR Documentation

RecruitmentCorrection

Description

RecruitmentCorrection

Usage

RecruitmentCorrection(
  Data,
  KeepMeas = c("MaxHOM", "MaxDate"),
  MinDBH = 10,
  PositiveGrowthThreshold = 5,
  InvariantColumns = c("Site", "Genus_TreeDataCor", "Species_TreeDataCor",
    "Family_TreeDataCor", "ScientificName_TreeDataCor"),
  DetectOnly = FALSE
)

Arguments

Data

(data.frame or data.table) The dataset should preferably contain the column of corrected diameters: 'DBH_TreeDataCor', otherwise the function will take the column 'Diameter'

KeepMeas

In case of multiple diameter measurements in the same census year, on which to apply the correction: Possible values: "MaxHOM", "MaxDate" (character).

  • "MaxHOM": apply the correction to the measurement taken at the highest POM

  • "MaxDate": apply the correction to the most recent measurement (same year but more recent date)

MinDBH

Minimum diameter of trees inventoried according to your protocol (in cm) (numeric, 1 value) (Default = 10 cm)

PositiveGrowthThreshold

A tree widening by more than x cm/year is considered abnormal (numeric, 1 value) (Default = 5 cm)

InvariantColumns

Vector with the names of the columns that are supposed to have always the same value for each measurement of the same tree (character)

DetectOnly

TRUE: Only detect errors, FALSE: detect and correct errors (logical)

Details

If the size of the tree has never changed, or if there is only one value, no recruits are added. If the Diameter has not been corrected ('Diameter_TreeDataCor' column does not exist), the function will create it for the forgotten recruits. It is strongly recommended to correct the Diameter before correcting the recruits

Value

Add rows for forgotten recruits with them estimated DBH in the 'Diameter_TreeDataCor' column, create a 'CorrectedRecruit' col (logical) and fill the 'Comment' column : "This DBH is/was the 1st recorded for this tree, according to its annual growth and the census done for this plot, it should have been recruited earlier according to your protocol (MinDBH)."

Examples

library(data.table)
data(TestData)
setnames(TestData, "Diameter", "Diameter_TreeDataCor")

Rslt <- RecruitmentCorrection(TestData,
                              InvariantColumns = c("Site",
                                                   "Genus",
                                                   "Species",
                                                   "Family",
                                                   "ScientificName"))
IdCorr <- Rslt[CorrectedRecruit == TRUE, IdTree]
TreesCorr <- Rslt[IdTree %in% IdCorr]

library(ggplot2)
ggplot(TreesCorr) +
aes(x = Year, y = Diameter_TreeDataCor) +
  geom_line(size = 0.5, colour = "#112446") +
  geom_point(shape = "circle", size = 1.5, mapping = aes(color = CorrectedRecruit)) +
  theme_minimal() +
  facet_wrap(vars(IdTree), scales = "free")


VincyaneBadouard/TreeData documentation built on Jan. 4, 2024, 2:56 a.m.