[R] Fw: PROBLEM - - COMPARING AND COMBINING two DATASETS

Maithili Shiva maithili_shiva at yahoo.com
Thu Aug 27 14:26:59 CEST 2009








Dear Sirs, 
  
At the outset I sincerely apologize for reproducing my query to you. I also thank all of you for the solution you had provided. It has worked on the actual data I am working with. 
  
However, there is this peculiar problem which I had realized only after I had obtained my results. 
  
e.g. in the example I had attached 
  
A <- c(2, 2, 1, 3, 7, 3, 3, 1, 14, 7, 31) 
B <- c(0.0728,0.9538,4.0140,0.0020,2.5593,0.1620,2.513,0.3798, .0033,0..2282, 0.1614) 
  
tapply( B, A, sum) 
  
I get R output as – 
  
 1          2          3            7            14          31 
4.3938   1.0266   2.6770    2.7875    0.0033    0.1614 
  
However, my requirement is I should get the output as 
  
1          2          3         4  5  6  7         8  9 …. 14 ………..31 
4.3938 1.0266  2.6770   0  0  0  2.7875  0  0 ..0.0033 .. 0.161 
  
i.e. my output should include the values 4, 5, 6, etc. which are not part of dataset A and the corresponding totals in B (which are anyways 0’s). I need this for my further analysis. Its possible for me to add these 0’s manually, however when the dataset is large, its not practical. 
  
I am attaching herewith an excel file. I will be grateful if you can guide me. 
  
Thanks in advance 
  
Maithili 
start: 2009-08-18 end: 0000-00-00 

Thinking of ordering food? Find restaurant numbers on Yahoo! India Local


      Love Cricket? Check out live scores, photos, video highlights and more. Click here http://cricket.yahoo.com


More information about the R-help mailing list