Re: [R] Matched pairs with two data frames

From: Patrick Connolly <p_connolly_at_slingshot.co.nz>
Date: Tue, 15 Apr 2008 08:45:41 +1200

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

|> Zitat von Peter Alspach <PAlspach@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
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

______________________________________________
R-help_at_r-project.org 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.
Received on Tue 15 Apr 2008 - 00:11:09 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 16 Apr 2008 - 10:30:28 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive