[R] computation on a table
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Sun Nov 13 14:28:30 CET 2005
Claus Atzenbeck <claus.atzenbeck at freenet.de> writes:
> 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.
So you didn't look at ?prop.table, I guess....
--
O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list