[Rd] "a.matrix[a.char.matrix]<- " crashes R (PR#447)

Prof Brian Ripley Prof Brian Ripley <ripley@stats.ox.ac.uk>
Fri, 18 Feb 2000 17:08:48 +0000 (GMT)


> From: p.dalgaard@biostat.ku.dk
> Date: Fri, 18 Feb 2000 17:05:50 +0100 (MET)
> 
> Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> writes:
> 
> > Still crashes for me!
> 
> [Directed back to R-bugs, and please keep it there!]
> 
> OK, there are two issues here:
> 
> (a) matrix subscripting doesn't work with character type. Plain and
> simple. A matrix subscript just get flattened into a character vector
> and then used for subscripting. We might want to give an error instead
> or simply implement the expected behaviour, but not this close to a
> major release, I think. (Splus cant do this either)

I think that is the correct behaviour. (What is the expected
behaviour?  It is what I expected.) A k-index (aka matrix or array
subset) is supposed to give the indices of the elements to be
extracted/replaced. I suppose character values could be matched to
dimnames, but that would be a new idea.  We might want to *warn*.

On the other hand, S-PLUS's print routine seems to ignore the added
elements, and R loses the dim attribute.

> (b) There's a bug in string indexing:
> 
>   x<-1:2
>   x[c("2","2")]<-2
>   x
> 
> Program received signal SIGSEGV, Segmentation fault. <etc>
> 
> It seems to happen only when there are repeated indices. The bug is

repeated *new *indices.

The hackery in StringSubscript was copying the wrong string as a name
for duplicate string indices. Fixed.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

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