assigncl: Function to assign validation classes

View source: R/assigncl.r

assignclR Documentation

Function to assign validation classes

Description

Assigns class of each observation in a dataframe

Usage

assigncl(
  data = data,
  variable = variable,
  num.class = 4,
  breaks = NULL,
  mincl = NULL,
  wclass = NULL
)

Arguments

data

a dataframe having the validation-variable for each observation.

variable

a character giving the column name of the variable to be used for definning the limits of each validation class.

num.class

the number of classes to be build. The default is set to 4. Regardless, the percentiles are used for defining the limits of each class.

breaks

is a vector having the numbers to be used as breakpoints, by default is set to NULL, therefore the breakpoints will be determined by the num.class.

mincl

the number of the minimum class to be used. By default is set to NULL, otherwise, this option is used to define the breaks.

wclass

the number to be used for defining the width or amplitud of the classes. By default is set to NULL, otherwise, this option and mincl are used to define the breaks.

Details

The function assign a class or category to be used for validation purposes based upon a variable defined by the user.

Value

The main output is the data including a new column having a composited name merging the character provided in variable and ".class". See the examples.

Author(s)

Christian Salas-Eljatib and Marcos Marivil.

References

  • Salas C. 2002. Ajuste y validación de ecuaciones de volumen para un relicto del bosque de roble-laurel-lingue. Bosque 23(2):81–92. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.4067/S0717-92002002000200009")}.

Examples


# The data  
library(datana)
maple
# Example 1
graphics::boxplot(maple$dbh)
df<-assigncl(data=maple,variable="dbh")
head(df)
table(df$dbh.class)
# Example 2, changing the number of classes
df<-assigncl(data=maple,variable="dbh",num.class=5)
table(df$dbh.class)
tapply(df$dbh,df$dbh.class,range)
# Example 3, fixing the breakpoints
df<-assigncl(data=maple,variable="dbh",
             breaks = c(25.60,36.44,40.12,42.3))
table(df$dbh.class)
tapply(df$dbh,df$dbh.class,range)
# Example 4, giving the minimum and amplitude
# of the classes
df<-assigncl(data=llancahue,variable="dbh",mincl=5,
             wclass = 5)
table(df$dbh.class)
tapply(df$dbh,df$dbh.class,range)

datana documentation built on Aug. 18, 2025, 5:18 p.m.