Learn R Programming

rockchalk (version 1.8.86)

getFocal.factor: Select focal values from factor variables.

Description

This is used by predictOMatic and plotSlopes to choose values of a categorical moderator variable.

Usage

## S3 method for class 'factor':
getFocal(x, xvals = NULL, n = 3, ...)

Arguments

x
Required. A factor variable
n
Number of values to be selected.
xvals
Optional. With factor variables, this argument is generally not used because the only implemented divider algorithm is "table" (see cutByTable), which selects the n most frequently observed values. That is the default algorithm.
...
Additional arguments passed to user-specified function in xvals.

Value

  • A named vector of level names (labels).

Examples

Run this code
x <- factor(c("A","B","A","B","C","D","D","D"))
getFocal(x)
getFocal(x, n = 2)

Run the code above in your browser using DataLab