finding index of maximum value in vector

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

finding index of maximum value in vector

Bugzilla from jfontain@free.fr
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I found:
  max.col(matrix(c(1,3,2),nrow=1))
Is there a more concise/elegant way?
Thanks,

- --
Jean-Luc Fontaine  http://jfontain.free.fr/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFDpbfAkG/MMvcT1qQRAjGnAJsH+9MWuiv+K+US0McW2fLzRx2LHwCfYpNG
gWKLuxnnlNde8WEr7wU5NUM=
=7/gr
-----END PGP SIGNATURE-----

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: finding index of maximum value in vector

Kjetil Halvorsen
Jean-Luc Fontaine wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I found:
>   max.col(matrix(c(1,3,2),nrow=1))
> Is there a more concise/elegant way?

which.max

> Thanks,
>
> - --
> Jean-Luc Fontaine  http://jfontain.free.fr/
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
> Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
>
> iD8DBQFDpbfAkG/MMvcT1qQRAjGnAJsH+9MWuiv+K+US0McW2fLzRx2LHwCfYpNG
> gWKLuxnnlNde8WEr7wU5NUM=
> =7/gr
> -----END PGP SIGNATURE-----
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html