Skip to content

Instantly share code, notes, and snippets.

@RyanHope
Created October 23, 2014 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RyanHope/e131f54e08f9e1078e48 to your computer and use it in GitHub Desktop.
Save RyanHope/e131f54e08f9e1078e48 to your computer and use it in GitHub Desktop.
vincent <- function(vec, N) {
qs <- quantile(vec, seq(0, 1, length.out=N))
v <- tapply(vec, findInterval(vec, qs), mean)
names(v) <- sapply(names(qs),function(x) as.numeric(sub("%","",x)))
v
}
# v <- vincent(rgamma(10000,1,1), 20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment