Cut a vector into n-tiles
SN248 / 2016-02-08
Useful code to cut vector into ntiles in R
To break a numeric vector X into n-tiles (e.g, here into quartiles), use
y <- cut(X, breaks=c(quantile(X, probs = seq(0, 1, by = 0.25))), labels=c("L1","L2","L3","L4"))
Somehow, the syntax highligting is not upto mark … :(
This code fragment looks much better on rouge even though, jekyll 3 is supposed to be using rouge for syntax highlighting, don’t know why this is happening or how to resolve this.
gist, looks much better …
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Useful piece of code to cut a vector into quantiles with custom labels | |
| y <- cut(X, breaks=c(quantile(X, probs = seq(0, 1, by = 0.25))), labels=c("L1","L2","L3","L4")) |