Skip to content
Prev 293220 / 398502 Next

Data frame vs matrix quirk: Hinky error message?

Duncan:

Maybe there **is** a bug, then.

 > zmat <- matrix(1:12,nr=4)
[1]  2  3  4  6  7  8 10 11 12
[1]  2  3  4  6  7  8 10 11 12
[,1] [,2] [,3]
[1,]    1    5    9
[2,]   NA   NA   NA
[3,]   NA   NA   NA
[4,]   NA   NA   NA

## ??
Error in `[<-.data.frame`(`*tmp*`, ix, value = NA) :
  only logical matrix subscripts are allowed in replacement

That matrix replacement should not work with (in general mixed type)
data frames seems reasonable, actually. Trying to "fix things" may not
be. But I leave this to you and your fellow expeRts,

Cheers,
Bert


On Tue, May 1, 2012 at 11:30 AM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote: