Actually, I'm a beginner too :-) It's just this list is so helpful, and I was 
helped so many times, that I am trying to bring my small contribution :-)
How about:

#_____________________________________________
Y1=X*Y[,1]
Y=cbind(Y,Y1)
Y

  site1 site2 site3 site4 site5 site6 site7 stage1 stage2 stage3
A     1     5     9    13    17    21    25      1      5      9
B     2     6    10    14    18    22    26      4     12     20
C     3     7    11    15    19    23    27      9     21     33
D     4     8    12    16    20    24    28     16     32     48
#_______________________________________________

And then change the names as you like... I bet there is a more elegant way, but 
it seems to work :-)

hth,
 
Mihai Nica
170 East Griffith St. G5
Jackson, MS 39201
601-914-0361

----- Original Message ----
From: Majid Iravani <[EMAIL PROTECTED]>
To: Mihai Nica <[EMAIL PROTECTED]>
Sent: Friday, October 13, 2006 1:58:29 AM
Subject: Re: [R] Cross two dataframe

Dear Mihai Nica
Thanks. Actually I dont want to merge two data frames.
For example if I have two matrixes X and Yas follow:

X<- matrix(1:12, nrow=4, ncol=3, dimnames=list(c("A","B","C","D"), 
c("stage1","stage2","stage3")))

Y<- matrix(1:28, nrow=4, ncol=7, dimnames=list(c("A","B","C","D"), 
c("site1","site2","site3","site4","site5", "site6","site7")))

  I would like to multiply first column of the Ymatrix (site1) to the all 
of the columns in Xmatrix. Then, the product will be three new columns 
(site1stage1, site1stage2 and site1stage3) which I want to add to Ymatrix. 
As my site (Y) dataset has about 400 columns its not easy to do it in Excel 
and Im looking for a command in R to prepare a new data frame for more 
analysis. So I would greatly appreciate if you help me in this case.
Thanks a lot again
Majid





At 10:06 AM 10/12/2006 -0700, you wrote:
>Mihai Nica

--------------------------------------------------------------------------------
  Majid Iravani
  PhD Student
  Swiss Federal Research Institute WSL
  Research Group of Vegetation Ecology
  Zürcherstrasse 111  CH-8903 Birmensdorf  Switzerland
  Phone: +41-1-739-2693
  Fax: +41-1-739-2215
  Email: [EMAIL PROTECTED]
http://www.wsl.ch/staff/majid.iravani/
--------------------------------------------------------------------------------








        [[alternative HTML version deleted]]

______________________________________________
[email protected] 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.

Reply via email to