Learn R Programming

secr (version 4.6.9)

binCovariate: Add Binned Covariate

Description

Forms a new covariate, replacing values of an old covariate by the central value of equal-width bins.

Usage

binCovariate(object, covname, width)

Value

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

Arguments

object

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

covname

character name of covariate

width

numeric bin width

Details

The name of the new covariate is paste0(covname, width).

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

Multi-session objects are handled appropriately.

See Also

covariates, skink

Examples

Run this code

# 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)

Run the code above in your browser using DataLab