create_bins: Create Bins from a vector of numbers.

Description Usage Arguments Value Examples

Description

Create Bins from a vector of numbers.

Usage

1
create_bins(x, nbins, bins = NULL)

Arguments

x

Vector of number.

nbins

Number of bins to be generated. If 'bins' parameter is provided value, nbins is not used.

bins

List containing the breaks intervals and the bins' labels. If 'bins' parameter is not provided value, nbins is used and bins are automatically generated. Bins contain two vectors: breaks and labels.

Value

vector of bins as string associated to x numbers.

Examples

1
2
3
4
5
6
7
#auto generate the bins
data<-data.frame(x =floor(exp(rnorm(200000 * 1.3))))
data$bin <- create_bins(data$x, nbins=6)

#pre-define the bins
data<-data.frame(x =floor(exp(rnorm(200000 * 1.3))))
data$bin <- create_bins(data$x, nbins=NULL, bins=list(breaks=c(-1,0,1,35,61,92,130), labels=c("0","1","2 to 35","36 to 61","62 to 92","93 to 130")))

mohtad/mapR documentation built on May 23, 2019, 6:01 a.m.