Skip to content

Bug in "[<-.matrix"? (Was: Feature Request: "matrix[1:10,1:10, block=F] <- 1:10")

2 messages · Warnes, Gregory R, Brian Ripley

#
Thanks to David Meyer [david.meyer@ci.tuwien.ac.at] and David Brahm
[brahm@alum.mit.edu] who suggested:

  m[ cbind(index.i, index.j) ] <- vals

This works fine for the example I gave.  

Unfortunately, this approach doesn't extend to using the row and column
names to make assignments:
A  B  C 
a "" "" ""
b "" "" ""
c "" "" ""
b   a   c   B   A   C 
 ""  ""  ""  ""  ""  ""  ""  ""  "" "1" "2" "3" "1" "2" "3" 

This looks like a bug...

-Greg
LEGAL NOTICE
Unless expressly stated otherwise, this message is confidential and may be privileged. It is intended for the addressee(s) only. Access to this E-mail by anyone else is unauthorized. If you are not an addressee, any disclosure or copying of the contents of this E-mail or any action taken (or not taken) in reliance on it is unauthorized and may be unlawful. If you are not an addressee, please inform the sender immediately.
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
On Wed, 20 Feb 2002, Warnes, Gregory R wrote:

            
It's as documented.  Take a look at e.g. the description of indexing
in Venables & Ripley.  You can use match() to turn names into numbers.
It is possible to use a matrix of integers as an index ...

S throws an error in your example, and perhaps R should too.  But not
giving errors when used in undocumented ways is not a bug.