View source: R/StatusCorrection.R
StatusCorrection | R Documentation |
Detect errors, or detect errors and correct, the tree life status evolution over the censuses. Inspired by the code of Nino Page package (ForestData::correct_alive() and .correct_alive_tree())
StatusCorrection(
Data,
InvariantColumns = c("Site", "Genus_TreeDataCor", "Species_TreeDataCor",
"Family_TreeDataCor", "ScientificName_TreeDataCor"),
DeathConfirmation = 2,
UseSize = FALSE,
AddRowsForForgottenCensuses = TRUE,
DetectOnly = FALSE,
RemoveRBeforeAlive = FALSE,
RemoveRAfterDeath = FALSE
)
Data |
Dataset (data.frame or data.table) The LifeStatus column must be coded as: - TRUE = alive, - FALSE = dead, - NA = unseen The Plot column is needed to add rows to the census where the plot was inventoried, where the tree was alive, but not recorded. |
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). It is recommended to use the columns that have already been corrected, such as the columns containing the corrected botanical information. |
DeathConfirmation |
Number of times (censuses) needed for an unseen tree to be considered dead (numeric) (Default = 2 censuses) |
UseSize |
Use the size presence as a witness of the living status of the tree (logical) (Default = FALSE) |
AddRowsForForgottenCensuses |
TRUE: adds rows for forgotten censuses between 2 'Alive', FALSE: does not add any rows (logical) |
DetectOnly |
TRUE: Only detect errors, FALSE: detect and correct errors (logical) |
RemoveRBeforeAlive |
Do you want to delete the rows about the tree before it was seen alive for the 1st time? (logical) |
RemoveRAfterDeath |
After correction do you want to delete the rows concerning the tree after its death? (logical) |
if UseSize : if Diameter != NA -> Alive If (the value in bold is modified by the value given after the arrow): (the ">" gives the chronological order of the sequence)
Dead > Alive -> NA
add rows for the forgotten censuses between 2 'Alive' if chosen
Alive > Dead/NA > Alive -> Alive
Alive > NA > Dead -> NA
Alive > Dead > NA -> Dead
Alive > NA > NA: if DeathConfirmation > unseens -> NA if DeathConfirmation =< unseens -> Dead
Fill the Comment column with error type informations. If DetectOnly = FALSE, add a LifeStatus_TreeDataCor column with the corrected trees life status.
library(data.table)
data(TestData)
selection <- c("101184", "101433","101435","101436")
# Write the sequence
TestData <- TestData[order(Year)] # arrange years in ascending order
TestData[IdTree == "101184", LifeStatus := c(TRUE, TRUE, TRUE, TRUE, FALSE)]
TestData[IdTree == "101433", LifeStatus := c(FALSE, TRUE, TRUE, TRUE, TRUE)]
TestData[IdTree == "101435", LifeStatus := c(TRUE, TRUE, NA, FALSE, TRUE)]
TestData[IdTree == "101436", LifeStatus := c(TRUE, NA, NA, FALSE, NA)]
Rslt <- StatusCorrection(TestData[IdTree %in% selection],
InvariantColumns = c("Site",
"Genus",
"Species",
"Family",
"ScientificName"))
LifeStatusCorrectionPlot(Rslt)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.