[R] how to get the position of an element in a vector ?

2007-07-03 Thread Benoit Chemineau
Hi, dear R developers,

I've got a vector of monthly volatilities and i would like to get the
position of the highest volatility of the vector without computing a loop.
Is there a function that could give me such a result ?

a-c(1,2,4,100,3)

the highest value is the fourth of the vector.
how can i get 4 without a loop going through the vector ?

Thanks !

Benoit.

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to get the position of an element in a vector ?

2007-07-03 Thread ONKELINX, Thierry
?which.max



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium
tel. + 32 54/436 185
[EMAIL PROTECTED]
www.inbo.be 

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney

 

 -Oorspronkelijk bericht-
 Van: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] Namens Benoit Chemineau
 Verzonden: dinsdag 3 juli 2007 16:12
 Aan: r-help@stat.math.ethz.ch
 Onderwerp: [R] how to get the position of an element in a vector ?
 
 Hi, dear R developers,
 
 I've got a vector of monthly volatilities and i would like to 
 get the position of the highest volatility of the vector 
 without computing a loop.
 Is there a function that could give me such a result ?
 
 a-c(1,2,4,100,3)
 
 the highest value is the fourth of the vector.
 how can i get 4 without a loop going through the vector ?
 
 Thanks !
 
 Benoit.
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to get the position of an element in a vector ?

2007-07-03 Thread Henrique Dallazuanna
 which(a==max(a))


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

On 03/07/07, Benoit Chemineau [EMAIL PROTECTED] wrote:

 Hi, dear R developers,

 I've got a vector of monthly volatilities and i would like to get the
 position of the highest volatility of the vector without computing a loop.
 Is there a function that could give me such a result ?

 a-c(1,2,4,100,3)

 the highest value is the fourth of the vector.
 how can i get 4 without a loop going through the vector ?

 Thanks !

 Benoit.

 [[alternative HTML version deleted]]

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.