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]]
Hi Jim, you could try this: mat <- matrix(sample(1:25), 5, 5) mat row(mat)[mat==max(mat)] col(mat)[mat==max(mat)] I hope it helps. Best, Dimitris ---- Dimitris Rizopoulos Doctoral Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/16/396887 Fax: +32/16/337015 Web: http://www.med.kuleuven.ac.be/biostat/ http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm ----- Original Message ----- From: "Jim Gustafsson" <jgu at Codan.DK> To: <r-help at stat.math.ethz.ch> Sent: Wednesday, August 25, 2004 11:07 AM 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, inthis> case row 2 and column 2. > How could you get the position? > > The values in the matrix is likelihood function values, and eachrow and> column represent values from two parameters. So the idea is to seekwhich> parameter values maximise the likelihood and therefore I need bootrow and> column position. > > Regards Jim > > > ------------------------------------------------------------------------------> This e-mail and any attachment may be confidential and may also beprivileged.> If you are not the intended recipient, please notify us immediatelyand then> delete this e-mail and any attachment without retaining copies ordisclosing> the contents thereof to any other person. > Thank you. > ------------------------------------------------------------------------------> [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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
On Wed, 25 Aug 2004 11:07:24 +0200 Jim Gustafsson <jgu at Codan.DK> wrote:> > 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?> mat <- matrix(c(11,16,2,24,29,15,11,16,2), ncol = 3) > mat[,1] [,2] [,3] [1,] 11 24 11 [2,] 16 29 16 [3,] 2 15 2> which(mat == max(mat), arr.ind = TRUE)row col [1,] 2 2> 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.HTH, Tobias
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:jgu@Codan.DK] Sent: 25 August 2004 10:07 To: r-help@stat.math.ethz.ch 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]] ______________________________________________ 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 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:kssg@kssg.com http://www.kssg.com The information in this Internet email is confidential and m...{{dropped}}
Dear all, Does anyone know how to read files with .dbf extension? Thanks for your time.
Did you do a search at "www.r-project.org" -> "R site search"? Searching for ".dbf" there just now exposed a "read.shape" function in the maptools package. hope this helps. p.s. Did you read the posting guide! "http://www.R-project.org/posting-guide.html"? Tips provided there may help you answer questions like this for yourself. Failing that, they may also help you formulate your questions so you are more likely to get useful replies. Buena suerte. Fuensanta Saura Igual wrote:>Dear all, >Does anyone know how to read files with .dbf extension? > >Thanks for your time. > >______________________________________________ >R-help at 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 > >-- Spencer Graves, PhD, Senior Development Engineer O: (408)938-4420; mobile: (408)655-4567
I believe .dbf files are more commonly DBase files, in which case see package RODBC. On Mon, 13 Sep 2004, Spencer Graves wrote:> Did you do a search at "www.r-project.org" -> "R site search"? > Searching for ".dbf" there just now exposed a "read.shape" function in > the maptools package. > > hope this helps. > p.s. Did you read the posting guide! > "http://www.R-project.org/posting-guide.html"? Tips provided there may > help you answer questions like this for yourself. Failing that, they > may also help you formulate your questions so you are more likely to get > useful replies. Buena suerte. > > Fuensanta Saura Igual wrote: > > >Dear all, > >Does anyone know how to read files with .dbf extension? > > > >Thanks for your time. > > > >______________________________________________ > >R-help at 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 > > > > > >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595