Crossprod of two different matrices by a factor/group

I have two matrices, X is N by p and y is N by 1
In each of the rows of X and y, theres a group associated with it. For example, 1st 1:j-1 elements in both X and y belong to the first group, subsequent j-1 to N elements belong to another group.
Is there anyway I could apply crossprod at the group level (ie give me a p by 1 matrix/vector in this case according to group), something that rowsums is doing
I tried looking up tapply but it does not seem to take up multiply arguments.
Would appreciate any help thanks!

Hi, can you provide a reproducible example of what your dataset looks like and what you're after?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.