[R] computation on a table

Claus Atzenbeck claus.atzenbeck at freenet.de
Sun Nov 13 11:43:47 CET 2005


On Sun, 13 Nov 2005, Peter Dalgaard wrote:

> jim holtman <jholtman at gmail.com> writes:
[...]
> > > index <- match(colnames(table2), colnames(table1), nomatch=0)
> > > t(t(table1[,index]) / table2[index != 0, drop=FALSE])
[...]
> or even
>
> > sweep(table1, 2, table2[colnames(table1)], "/")

Perfect. I was not aware of sweep. The R help pages I read to solve this
problem did not refer to that.

Thanks to Jim and Peter.

Claus




More information about the R-help mailing list