View source: R/cut.data.frame.R
cut.data.frame  R Documentation 
This function changes numerical columns of a data frame x
into factors. For each of these columns, its range is divided into intervals and the values of this column is recoded according to which interval they fall.
For that, cut
is applied to each column of x
.
## S3 method for class 'data.frame'
cut(x, breaks, labels = NULL, include.lowest = FALSE, right = TRUE, dig.lab = 3L,
ordered_result = FALSE, cutcol = NULL, ...)
x 
data frame (can also be a tibble). 
breaks 
list or numeric.

labels 
list of character vectors. If given, its length is equal to the number of columns of x.
See 
include.lowest 
logical, indicating if, for each column 
right 
logical, indicating if the intervals should be closed on the right (and open on the left) or vice versa (see 
dig.lab 
integer or integer vector, which is used when labels are not given. It determines the number of digits used in formatting the break numbers.

ordered_result 
logical: should the results be ordered factors? (see 
cutcol 
numeric vector: indices of the columns to be converted into factors. These columns must all be numeric. Otherwise, there is a warning. 
... 
further arguments passed to or from other methods. 
A data frame with the same column and row names as x
.
If cutcol
is given, each numeric column x[, j]
whose number is contained in cutcol
is replaced by a factor.
The other columns are unmodified.
If any column x[, j]
whose number is in cutcol
is not numeric, it is unmodified.
If cutcol
is omitted, every numerical columns are replaced by factors.
Rachid Boumaza, Pierre Santagostini, Smail Yousfi, Sabine DemotesMainard
data("roses")
x < roses[roses$rose %in% c("A", "B"), c("Sha", "Sym", "Den", "rose")]
cut(x, breaks = 3)
cut(x, breaks = 5)
cut(x, breaks = c(0, 4, 6, 10))
cut(x, breaks = list(c(0, 6, 8, 10), c(0, 5, 7, 10), c(0, 6, 7, 10)))
cut(x, breaks = list(c(0, 6, 8, 10), c(0, 5, 7, 10)), cutcol = 1:2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.