SHARE
TWEET

Untitled

a guest Oct 21st, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. maxN <- function(x, N=2, decreasing = FALSE){
  2.   len <- length(x)
  3.   if(N>len){
  4.     warning('N greater than length(x).  Setting N=length(x)')
  5.     N <- length(x)
  6.   }
  7.   if (decreasing == FALSE) {
  8.     sort(x,partial=len-N+1)[len-N+1]
  9.   } else {
  10.     -sort(-x,partial=len-N+1)[len-N+1]
  11.   }
  12. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top