GetTopNValues <- function(x, N=100){
# Return top N values from vector x
#
# ARGS:
# x: vector
# N: top N values to return
#
# RETURNS:
# x.top: list with components
# vals: top N values
# i: indices of the top N values
# init list
x.top <- list(vals=NULL, i=NULL)
x.top$vals <- head(sort(x, decreasing=TRUE), N)
x.top$i <- which(x %in% x.top$vals) # not ordered!
return(x.top)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.