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

**Martin Maechler
**
Martin Maechler <maechler@stat.math.ethz.ch>

*Fri, 1 Jun 2001 14:39:10 +0200*

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