[R] Matched pairs with two data frames

Patrick Connolly p_connolly at slingshot.co.nz
Mon Apr 14 22:45:41 CEST 2008


On Mon, 14-Apr-2008 at 08:37AM +0200, Udo wrote:

|> Zitat von Peter Alspach <PAlspach at hortresearch.co.nz>:
|> 
|> > Udo
|> >
|> > Seems you might want merge()
|> >
|> > HTH .......
|> >
|> > Peter Alspach
|> 
|> Thank you Peter and Jorge,
|> 
|> but as I had written in my last sentence,
|> "Merge doesn´t do the job, because it makes
|> all possible matches", but maybe there is a sophisticated
|> solution with "merge", I could not bring light to.

Maybe it would help if we knew what you mean by 'all' in this context.
To get the NAs in your example, it is NECESSARY to use the all = TRUE
argument.  Without the all = TRUE, the NA rows are omitted.

What is it that you don't want in this:

> merge(treat, control, all = TRUE)
   age school out1 out2
1    1     10  9.5  1.1
2    1     10  9.5  2.0
3    1     10  9.5  3.5
4    1     10  9.5  4.9
5    1     10  2.3  1.1
6    1     10  2.3  2.0
7    1     10  2.3  3.5
8    1     10  2.3  4.9
9    2     20  3.3  6.5
10   2     20  4.1  6.5
11   2     20  5.9  6.5
12   3     33   NA  5.2
13   4     11  4.6   NA

Whatever it is, can't you subset them out?

best

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}          		 Great minds discuss ideas    
 _( Y )_  	  	        Middle minds discuss events 
(:_~*~_:) 	       		 Small minds discuss people  
 (_)-(_)  	                           ..... Anon
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.



More information about the R-help mailing list