binCovariate: Add Binned Covariate

binCovariateR Documentation

Add Binned Covariate

Description

Forms a new covariate, replacing values of an old numeric covariate either by the central value of equal-width bins (a new numeric covariate) or factor levels from cut.

Usage


binCovariate(object, covname, width, breaks = NULL, replace = FALSE, ...)

Arguments

object

secr object with covariates attribute (capthist, traps, mask)

covname

character name of covariate

width

numeric bin width

breaks

numeric (see cut)

replace

logical; if TRUE any existing covariate of the new name is replaced

...

arguments passed to cut when breaks is provided

Details

Argument ‘width’ is ignored if ‘breaks’ is specified.

By default (breaks not specified) the name of the new covariate is paste0(covname, width). Otherwise, the new covariate name is paste0(covname, 'cut').

Fails if covariate not found or is not numeric or there is already a covariate with the new name and replace = FALSE.

Multi-session objects are handled appropriately.

Value

Object of the same class as the input with new covariate.

See Also

covariates, skink

Examples


# bin values of skink snout-vent length (mm)
infraCH <- binCovariate (infraCH, 'SVL', 5)
table(covariates(infraCH[[1]])$SVL5)

# bin values of trap covariate 'HtBrack' (height of bracken, cm)
traps(infraCH) <- binCovariate(traps(infraCH), "HtBrack", 20)
table(covariates(traps(infraCH)[[1]])$HtBrack20)


secr documentation built on Oct. 11, 2026, 5:06 p.m.