Description Usage Arguments Value Examples
Create Bins from a vector of numbers.
1 | create_bins(x, nbins, bins = NULL)
|
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. |
vector of bins as string associated to x numbers.
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")))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.