# [S] Subsetting matrices (was untitled)

Patrick Connolly (PConnolly@grunt.marc.cri.nz)
Mon, 16 Feb 1998 17:18:11 +1300 (NZDT)

|> What is did is put together a matrix with 25 rows and 9 columns
|> for testing purposes.
|>
|> > x1 <- matrix(rnorm(225),nrow=25,ncol=9)
|>
|> > xc3 <- c(3:9,4:9,5:9,6:9,7:9,8:9,9,
|> + 4:9,5:9,6:9,7:9,8:9,9,
|> + 5:9,6:9,7:9,8:9,9,
|> + 6:9,7:9,8:9,9,
|> + 7:9,8:9,9,
|> + 8:9,9,
|> + 9)
|>
|> > xc2 <- c(rep(2,7),rep(3,6),rep(4,5),rep(5,4),rep(6,3),rep(7,2),8,
|> + rep(3,6),rep(4,5),rep(5,4),rep(6,3),rep(7,2),8,
|> + rep(4,5),rep(5,4),rep(6,3),rep(7,2),8,
|> + rep(5,4),rep(6,3),rep(7,2),8,
|> + rep(6,3),rep(7,2),8,
|> + rep(7,2),8,
|> + 8)
|> > xc1 <- c(rep(1,28),rep(2,21),rep(3,15),rep(4,10),rep(5,6),rep(6,3),7)
|>
|> > x2 <- numeric(length=84)
|> > xt <- cbind(xc1,xc2,xc3)

This matrix can be done more simply thus:

> A_expand.grid(1:9,1:9,1:9)
> B_A[A[,1]<A[,2]&A[,1]<A[,3]&A[,2]<A[,3],]

> dim(B)
[1] 84 3

I'd be fairly certain that apart from being a dataframe, it's the same
as xt

-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news