Hi Casper,

Try

m/colSums(m)
m/rowSums(m)

HTH,
Jorge

On Sun, Nov 28, 2010 at 3:46 PM, casperyc <> wrote:

>
> Hi,
>
> I have a matrix, say
> m=matrix(c(
>        983,679,134,
>        383,416,84,
>        2892,2625,570
>        ),nrow=3
> )
>
> i can find its row/col sum by
>
> rowSums(m)
> colSums(m)
>
> How do I divide each row/column by its rowSum/colSums and still return in
> the matrix form?
> (i.e. the new rowSums/colSums =1)
>
> Thanks.
>
> Casper
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/how-to-divide-each-column-in-a-matrix-by-its-colSums-tp3062739p3062739.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to