From bates@stat.wisc.edu  Wed Jun 17 23:24:54 1998
From: bates@stat.wisc.edu (Douglas Bates)
Date: Wed, 17 Jun 1998 17:24:54 -0500 (CDT)
Subject: Scalar operations dropping matrix attributes
Message-ID: <m0ymQdS-0000Y8C@verdi.stat.wisc.edu>

In 0.62.1 I found that code like t(mat/vec)/vec seems to drop the
matrix attributes of the result.  In this case the matrix is 1x1.
Here is something tracked inside a debug-induced browser.

 Browse[1]> data.class(Var)
 [1] "matrix"
 Browse[1]> Var
	     (Intercept)
 (Intercept)      31.662
 Browse[1]> 
 debug: stdDev <- sqrt(diag(Var))
 Browse[1]> 
 debug: names(stdDev) <- dimnames(Var)[[2]]
 Browse[1]> 
 debug: value <- t(Var/stdDev)/stdDev
 Browse[1]> data.class(stdDev)
 [1] "numeric"
 Browse[1]> 
 debug: attr(value, "stdDev") <- stdDev
 Browse[1]> data.class(value)
 [1] "numeric"

(As you might guess this code takes a variance-covariance matrix and
creates a correlation matrix with the standard deviations as an
attribute.)
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


Scalar operations dropping matrix attributes
Douglas Bates