[R] bigest part of vector

2009-02-24 Thread Peterko
Hi, may be simle question, but a do not find it anywhere. Is there same function like max() ,but giving more results. max() give 1number-maximum I need funcion what give p bigest number. many thanks -- View this message in context:

Re: [R] bigest part of vector

2009-02-24 Thread seelenhirt
On Tue, 24 Feb 2009 11:36:06 -0800 (PST) (SO, 55 Chs 3175 YOLD) Peterko lanikpe...@gmail.com wrote: Hi, may be simle question, but a do not find it anywhere. Is there same function like max() ,but giving more results. max() give 1number-maximum I need funcion what give p bigest number.

Re: [R] bigest part of vector

2009-02-24 Thread Jorge Ivan Velez
Dear Peter, Perhaps: set.seed(1) # For reproducibility p-2 # Two biggest values of x x-rnorm(10) tail(sort(x),p) [1] 0.7383247 1.5952808 In a function mode, foo-function(x,p=2) tail(sort(x),p) foo(x,p=3) [1] 0.5757814 0.7383247 1.5952808 HTH, Jorge On Tue, Feb 24, 2009 at 2:36

Re: [R] bigest part of vector

2009-02-24 Thread markleeds
There's probably something built in to R but you can change the values of the percentiles (p) below to get the value that corresponds to it. rounding might be problematic also. temp - c(1,4,8,3,5) p - 0.8 temp[order(temp)][round(length(temp)*p)] On Tue, Feb 24, 2009 at 2:36 PM, Peterko

Re: [R] bigest part of vector

2009-02-24 Thread Bert Gunter
-Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Peterko Sent: Tuesday, February 24, 2009 11:55 AM To: r-help@r-project.org Subject: Re: [R] bigest part of vector Thanks for all Peterko wrote: Hi, may be simle question, but a do

Re: [R] bigest part of vector

2009-02-24 Thread Stavros Macrakis
On Tue, Feb 24, 2009 at 3:01 PM, Bert Gunter gunter.ber...@gene.com wrote: Nothing wrong with prior suggestions, but strictly speaking, (fully) sorting the vector is unnecessary. y[y quantile(y, 1- p/length(y))] will do it without the (complete) sort. (But sorting is so efficient anyway, I

Re: [R] bigest part of vector

2009-02-24 Thread Bert Gunter
into the psychology of surprise that I don't have). -- Bert -Original Message- From: macra...@gmail.com [mailto:macra...@gmail.com] On Behalf Of Stavros Macrakis Sent: Tuesday, February 24, 2009 2:12 PM To: Peterko Cc: Bert Gunter; r-help@r-project.org Subject: Re: [R] bigest part of vector On Tue, Feb 24