diameter_class: Divide data into diameter classes, and get number of...

View source: R/diameter_class.R

diameter_classR Documentation

Divide data into diameter classes, and get number of observations

Description

This function can be used to divide data into diameter classes, get the number of observations, number of observations per ha, and check number of species individuals, volume and G in each diameter class. It's also possible to spread the diameter classes as columns.

Usage

diameter_class(
  df,
  dbh,
  plot = NA,
  plot_area,
  ci = 5,
  dbhmin = 5,
  species = NA,
  volume = NA,
  NI_label = "NI",
  cc_to_column = FALSE,
  G_to_cc = FALSE,
  cctc_ha = TRUE,
  keep_unused_classes = FALSE
)

Arguments

df

A data frame.

dbh

Quoted name of the diameter at breast height variable, in cm.

plot

Optional parameter.Quoted name of the plot variable. used to differentiate the plots trees, and calculate the number of sampled plots. Default NA.

plot_area

Optional parameter. Quoted name of the plot area variable, or a numeric vector with the plot area value. The plot area value must be in square meters. Default NA.

ci

Numeric value for the class interval used to classify the data. Default: 5.

dbhmin

Numeric value for minimum diameter value to be considered in the classifications. dbh values smaller than this will be dismissed from the classification. Default: 5.

species

Optional parameter. Quoted name of the scientific names variable, or any variable used to differentiate the different species found in data. If supplied, will be used to classify the species in the diameter data. Default NA.

volume

Optional parameter. Quoted name of the volume variable. If supplied, will be used classify the volume variable in the different diameter classes. Also, if cc_to_column is TRUE, the center of class columns will be filled with volume values, instead of number of individuals. Default NA.

NI_label

Label used for Species not identified. This parameter works along with species. The level supplied here will not be considered in the classification. Default "NI".

cc_to_column

If TRUE, will spread the center class column as multiple columns, one for each class. The value that fills these columns, by default is the number of individuals found in each class, but this can be changed by using other arguments. Default FALSE.

G_to_cc

If TRUE, and cc_to_column is also TRUE, will fill the center of class columns with basal area values, instead of number of individuals. Default FALSE.

cctc_ha

If TRUE, will calculate values per hectare for number of individuals per class, basal area per class and volume per class (if supplied). These values will also be used to fill the center of class columns, if cc_to_column is TRUE. Default TRUE.

keep_unused_classes

Some diameter classes may end up empty, depending on the maximum value of diameter and the class interval used. If this is TRUE, those classes will not be removed from the final data frame. Default FALSE.

Value

A data frame containing the supplied data divided into diameter classes.

Author(s)

Sollano Rabelo Braga sollanorb@gmail.com

Examples

library(forestmangr)
data("exfm20")
head(exfm20)

# n
# Number of individuals per ha per diameter class
diameter_class(df = exfm20, dbh = "dbh", ci = 10, dbhmin = 10, volume = "vol")

# Number of individuals per ha per diameter class per species
diameter_class(exfm20,"dbh", "transect", 10000, 10, 10, "scientific.name") %>% 
head(10)

# Number of individuals per ha per diameter class, with each diameter class as a column
diameter_class(exfm20,"dbh", "transect", 10000, 10, 10, "scientific.name", cc_to_column=TRUE) %>% 
head(10)

# G
# Basal area per ha per diameter class, with each diameter class as a column
diameter_class(exfm20,"dbh", "transect",10000,10,10,"scientific.name",
cc_to_column=TRUE,G_to_cc=FALSE) %>% 
head(10)


# Volume
# Volume per ha per diameter class
diameter_class(exfm20,"dbh", "transect", 10000, 10, 10, "scientific.name",volume = "vol") %>% 
head(10)

# Volume per ha per diameter class, with each diameter class as a column
diameter_class(exfm20,"dbh","transect",10000,10,10,"scientific.name","vol",cc_to_column=TRUE) %>% 
head(10)


forestmangr documentation built on Nov. 24, 2023, 1:07 a.m.