> On 4 May 2017, at 20:13, Murat Tasan <mmu...@gmail.com> wrote: > > The only semi-efficient method I've found around this is to `apply` across > rows (more accurately through blocks of rows coerced into dense > sub-matrices of P), but I'd like to try to remove the looping logic from my > codebase if I can, and I'm wondering if perhaps there's a built-in in the > Matrix package (that I'm just not aware of) that helps with this particular > type of computation.
The "wordspace" package has an efficient C-level implementation for this purpose: P.norm <- normalize.rows(P) which is a short-hand for P.norm <- scaleMargins(P, rows=1 / rowNorms(P, method="euclidean")) Best, Stefan ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.