binVar: Bin a Variable

Description Usage Arguments Value Author(s)

Description

Bins a continuous variable into a categorical variable

Usage

1
2
3
4
5
6
7
8
9
binVar(
  x,
  bins = 4,
  method = c("intervals", "proportions"),
  labels = FALSE,
  include.lowest = TRUE,
  right = FALSE,
  ...
)

Arguments

x

Continuous variable to be binnged

bins

Number of groups in new variable

method

Method for generating "intervals" for fixed-width intervals and "proportions" for cut-points based on quantiles of the distribution.

labels

An optional vector of labels to apply to the groups

include.lowest

Logical indicating whether a value equal to the lowest (if right=TRUE) or highest (if right=FALSE) should be included.

right

Logical indicating Whether the intervals should be closed on the right and open on the left (if TRUE) or vice versa (if FALSE). Open intervals are those that do not include the end-point of the range and closed intervals do.

...

Other arguments to be passed down to cut

Function adapted from binVariable from the RcmdrMisc pacakge.

Value

A factor

Author(s)

John Fox


DAMisc documentation built on Jan. 12, 2022, 1:07 a.m.