diff --git a/DESCRIPTION b/DESCRIPTION index da78c56..59408dc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -43,27 +43,27 @@ Depends: R (>= 4.1) Config/testthat/edition: 3 Imports: - magrittr (>= 2.0.1), - dplyr (>= 1.0.7), - tibble (>= 3.1.0), - tidyr (>= 1.1.2), - BIOMASS (>= 2.1.7), - rlang (>= 0.4.10), - raster (>= 3.5.29), - sp (>= 1.4.6), - sf (>= 1.0.5), - nngeo (>= 0.4.5), - fasterize (>= 1.0.3), - terra (>= 1.4-22), - methods (>= 3.6.1), - utils (>= 3.6.1), - matlib (>= 0.9.4), - gdistance(>= 1.3-6), - smoothr (>= 0.2.2), - lwgeom (>= 0.2-8), - units (>= 0.7.2), - stats (>= 3.6.1), - parallel (>= 3.6), + magrittr (>= 2.0.3), + dplyr (>= 1.1.2), + tibble (>= 3.2.1), + tidyr (>= 1.3.0), + BIOMASS (>= 2.1.8), + rlang (>= 1.1.1), + raster (>= 3.6.20), + sp (>= 1.6.0), + sf (>= 1.0.12), + nngeo (>= 0.4.7), + fasterize (>= 1.0.4), + terra (>= 1.7-29), + methods (>= 4.3.0), + utils (>= 4.3.0), + matlib (>= 0.9.6), + gdistance(>= 1.6.4), + smoothr (>= 1.0.1), + lwgeom (>= 0.2-11), + units (>= 0.8-2), + stats (>= 4.3.0), + parallel (>= 4.3.0), doSNOW (>= 1.0.20), foreach (>= 1.5.2), tryCatchLog (>= 1.3.1) diff --git a/R/SpeciesCriteria.R b/R/SpeciesCriteria.R index 2f09d4a..38c6503 100644 --- a/R/SpeciesCriteria.R +++ b/R/SpeciesCriteria.R @@ -8,12 +8,14 @@ #' \describe{ #' \item{CommercialName}{Vernacular/economic name (character)} #' \item{Genus}{Genus associated to the vernacular name (character)} -#' \item{Species}{Species (without genus part) associated to the vernacular name (character)} -#' \item{CommercialLevel}{Economic interest level ("1" principal economic species, -#' "2" species logged in a objective of diversification, "0" species -#' whose genus is covered by a commercial name, but which are not logged) (factor)} +#' \item{Species}{Species (without genus part) associated to the vernacular +#' name (character)} +#' \item{CommercialLevel}{Economic interest level (1: principal economic species, +#' 2 or more: species logged in a objective of diversification, 0: species +#' whose genus is covered by a commercial name, but which are not logged) (numeric)} #' \item{MinFD}{Minimum Felling Diameter, in centimeter (numeric)} -#' \item{UpMinFD}{Enhanced Minimum Felling Diameter (over-rich stand case), in centimeter (numeric)} +#' \item{UpMinFD}{Enhanced Minimum Felling Diameter (over-rich stand case), in +#' centimeter (numeric)} #' \item{MaxFD}{Maximum Felling Diameter, in centimeter (numeric)} #' \item{Aggregative}{Aggregative character of the species (logical)} #' ... diff --git a/R/addtreedim.R b/R/addtreedim.R index 904cb31..0a45c44 100644 --- a/R/addtreedim.R +++ b/R/addtreedim.R @@ -1,6 +1,10 @@ #'Compute tree dimensions (tree, trunk and crown height, crown diameter, #'harvestable volume, wood density, and AGB) #' +#'@description Compute tree dimensions (tree, trunk and crown height, crown +#' diameter, harvestable volume, wood density, and AGB) from its Diameter at +#' Breast Height (DBH) +#' #'@param inventory Input inventory (see the inputs formats and metadata in the #' vignette) (data.frame) #' @@ -26,10 +30,10 @@ #'@details 'addtreedim' compute some tree dimensions with the #' 'advancedloggingparameters' argument: #' - Tree height (in m) ('TreeHeightAllometry') -#' - Tree harvestable volume (m3) ('TreeHarvestableVolumeAllometry') +#' - Tree harvestable volume (m3) ('TreeHarvestableVolumeAllometry')(French Guiana ONF) #' - Trunk height (in m) ('TrunkHeightAllometry') #' - Crown height (in m) -#' - Crown diameter (in m) ('CrownDiameterAllometry') +#' - Crown diameter (in m) ('CrownDiameterAllometry') (Aubry-Kientz et al.2019) #' - Wood density (g/cm3) (by the BIOMASS package) #' - Tree above-ground biomass (AGB) (in ton) (by the BIOMASS package) #' diff --git a/R/commercialcriteriajoin.R b/R/commercialcriteriajoin.R index 388d163..816729f 100644 --- a/R/commercialcriteriajoin.R +++ b/R/commercialcriteriajoin.R @@ -84,8 +84,8 @@ commercialcriteriajoin <- function( mutate(CommercialName = ifelse(is.na(CommercialName.species), CommercialName.genus, CommercialName.species)) %>% dplyr::select(-CommercialName.species, -CommercialName.genus) %>% - mutate(CommercialLevel.species = as.character(CommercialLevel.species)) %>% - mutate(CommercialLevel.genus = as.character(CommercialLevel.genus)) %>% + # mutate(CommercialLevel.species = as.character(CommercialLevel.species)) %>% # remove for reviewer + # mutate(CommercialLevel.genus = as.character(CommercialLevel.genus)) %>% # remove for reviewer mutate(CommercialLevel = ifelse(is.na(CommercialLevel.species), CommercialLevel.genus, CommercialLevel.species)) %>% mutate(MinFD = ifelse(is.na(MinFD.species), MinFD.genus, MinFD.species)) %>% @@ -97,19 +97,19 @@ commercialcriteriajoin <- function( dplyr::select(-CommercialLevel.species, -CommercialLevel.genus, -MinFD.species, -MinFD.genus, -UpMinFD.species, -UpMinFD.genus, -MaxFD.species, -MaxFD.genus, -Aggregative.species, -Aggregative.genus) %>% - mutate(CommercialLevel = as.character(CommercialLevel)) %>% + # mutate(CommercialLevel = as.character(CommercialLevel)) %>% # remove for reviewer # Exceptions management (CommercialLevel == "0" in speciescriteria) - mutate(CommercialName = ifelse(CommercialLevel == "0", NA, CommercialName)) %>% - mutate(MinFD = ifelse(CommercialLevel == "0", NA, MinFD)) %>% - mutate(UpMinFD = ifelse(CommercialLevel == "0", NA, UpMinFD)) %>% - mutate(MaxFD = ifelse(CommercialLevel == "0", NA, MaxFD)) %>% - mutate(Aggregative = ifelse(CommercialLevel == "0", NA, Aggregative)) + mutate(CommercialName = ifelse(CommercialLevel == 0, NA, CommercialName)) %>% # in numeric for reviewer + mutate(MinFD = ifelse(CommercialLevel == 0, NA, MinFD)) %>% + mutate(UpMinFD = ifelse(CommercialLevel == 0, NA, UpMinFD)) %>% + mutate(MaxFD = ifelse(CommercialLevel == 0, NA, MaxFD)) %>% + mutate(Aggregative = ifelse(CommercialLevel == 0, NA, Aggregative)) inventory <- inventory %>% - mutate(CommercialLevel = ifelse(is.na(CommercialLevel), "0", CommercialLevel)) %>% - mutate(CommercialLevel = factor(as.character(CommercialLevel))) + mutate(CommercialLevel = ifelse(is.na(CommercialLevel), 0, CommercialLevel)) # %>% + # mutate(CommercialLevel = factor(as.character(CommercialLevel))) # remove for reviewer if(nrow(inventory) != nrow(inventory0)) stop("The number of rows between the input inventory and the output inventory diff --git a/R/futurereserve.R b/R/futurereserve.R index 89409b5..d7178cf 100644 --- a/R/futurereserve.R +++ b/R/futurereserve.R @@ -111,7 +111,7 @@ futurereserve <- function( #Future: select essence and diameters inventory <- inventory %>% - mutate(LoggingStatus = ifelse(CommercialLevel == "1" & Selected != "1" & HarvestableZone == TRUE & + mutate(LoggingStatus = ifelse(CommercialLevel == 1 & Selected != "1" & HarvestableZone == TRUE & ((Up == "0" & (DBH >= advancedloggingparameters$FutureTreesMinDiameter & DBH < MinFD)) | (Up == "1" & diff --git a/R/harvestable.R b/R/harvestable.R index 261b1af..12e3e4a 100644 --- a/R/harvestable.R +++ b/R/harvestable.R @@ -162,7 +162,7 @@ harvestable <- function( # Calculation of spatial information (distance and slope) SpatInventory <- inventory %>% - dplyr::filter(CommercialLevel!= "0") %>% # only take commercial sp, the calculation time is long enough + dplyr::filter(CommercialLevel!= 0) %>% # only take commercial sp, the calculation time is long enough dplyr::filter(DBH >= MinFD & DBH <= MaxFD) # already selected commercial DBHs coordinates(SpatInventory) <- ~ Xutm + Yutm # transform the inventory into a spatial object by informing the coordinates @@ -263,9 +263,9 @@ harvestable <- function( # Essences selection HarverstableConditions <- # = 1 boolean vector if (diversification || (!diversification && specieslax)) { - inventory$CommercialLevel =="1"| inventory$CommercialLevel == "2" # now or maybe after we will diversify + inventory$CommercialLevel >0 # now or maybe after we will diversify } else if (!diversification && !specieslax) { - inventory$CommercialLevel == "1" # We will never diversify + inventory$CommercialLevel == 1 # We will never diversify } @@ -286,14 +286,14 @@ harvestable <- function( inventory <- inventory %>% mutate(LoggingStatus = ifelse(HarverstableConditions, #Under the above criteria, designate the harvestable species "harvestable", "non-harvestable")) %>% - mutate(LoggingStatus = ifelse(CommercialLevel == "0", #The non-commercial species are non-harvestable. + mutate(LoggingStatus = ifelse(CommercialLevel == 0, #The non-commercial species are non-harvestable. "non-harvestable", LoggingStatus)) %>% mutate(LoggingStatus = ifelse( !diversification & specieslax & #designate the secondarily harvestable species, because diversification only if necessary LoggingStatus == "harvestable" & - CommercialLevel == "2", + CommercialLevel >1, "harvestable2nd", LoggingStatus)) diff --git a/R/loggingparameters.R b/R/loggingparameters.R index 1160f16..527dcb6 100644 --- a/R/loggingparameters.R +++ b/R/loggingparameters.R @@ -70,7 +70,7 @@ #'@param CrownPartForFuel Proportion of the tree crown biomass used as fuel wood. #' Default = 2/3 (double) (Branches diameter >= 5 cm) (Eleotério et al. 2019) #' -#'@param Purge Part of the harvested log no used for timber, can be used for fuel +#'@param Purge Part of the harvested log not used for timber, can be used for fuel #' wood. Default = 0.14, in m3 of purge/m3 of volume of timber harvested. #' (double) #' @@ -94,8 +94,8 @@ #' - "SecondTrails" (default = 0.1) #' #'@param TreeHarvestableVolumeAllometry By default, allometry of tree -#' harvestable volume, French Guiana ONF formula: aCoef + bCoef * (DBH/100)^2, -#' aCoef and bCoef depend on the forest location, stored in +#' harvestable volume, French Guiana ONF formula: aCoef + bCoef * (DBH/100)^2. +#' With aCoef and bCoef depending on the forest location, stored in #' \code{\link{ForestZoneVolumeParametersTable}}, DBH in cm. (function) #' #'@param TrunkHeightAllometry Allometry of trunk height, based on the cylinder diff --git a/R/selected.R b/R/selected.R index 3091b59..b885a5e 100644 --- a/R/selected.R +++ b/R/selected.R @@ -84,8 +84,10 @@ #' @examples #' data(Paracou6_2016) #' data(DTMParacou) +#' data(PlotMask) #' data(HarvestableAreaOutputsCable) #' data(MainTrails) +#' data(ForestZoneVolumeParametersTable) #' #' inventory <- addtreedim(cleaninventory(Paracou6_2016, PlotMask), #' volumeparameters = ForestZoneVolumeParametersTable) @@ -93,7 +95,7 @@ #' inventory <- commercialcriteriajoin(inventory, SpeciesCriteria) #' #' harvestableOutputs <- harvestable(inventory, topography = DTMParacou, -#' diversification = TRUE, specieslax = FALSE, +#' diversification = FALSE, specieslax = TRUE, #' plotslope = HarvestableAreaOutputsCable$PlotSlope, #' maintrails = MainTrails, #' harvestablepolygons = HarvestableAreaOutputsCable$HarvestablePolygons, @@ -105,7 +107,7 @@ #' #' selecInventory <- selected(inventory, topography = DTMParacou, #' scenario = "manual", fuel = "2", diversification = TRUE, -#' VO = 125, HVinit = HVinit, specieslax = FALSE, objectivelax = TRUE, +#' VO = 20, HVinit = HVinit, specieslax = TRUE, objectivelax = TRUE, #' advancedloggingparameters = loggingparameters())$inventory #' selected <- function( @@ -213,6 +215,7 @@ selected <- function( inventory <- inventory %>% mutate(Condition = ifelse(LoggingStatus == "harvestable2nd"|LoggingStatus == "harvestable",TRUE, FALSE)) %>% group_by(Condition) %>% + arrange(CommercialLevel) %>% # add for reviewer arrange(desc(TreeHarvestableVolume)) %>% mutate(VolumeCumSum = cumsum(TreeHarvestableVolume)) %>% ungroup() %>% @@ -250,6 +253,7 @@ selected <- function( inventory <- inventory %>% mutate(Condition = ifelse(LoggingStatus == "harvestable",TRUE, FALSE)) %>% group_by(Condition) %>% + arrange(CommercialLevel) %>% # add for reviewer arrange(desc(TreeHarvestableVolume)) %>% mutate(VolumeCumSum = cumsum(TreeHarvestableVolume)) %>% ungroup() %>% @@ -283,7 +287,7 @@ selected <- function( inventory <- inventory %>% mutate(LoggingStatus = ifelse(LoggingStatus == "harvestable" & - CommercialLevel == "1" & (DBH >= UpMinFD & DBH <= MaxFD), #designate the bigger individuals, when the plot is species-rich. + CommercialLevel == 1 & (DBH >= UpMinFD & DBH <= MaxFD), #designate the bigger individuals, when the plot is species-rich. "harvestableUp", LoggingStatus)) if (!diversification) { @@ -309,6 +313,7 @@ selected <- function( inventory <- inventory %>% mutate(Condition = ifelse(LoggingStatus == "harvestableUp", TRUE, FALSE)) %>% group_by(Condition) %>% + arrange(CommercialLevel) %>% # add for reviewer arrange(desc(TreeHarvestableVolume)) %>% mutate(VolumeCumSum = cumsum(TreeHarvestableVolume)) %>% ungroup() %>% @@ -331,6 +336,7 @@ selected <- function( inventory <- inventory %>% mutate(Condition = ifelse(LoggingStatus == "harvestableUp"|LoggingStatus == "harvestable",TRUE,FALSE)) %>% group_by(Condition) %>% + arrange(CommercialLevel) %>% # add for reviewer arrange(desc(TreeHarvestableVolume)) %>% mutate(VolumeCumSum = cumsum(TreeHarvestableVolume)) %>% ungroup() %>% @@ -353,7 +359,7 @@ selected <- function( # Increase the MinFD of the other economic species inventory <- inventory %>% - mutate(LoggingStatus = ifelse(LoggingStatus == "harvestable" & CommercialLevel == "2" & + mutate(LoggingStatus = ifelse(LoggingStatus == "harvestable" & CommercialLevel >1 & (DBH >= UpMinFD & DBH <= MaxFD), #designate preferred individuals of 2nd economic rank species too, when the plot is species-rich. "harvestableUp", LoggingStatus)) @@ -377,6 +383,7 @@ selected <- function( inventory <- inventory %>% mutate(Condition = ifelse(LoggingStatus == "harvestableUp"|LoggingStatus == "harvestable",TRUE,FALSE)) %>% group_by(Condition) %>% + arrange(CommercialLevel) %>% # add for reviewer arrange(desc(TreeHarvestableVolume)) %>% mutate(VolumeCumSum = cumsum(TreeHarvestableVolume)) %>% ungroup() %>% @@ -413,6 +420,7 @@ selected <- function( inventory <- inventory %>% mutate(Condition = ifelse(LoggingStatus == "harvestable", TRUE, FALSE)) %>% group_by(Condition) %>% + arrange(CommercialLevel) %>% # add for reviewer arrange(desc(TreeHarvestableVolume)) %>% mutate(VolumeCumSum = cumsum(TreeHarvestableVolume)) %>% ungroup() %>% @@ -435,6 +443,7 @@ selected <- function( (TreeHarvestableVolume > min & TreeHarvestableVolume <= MissingVolume), TRUE, FALSE)) %>% group_by(Crumbs) %>% + arrange(CommercialLevel) %>% # add for reviewer arrange(desc(TreeHarvestableVolume)) if(any(inventory$Crumbs)){ diff --git a/man/SpeciesCriteria.Rd b/man/SpeciesCriteria.Rd index 38dc941..e9dca5f 100644 --- a/man/SpeciesCriteria.Rd +++ b/man/SpeciesCriteria.Rd @@ -9,12 +9,14 @@ A tibble with 96 rows and 8 variables: \describe{ \item{CommercialName}{Vernacular/economic name (character)} \item{Genus}{Genus associated to the vernacular name (character)} -\item{Species}{Species (without genus part) associated to the vernacular name (character)} -\item{CommercialLevel}{Economic interest level ("1" principal economic species, -"2" species logged in a objective of diversification, "0" species -whose genus is covered by a commercial name, but which are not logged) (factor)} +\item{Species}{Species (without genus part) associated to the vernacular +name (character)} +\item{CommercialLevel}{Economic interest level (1: principal economic species, +2 or more: species logged in a objective of diversification, 0: species +whose genus is covered by a commercial name, but which are not logged) (numeric)} \item{MinFD}{Minimum Felling Diameter, in centimeter (numeric)} -\item{UpMinFD}{Enhanced Minimum Felling Diameter (over-rich stand case), in centimeter (numeric)} +\item{UpMinFD}{Enhanced Minimum Felling Diameter (over-rich stand case), in +centimeter (numeric)} \item{MaxFD}{Maximum Felling Diameter, in centimeter (numeric)} \item{Aggregative}{Aggregative character of the species (logical)} ... diff --git a/man/selected.Rd b/man/selected.Rd index 81d328d..e86f658 100644 --- a/man/selected.Rd +++ b/man/selected.Rd @@ -95,8 +95,10 @@ an unreached objective volume, or be abandoned ('objectivelax') \examples{ data(Paracou6_2016) data(DTMParacou) +data(PlotMask) data(HarvestableAreaOutputsCable) data(MainTrails) +data(ForestZoneVolumeParametersTable) inventory <- addtreedim(cleaninventory(Paracou6_2016, PlotMask), volumeparameters = ForestZoneVolumeParametersTable) @@ -104,7 +106,7 @@ volumeparameters = ForestZoneVolumeParametersTable) inventory <- commercialcriteriajoin(inventory, SpeciesCriteria) harvestableOutputs <- harvestable(inventory, topography = DTMParacou, -diversification = TRUE, specieslax = FALSE, +diversification = FALSE, specieslax = TRUE, plotslope = HarvestableAreaOutputsCable$PlotSlope, maintrails = MainTrails, harvestablepolygons = HarvestableAreaOutputsCable$HarvestablePolygons, @@ -116,7 +118,7 @@ HVinit <- harvestableOutputs$HVinit selecInventory <- selected(inventory, topography = DTMParacou, scenario = "manual", fuel = "2", diversification = TRUE, -VO = 125, HVinit = HVinit, specieslax = FALSE, objectivelax = TRUE, +VO = 20, HVinit = HVinit, specieslax = TRUE, objectivelax = TRUE, advancedloggingparameters = loggingparameters())$inventory } diff --git a/tests/testthat/test-commercialcriteriajoin.R b/tests/testthat/test-commercialcriteriajoin.R index 150f94e..cc96d72 100644 --- a/tests/testthat/test-commercialcriteriajoin.R +++ b/tests/testthat/test-commercialcriteriajoin.R @@ -40,11 +40,11 @@ test_that("commercialcriteriajoin", { function(element) expect_type(element, "double")) expect_type(testinventory$CommercialName, "character") - expect_s3_class(testinventory$CommercialLevel, "factor") + expect_type(testinventory$CommercialLevel, "double") # Check that commercial sp have logging info, and non-commercial have not: TestCommercial <- testinventory %>% - filter(CommercialLevel == "0") + filter(CommercialLevel == 0) TestList <- list( # list the variables to check TestCommercial$CommercialName, @@ -56,7 +56,7 @@ test_that("commercialcriteriajoin", { function(element) expect_true(all(is.na(element)))) TestCommercial <- testinventory %>% - filter(CommercialLevel != "0") + filter(CommercialLevel != 0) TestList <- list( # list the variables to check TestCommercial$CommercialName, @@ -91,8 +91,8 @@ test_that("commercialcriteriajoin", { # check colonnes présentes et classe: -# CommercialName(character), CommercialLevel(factor), MinFD(numeric), UpMinFD(numeric), MaxFD(numeric) -# Quand CommercialLevel diff de "0" : CommercialName, MinFD, UpMinFD, MaxFD dif de NA +# CommercialName(character), CommercialLevel(numeric), MinFD(numeric), UpMinFD(numeric), MaxFD(numeric) +# Quand CommercialLevel diff de 0 : CommercialName, MinFD, UpMinFD, MaxFD dif de NA # Check species attribution exceptions -# Quand CommercialLevel == "0" : CommercialName, MinFD, UpMinFD, MaxFD == NA +# Quand CommercialLevel == 0 : CommercialName, MinFD, UpMinFD, MaxFD == NA diff --git a/tests/testthat/test-futurereserve.R b/tests/testthat/test-futurereserve.R index 2696477..d444e35 100644 --- a/tests/testthat/test-futurereserve.R +++ b/tests/testthat/test-futurereserve.R @@ -29,12 +29,12 @@ test_that("futurereserve", { advancedloggingparameters = loggingparameters() - # Future = CommercialLevel == "1" + # Future = CommercialLevel == 1 FutureTrees <- testinventory %>% filter(LoggingStatus == "future") - expect_true(all(FutureTrees$CommercialLevel == "1" + expect_true(all(FutureTrees$CommercialLevel == 1 & ( (FutureTrees$Up == "0" & (FutureTrees$DBH >= advancedloggingparameters$FutureTreesMinDiameter & FutureTrees$DBH < FutureTrees$MinFD)) @@ -45,7 +45,7 @@ test_that("futurereserve", { ReserveTrees <- testinventory %>% filter(LoggingStatus =="reserve") - expect_true(all(ReserveTrees$CommercialLevel == "1" + expect_true(all(ReserveTrees$CommercialLevel == 1 & ( (ReserveTrees$Up == "0" & (ReserveTrees$DBH >= advancedloggingparameters$FutureTreesMinDiameter & ReserveTrees$DBH < ReserveTrees$MinFD)) diff --git a/tests/testthat/test-harvestable.R b/tests/testthat/test-harvestable.R index 327f826..b6d1ebe 100644 --- a/tests/testthat/test-harvestable.R +++ b/tests/testthat/test-harvestable.R @@ -55,32 +55,32 @@ test_that("harvestable", { expect_false(any(is.na(testinventory1$LoggingStatus))) expect_false(any(is.na(testinventory2$LoggingStatus))) - # CommercialLevel == "0" are LoggingStatus =="non-harvestable" + # CommercialLevel == 0 are LoggingStatus =="non-harvestable" TestCommercial <- testinventory1 %>% - dplyr::filter(CommercialLevel == "0") + dplyr::filter(CommercialLevel == 0) expect_true(all(TestCommercial$LoggingStatus =="non-harvestable")) TestCommercial <- testinventory2 %>% - dplyr::filter(CommercialLevel == "0") + dplyr::filter(CommercialLevel == 0) expect_true(all(TestCommercial$LoggingStatus =="non-harvestable")) # "harvestable": DBH >= MinFD & DBH <= MaxFD - # "harvestable": CommercialLevel == "1" ou "2" if diversification=T, or diversification=F & specieslax=T + # "harvestable": CommercialLevel == 1 ou 2 if diversification=T, or diversification=F & specieslax=T testinventory1a <- testinventory1 %>% - dplyr::filter(CommercialLevel == "2") + dplyr::filter(CommercialLevel == 2) testinventory2a <- testinventory2 %>% - dplyr::filter(CommercialLevel == "2") + dplyr::filter(CommercialLevel == 2) expect_true(any(testinventory1a$LoggingStatus =="harvestable")) expect_true(any(testinventory2a$LoggingStatus =="harvestable2nd")) - # "harvestable": CommercialLevel == "1" diversification=F & specieslax=F + # "harvestable": CommercialLevel == 1 diversification=F & specieslax=F testinventory3a <- testinventory3 %>% - dplyr::filter(CommercialLevel != "1") + dplyr::filter(CommercialLevel != 1) expect_true(all(testinventory3a$LoggingStatus == "non-harvestable")) diff --git a/tests/testthat/test-selected.R b/tests/testthat/test-selected.R index da50df2..7031282 100644 --- a/tests/testthat/test-selected.R +++ b/tests/testthat/test-selected.R @@ -182,7 +182,7 @@ test_that("selected", { VO = VO, HVinit = HVinit))$inventory TestUp <- testinventory %>% - dplyr::filter(CommercialLevel == "1") %>% + dplyr::filter(CommercialLevel == 1) %>% dplyr::filter(DBH >= UpMinFD & DBH <= MaxFD) %>% dplyr::filter(LoggingStatus != "non-harvestable") %>% dplyr::filter(ProbedHollow == "0") @@ -192,13 +192,13 @@ test_that("selected", { dplyr::filter(LoggingStatus == "harvestableUp") if(nrow(TestUp)>0){ - expect_true(all(TestUp$LoggingStatus == "harvestableUp")) # There are harvestableUp among the CommercialLevel = "1" + expect_true(all(TestUp$LoggingStatus == "harvestableUp")) # There are harvestableUp among the CommercialLevel = 1 expect_true(all(TestDBHUp$DBH >= TestDBHUp$UpMinFD)) # DBH >= UpMinFD expect_true(all(TestDBHUp$Up =="1")) # Up = "1" } ## if (!diversification) - expect_false(any(TestDBHUp$CommercialLevel == "2")) # no CommercialLevel = "2" among the harvestableUp + expect_false(any(TestDBHUp$CommercialLevel == 2)) # no CommercialLevel = 2 among the harvestableUp ### if (HVupCommercial1 == VO) ### if (HVupCommercial1 > VO) ### if (HVupCommercial1 < VO) diff --git a/vignettes/LoggingLab.Rmd b/vignettes/LoggingLab.Rmd index b6811f3..0995e47 100644 --- a/vignettes/LoggingLab.Rmd +++ b/vignettes/LoggingLab.Rmd @@ -171,16 +171,14 @@ To generate creek distances: \code{\link{CreekDistances}} in 'Articles'. + **speciescriteria** : Table of species exploitability criteria : species names, economic interest level, minimum and maximum felling diameter, in -the same format of \code{\link{SpeciesCriteria}} (2 levels of commercial -species) (data.frame) +the same format of \code{\link{SpeciesCriteria}} (data.frame) + **volumeparameters** : Volume parameters table (in the same format of \code{\link{ForestZoneVolumeParametersTable}}) to compute the harvestable volume of each tree, depend to its geographic zone if several locations (data.frame)("Guide de Sylviculture", ONF ('Office National des Forêts') of French Guiana, 2014) -+ **scenario** : Logging scenario: "**RIL1**", "**RIL2broken**", "**RIL2**", "**RIL3**", -"**RIL3fuel**", "**RIL3fuelhollow**" or "**manual**"(character) (See *ScenariosTable*) ++ **scenario** : Logging scenario: "**RIL1**", "**RIL2broken**", "**RIL2**", "**RIL3**", "**RIL3fuel**", "**RIL3fuelhollow**" or "**manual**"(character) (See *ScenariosTable*) + **objective** : Objective volume (m3/ha) (numeric) @@ -190,7 +188,7 @@ exploitation of **hollow trees, damages and unused part of logged trees** in fuel = "**2**" + **diversification** : Possibility to log other species in addition to the -main commercial species (species with a value of 2 for commercial in the +main commercial species (species with a value > 1 for commercial in the \code{\link{SpeciesCriteria}} table) (logical) + **winching** : Tree recovery: