# [S] r and rho

Erin Hodgess (hodgess@uhdux2.dt.uh.edu)
Thu, 12 Feb 1998 16:52:51 -0600

Dear Prof. Gleaves:
Here is a possible solultion to your problem.
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)
> for(i in 1:84)x2[i] <- sum(x1[,xt[i,1:3]])

Now the xt matrix has the list of the possible combinations. You
end up with the x2 vector with all of the sums. There are 84 possible
combinations; i.e., the combination of 9 items taken 3 at a time.

I hope this helps!

Sincerely,

Erin Hodgess
Assistant Professor
Dept. of Computer and Mathematical Sciences
University of Houston -- Downtown
e-mail: hodgess@uhdux2.dt.uh.edu

From: "David H. Gleaves" <dhg@psyc.tamu.edu>
Organization: tamu/psycdept
To: s-news@wubios.wustl.edu
Date: Wed, 11 Feb 1998 19:21:34 CST6CDT
Subject: [S] help transforming a matrix
X-Mailer: Pegasus Mail for Windows (v2.52)
Message-Id: <1F6D01F1A23@psyc.tamu.edu>
Sender: owner-s-news@wubios.wustl.edu
Status: R

I would be extremely greatful for some help with this problem.

I have a matrix with nine variables (columns). I need to output a
new matrix with three variables, each of which being the sum of three
of the nine variables (e.g. v1+v2+v3, v4+v5+v6, v7+v8+v9). Then, I
need to do this for all possible combinations of three variables.
These could either be output into one three dimensional array or
separate two dimensional matrices for each of the possible
combinations.

I'm using S-Plus 3.3 with Windows 3.2

As I said, I would greatly appreciate any help with this, and please
send responses to my personal e-mail rather than the list.

Thanks

David H. Gleaves, Ph.D.
Assistant Professor, Department of Psychology
Texas A&M University, College Station, TX 77843-4235
dhg@tamu.edu, http://acs.tamu.edu/~Gleaves/
-----------------------------------------------------------------------
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

-----------------------------------------------------------------------
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