This function can be used to divide the data into classes, based on minimum value and class interval of a given variable, and create a column with the center of each class.
class_center(df, y, ci =3, ymin =5)
Arguments
df: A data frame.
y: Quoted name of a variable, or a vector to be classified.
ci: Numeric value for the class interval used to classify the data. Default: 3.
ymin: Numeric value for minimum value value to be considered in the classifications. dbh values smaller than this will be dismissed from the classification. Default: 5.
Returns
if df is supplied, a data frame containing the supplied data with a new column for the center of classes; if df is missing, a vetor with the center of class.
Examples
library(forestmangr)library(dplyr)data("exfm20")head(exfm20)# n# Number of individuals per ha per diameter classclass_center(df = exfm20, y ="dbh", ci =10, ymin =10)exfm20 %>%mutate(CC = class_center(y = dbh, ci =10, ymin =10))