makeClasses: Convert numeric variables to class intervals (factor)

Description Usage Arguments Value Author(s) See Also Examples

View source: R/functionsFIA.R

Description

Convert continuous numeric variables to class intervals with output as factor or numeric classes. Simplified implementation of cut. Example uses include computing diameter or height classes for summarization with rFIA functions (e.g. tpa, biomass).

Usage

1
2
makeClasses(x, interval = NULL, lower = NULL, upper = NULL,
            brks = NULL, numLabs = FALSE)

Arguments

x

numeric vector to be converted to factor (class intervals).

interval

numeric; interval of desired output classes. e.g. specify x = DIA and interval = 2 for 2-inch diameter class intervals.

lower

lower bound of output classes, included in lowest class. e.g. [lower, ...).

upper

upper bound of output classes, NOT included in highest class. e.g. [..., upper).

brks

numeric vector of desired breakpoints (bounds) of class intervals.

numLabs

logical; if TRUE, return class intervals as numeric vector with values representing the lower bounds of each interval. If FALSE, return factor with labels of form '[b1, b2)'.

Value

Factor or integer vector. Factor values represent class intervals with [b1, b2) notation, values of integer vectors represent the lower bounds of class intervals (e.g. b1).

Author(s)

Hunter Stanke and Andrew Finley

See Also

clipFIA

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## Load data from the rFIA package
data(fiaRI)

## Compute Diameter Classes on 1-inch intervals for each tree in TREE table ----
# Factor w/ interval labels
makeClasses(fiaRI$TREE$DIA, interval = 1)
# Numeric w/ lower bound of each class as returned value
makeClasses(fiaRI$TREE$DIA, interval = 1, numLabs = TRUE)

## Compute Stand Age Classes on 20 year intervals for each
## condition in COND table ----
# NOTE: Unrecorded stand age recorded as -999, replace negative values with NA
fiaRI$COND$STDAGE[fiaRI$COND$STDAGE < 0] <- NA
makeClasses(fiaRI$COND$STDAGE, interval = 25)

## Compute Stand Stocking Classes (10%) for all live (ALSTK),
## and growing stock (GSSTK) in COND table ----
makeClasses(fiaRI$COND$ALSTK, interval = 10) # All Live
makeClasses(fiaRI$COND$GSSTK, interval = 10) # Growing Stock

## Compute % Slope Classes (20%) for each condition in COND table ----
makeClasses(fiaRI$COND$SLOPE, interval = 20)

rFIA documentation built on Dec. 16, 2021, 1:07 a.m.