I would like to find the rank of a matrix using R. Looking through a list of commands it seems that the command qr should do the job. Checking a simple example gave me the wrong answer. Here is the example:> A <- c(1,2,3,4,5,6) > A <- matrix(A, nrow=2, ncol=3) > A[,1] [,2] [,3] [1,] 1 3 5 [2,] 2 4 6> qr(A)$rank[1] 3 The correct answer is two. I should add that I am using the mac version of R. Any suggestions? --- Bertram -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Tue, 24 Feb 1998, Bertram Zinner wrote:> I would like to find the rank of a matrix using R. Looking through a list > of commands it seems that the command qr should do the job. Checking a > simple example gave me the wrong answer. Here is the example: > > > A <- c(1,2,3,4,5,6) > > A <- matrix(A, nrow=2, ncol=3) > > A > [,1] [,2] [,3] > [1,] 1 3 5 > [2,] 2 4 6 > > qr(A)$rank > [1] 3 > > The correct answer is two.I think this is due to the mac version being so out of date. I don't have access to it, but qr(A)$rank does work on 0.50a2 and 0.61.1 (at least ignoring the question of whether the rank is well-defined numerically). What does the rest of qr(A) look like? This might help in deciding what to do, especially as a large chunk of the Mac expertise on R is temporarily unavailable due to power failures in New Zealnd. -thomas Thomas Lumley ------------------------------------------------------+------ Biostatistics : "Never attribute to malice what : Uni of Washington : can be adequately explained by : Box 357232 : incompetence" - Hanlon's Razor : Seattle WA 98195-7232 : : ------------------------------------------------------------ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Bertram Zinner <zinnebe at mail.auburn.edu> writes:> > qr(A)$rank > [1] 3 > > The correct answer is two. > > I should add that I am using the mac version of R. Any suggestions? ---Well, don't do that then ;^)> A <- c(1,2,3,4,5,6) > A <- matrix(A, nrow=2, ncol=3) > qr(A)$rank[1] 2 Seriously speaking, yes, we really should get around to getting the Mac version up to date. Volunteers? -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
John Bacon-Shone <johnbs@hku.hk> writes:> >Seriously speaking, yes, we really should get around to getting the > >Mac version up to date. Volunteers? > > What needs to be done? Create an up-to-date CodeWarrior project, or do coding? > > John > > Dr John Bacon-Shone, Director, Social Sciences Research Centre, > The University of Hong Kong, Pokfulam Road, Hong Kong > Tel: 852-28592412 Fax: 852-28584327 E-mail: mailto:johnbs@hku.hk > Web http://www.ssrc.hku.hkIf only I knew... I suspect that some actual coding changes are needed for the event loop and the graphics interface, whereas the main body of the parser and the internals, as well as the interpreted code are highly portable. That's the situation with the Windows version anyway, and I can't believe that MacProgramming can be worse that the Win32 API. One thing that I have been looking at a bit is the possibility of coding up a Tcl/Tk version of R. This could be made portable between all three architectures (X/Win32/Mac) and probably evolve into a set of R/Tk language bindings a.m. STk (Scheme Tk), so we could have menu interfaces and R functions that are call via a button-click, etc. [I'm Cc-ing this to the R-devel list. Slightly bad netiquette since your email was to me privately, but I hope you won't mind.] -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._