@@ -20,8 +20,8 @@ Thinning <- S7::new_class(
2020# ' Calculate Forestry Thinning Schemes
2121# '
2222# ' Calculates thinning schemes for forest management by selecting trees to extract
23- # ' based on specified criteria. Supports both low thinning (removing smaller trees)
24- # ' and high thinning (removing larger trees) approaches.
23+ # ' based on specified criteria. Supports both thinning from below (removing smaller trees)
24+ # ' and thinning from above (removing larger trees) approaches.
2525# '
2626# ' @param data A data frame, or silviculture::Inventory object. See details.
2727# ' @param var A variable used for calculating the thinning. Typically used variables
@@ -30,7 +30,7 @@ Thinning <- S7::new_class(
3030# ' @param ntrees Numeric vector with the number of trees per hectare of each diametric
3131# ' class
3232# ' @param thinning Charater string specifying the thinning type. Available options
33- # ' are `low ` and `high `
33+ # ' are `below ` and `above `
3434# ' @param perc Numeric value between 0 and 1 specifying the percentage of `var`
3535# ' to extract
3636# ' @param .groups A character vector with variables to group by (e.g. plot id, tree
@@ -39,11 +39,11 @@ Thinning <- S7::new_class(
3939# ' @details
4040# ' This function implements common silvicultural thinning practices:
4141# '
42- # ' **Low Thinning:** Removes trees with the lowest values of the specified
42+ # ' **Thinning from below :** Removes trees with the lowest values of the specified
4343# ' variable. This approach typically removes suppressed, damaged, or poor-quality
4444# ' trees, mimicking natural mortality processes.
4545# '
46- # ' **High Thinning:** Removes trees with the highest values of the specified
46+ # ' **Thinning from above :** Removes trees with the highest values of the specified
4747# ' variable. This approach harvests the most valuable trees while leaving smaller
4848# ' trees to continue growing.
4949# '
@@ -73,29 +73,29 @@ Thinning <- S7::new_class(
7373# ' .groups = c('plot_id', 'species')
7474# ' )
7575# '
76- # ' ## Basic low thinning removing 30% of trees based on basal area
76+ # ' ## Thinning from below removing 30% of trees based on basal area
7777# ' silv_treatment_thinning(
7878# ' data = inventory,
7979# ' var = g_ha,
8080# ' dclass = dclass,
8181# ' ntrees = ntrees_ha,
82- # ' thinning = "low ",
82+ # ' thinning = "below ",
8383# ' perc = 0.3
8484# ' )
8585# '
86- # ' ## Basic high thinning removing 20% of trees based on basal area
86+ # ' ## Thinning from above removing 20% of trees based on basal area
8787# ' silv_treatment_thinning(
8888# ' data = inventory,
8989# ' var = g_ha,
9090# ' dclass = dclass,
9191# ' ntrees = ntrees_ha,
92- # ' thinning = "high ",
92+ # ' thinning = "above ",
9393# ' perc = 0.2
9494# ' )
95- silv_treatment_thinning <- function (data , var , dclass , ntrees , thinning = " low " , perc = 0.3 , .groups = NULL ) {
95+ silv_treatment_thinning <- function (data , var , dclass , ntrees , thinning = " below " , perc = 0.3 , .groups = NULL ) {
9696
9797 # # check for errors
98- if (! thinning %in% c(" low " , " high " )) cli :: cli_abort(" Thinning must be either `low ` or `high `." )
98+ if (! thinning %in% c(" below " , " above " )) cli :: cli_abort(" Thinning must be either `below ` or `above `." )
9999 if (perc < 0 | perc > 1 ) cli :: cli_abort(" `perc` must be between 0 and 1." )
100100
101101 # # take CD table if data is silviculture::Inventory
@@ -113,9 +113,9 @@ silv_treatment_thinning <- function(data, var, dclass, ntrees, thinning = "low",
113113 var_name <- paste0(rlang :: as_name(rlang :: enquo(var )), " _extract" )
114114
115115 # # sort depending thinning type
116- if (thinning == " low " ) {
116+ if (thinning == " below " ) {
117117 data_tbl <- dplyr :: arrange(data_tbl , !!! rlang :: syms(.groups ), {{ dclass }})
118- } else if (thinning == " high " ) {
118+ } else if (thinning == " above " ) {
119119 data_tbl <- dplyr :: arrange(data_tbl , !!! rlang :: syms(.groups ), dplyr :: desc({{ dclass }}))
120120 }
121121
0 commit comments