Learn R Programming

wakefield (version 0.3.6)

interval: Cut Numeric Into Factor

Description

A wrapper for cut that cuts the vector and then adds the varname produced by the original function.

Usage

interval(
  fun,
  breaks,
  ...,
  labels = NULL,
  include.lowest = FALSE,
  right = TRUE,
  dig.lab = 3,
  ordered_result = FALSE,
  n
)

Arguments

fun

A vector producing function.

breaks

Either a numeric vector of two or more unique cut points or a single number (greater than or equal to 2) giving the number of intervals into which the vector produced from fun is to be cut.

labels

Labels for the levels of the resulting category. By default, labels are constructed using "(a,b]" interval notation. If labels = FALSE, simple integer codes are returned instead of a factor.

include.lowest

logical. If TRUE an 'x[i]' equal to the lowest (or highest, for right = FALSE) 'breaks' value should be included.

right

logical. If TRUE the intervals will be closed on the right (and open on the left).

dig.lab

An integer which is used when labels are not given. It determines the number of digits used in formatting the break numbers.

ordered_result

logical. If TRUE the result be an ordered factor.

n

The number elements to generate. This can be globally set within the environment of r_data_frame or r_list.

Other arguments passed to fun.

Value

Returns a cut factor vector.

See Also

cut

Examples

Run this code
# NOT RUN {
interval(normal, 4, n=100)
attributes(interval(normal, 4, n=100))
interval(age, 3, n = 1000)
# }

Run the code above in your browser using DataLab