Or you could use:
mat <- matrix(sample(1:25), 5, 5) mat which(mat==max(mat),arr.ind = T) Wayne -----Original Message----- From: Jim Gustafsson [mailto:[EMAIL PROTECTED] Sent: 25 August 2004 10:07 To: [EMAIL PROTECTED] Subject: [R] R-help Dear R users, I have just start working with R and would need some help. If you have a matrix as: [,1] [,2] [,3] [1,] 11 24 11 [2,] 16 29 16 [3,] 2 15 2 and you want the position where you can find the maximum value, in this case row 2 and column 2. How could you get the position? The values in the matrix is likelihood function values, and each row and column represent values from two parameters. So the idea is to seek which parameter values maximise the likelihood and therefore I need boot row and column position. Regards Jim ---------------------------------------------------------------------------- -- This e-mail and any attachment may be confidential and may also be privileged. If you are not the intended recipient, please notify us immediately and then delete this e-mail and any attachment without retaining copies or disclosing the contents thereof to any other person. Thank you. ---------------------------------------------------------------------------- -- [[alternative HTML version deleted]] ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html KSS Ltd Seventh Floor St James's Buildings 79 Oxford Street Manchester M1 6SS England Company Registration Number 2800886 Tel: +44 (0) 161 228 0040 Fax: +44 (0) 161 236 6305 mailto:[EMAIL PROTECTED] http://www.kssg.com The information in this Internet email is confidential and m...{{dropped}} ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html