From Martin Maechler <maechler@stat.math.ethz.ch>  Fri Jun  1 13:39:10 2001
From: Martin Maechler <maechler@stat.math.ethz.ch> (Martin Maechler)
Date: Fri, 1 Jun 2001 14:39:10 +0200
Subject: [Rd] v matrix of svd(X) loses dimensions if nrow(X)==1 (PR#963)
In-Reply-To: <200106011147.NAA00152@pubhealth.ku.dk>
References: <200106011147.NAA00152@pubhealth.ku.dk>
Message-ID: <15127.36078.609836.481507@gargle.gargle.HOWL>


    Marcel> Dear R-developers
    Marcel> I'm not very sure whether this is really a bug and not a feature:

    Marcel> is.matrix(svd(matrix(1:12,nrow=1))$v)  
    Marcel> [1] FALSE

    Marcel> In all other cases the $v component is a matrix. Also, the $u
    Marcel> component always seems to be a matrix as indicated in the doc.

It's the famous `programmer bug' of not using  `` , drop = FALSE ''
when matrix subscripting in functions....

in the 2nd-to-last line of svd() :

    if(nv && nv < p) z$v <- z$v[, 1:nv, drop = FALSE]
				      ^^^^^^^^^^^^^^
				       add this.

{merci, Marcel!}


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] v matrix of svd(X) loses dimensions if nrow(X)==1 (PR#963)
Martin Maechler