Learn R Programming

DAMisc (version 1.7.2)

binVar: Bin a Variable

Description

Bins a continuous variable into a categorical variable

Usage

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