For example, with 6 observations, the columns of the matrices below
represent the groups that can be formed by placing the 6 ordered
observations into 2-5 groups. Think of the columns of these matrices as
being an indicator of group membership. We then cbind these matrices
with the trivial partitions into 1 and 6 groups:
mat2g <- matrix(c(1,1,1,1,1,
2,1,1,1,1,
2,2,1,1,1,
2,2,2,1,1,
2,2,2,2,1,
2,2,2,2,2),
nrow = 6, ncol = 5, byrow = TRUE)
mat3g <- matrix(c(1,1,1,1,1,1,1,1,1,1,
2,2,2,2,1,1,1,1,1,1,
3,2,2,2,2,2,2,1,1,1,
3,3,2,2,3,2,2,2,2,1,
3,3,3,2,3,3,2,3,2,2,
3,3,3,3,3,3,3,3,3,3),
nrow = 6, ncol = 10, byrow = TRUE)
mat4g <- matrix(c(1,1,1,1,1,1,1,1,1,1,
2,2,2,2,2,2,1,1,1,1,
3,3,3,2,2,2,2,2,2,1,
4,3,3,3,3,2,3,3,2,2,
4,4,3,4,3,3,4,3,3,3,
4,4,4,4,4,4,4,4,4,4),
nrow = 6, ncol = 10, byrow = TRUE)
mat5g <- matrix(c(1,1,1,1,1,
2,2,2,2,1,
3,3,3,2,2,
4,4,3,3,3,
5,4,4,4,4,
5,5,5,5,5),
nrow = 6, ncol = 5, byrow = TRUE)
cbind(rep(1,6), mat2g, mat3g, mat4g, mat5g, 1:6)
I'd like to be able to do this automagically, for any (reasonable,
small, say n = 10-20) number of observations, n, and for g = 1, ..., n
groups.
I can't see the pattern here or a way forward. Can anyone suggest an
approach?
Thanks in advance,
Gavin
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Dr. Gavin Simpson [t] +44 (0)20 7679 0522
ECRC, UCL Geography, [f] +44 (0)20 7679 0565
Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/
UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
______________________________________________
R-help@r-project.org 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.