Re: [R] Replacing NA values when building matrix using tapply

2007-10-05 Thread Gabor Grothendieck
Try this: xtabs(value ~ row + column, d)[] On 10/5/07, Chris Long <[EMAIL PROTECTED]> wrote: > Hi, > > I'm building a matrix m from a data frame d which includes the matrix row, > column and value. > > This works well enough: > > m <- tapply(d[,"value"],d[,c("row","column")],c) > > However, I'

[R] Replacing NA values when building matrix using tapply

2007-10-05 Thread Chris Long
Hi, I'm building a matrix m from a data frame d which includes the matrix row, column and value. This works well enough: m <- tapply(d[,"value"],d[,c("row","column")],c) However, I'd like to replace any missing values with 0, not NA. The obvious doesn't work, however: m <- tapply(d[,"value"],