Skip to content
Prev 170689 / 398506 Next

Applying functions to partitions

Stavros Macrakis <macrakis at alum.mit.edu> writes:
or the variant

  idx <- outer(rfact, (cfact - 1) * max(rfact), "+")
  matrix(tapply(m, idx, mean), max(rfact))

The assumption is that cfact, rfact are integer valued with max(rfact)
<= nrow(m), max(cfact) <= ncol(m).

I think Stavros' solution will run in to trouble when there are more
than 9 row blocks, and '10 1' sorts before '2 1', for instance.

Martin

  
    
Message-ID: <6phljs6xeiw.fsf@gopher4.fhcrc.org>
In-Reply-To: <8b356f880902161221g56d33080o1c0de030069a572b@mail.gmail.com> (Stavros Macrakis's message of "Mon, 16 Feb 2009 15:21:44 -0500")