On Mon, Feb 16, 2009 at 7:52 PM, Bert Gunter wrote:
> I suppose the clean way to do this would be to define a cartesian product of
> two factors with the induced lexicographic order (is there a standard
> function for doing this?):"
>
> Of course. ?interaction.
Perhaps my specification was unclea
"...
I suppose the clean way to do this would be to define a cartesian product of
two factors with the induced lexicographic order (is there a standard
function for doing this?):"
Of course. ?interaction.
-- Bert Gunter
Genentch
__
R-help@r-project.
On Mon, Feb 16, 2009 at 4:23 PM, Martin Morgan wrote:
> Stavros Macrakis writes:
> >matrix(tapply(mm, outer(rfact,cfact,paste), mean),
> > length(unique(rfact)))
>
> or the variant
>
> idx <- outer(rfact, (cfact - 1) * max(rfact), "+")
> matrix(tapply(m, idx, mean), max(rfact
Stavros Macrakis writes:
> Assuming your matrix is:
>
> mm <- matrix(runif(6*6),6,6)
>
> And your blocks are defined by integers or factors:
>
>cfact <- c(1,1,1,2,3,3)
>rfact <- c(1,1,1,2,2,3)
>
> Then the following should do the trick:
>
>matrix(tapply(mm, outer(rfact,cfact,paste
Its not clear that the object returned from such an operation would be
a matrix, but if things remain very regular then perhapos you will
succeed with this:
> markmtx <- matrix(scan(textConnection("a a a d g g
+ a a a d g g
+ a a a d g g
+ b b b e h h
+ b b b e h h
+ c c c
Assuming your matrix is:
mm <- matrix(runif(6*6),6,6)
And your blocks are defined by integers or factors:
cfact <- c(1,1,1,2,3,3)
rfact <- c(1,1,1,2,2,3)
Then the following should do the trick:
matrix(tapply(mm, outer(rfact,cfact,paste), mean),
length(unique(rfact)))
On Mon, 16 Feb 2009, Titus von der Malsburg wrote:
On Mon, Feb 16, 2009 at 01:45:52PM -0500, Stavros Macrakis wrote:
How are the blocks defined? As a priori index ranges? By factors? By
some property of i,j? Or...?
Ok, I should have been more specific.
The blocks are defined by factors. The
On Mon, Feb 16, 2009 at 01:45:52PM -0500, Stavros Macrakis wrote:
> How are the blocks defined? As a priori index ranges? By factors? By
> some property of i,j? Or...?
Ok, I should have been more specific.
The blocks are defined by factors. There's a factor for the columns and
a factor for the r
Hi list! I have a large matrix which I'd like to partition into blocks
and for each block I'd like to compute the mean. Following a example
where each letter marks a block of the partition:
a a a d g g
a a a d g g
a a a d g g
b b b e h h
b b b e h h
c c c f i i
I
9 matches
Mail list logo