s-news
[Top] [All Lists]

Re: opposite of merge

To: "Lambert.Winnie" <lambert.winnie@ensco.com>, "S-PLUS Newsgroup" <s-news@lists.biostat.wustl.edu>
Subject: Re: opposite of merge
From: Tony Plate <tplate@blackmesacapital.com>
Date: Mon, 12 Jul 2004 14:33:58 -0600
In-reply-to: <8986151694190742869D08450EE4DCDE45036D@amu-exch.ensco.win>
References: <8986151694190742869D08450EE4DCDE45036D@amu-exch.ensco.win>
A hacky way to do this would be to use paste() to create a key combining year, month, and day, and then use setdiff() to find the values of the key in df2 that you want.

-- Tony Plate

At Monday 01:11 PM 7/12/2004, Lambert.Winnie wrote:
S-PLUS 6, Windows XP
 
I think this must be simple, but I'm having a brain blip and can't get there from here.  I want to do something that is essentially the opposite of merge.  I have 2 data frames, say df1 and df2.
 
df1 has 3 columns: Year, Month, Day; and 153 records.
df2 has 2295 records and 25 columns, including 3 with the same names: Year, Month, Day.
 
I created a third data frame, df3, that is an intersection of df1 and df2 by using merge(df2, df1). df3 contains 153 records with the same years, months, and days as in df1 and all the other columns in df2 associated with those years, months, and days. i.e., df3 has 25 columns, 153 rows.
 
Now, I would like another data frame, df4, that has all the years, months, and days in df2 that are NOT in df3 and df1  (2295-153 = 2142 records, 25 columns).  Can anyone help?  Thanks.
 
*****************************************************************
Winifred C. Lambert  Senior Scientist/Meteorologist
ENSCO, Inc.
Aerospace Sciences and Engineering Division
1980 N. Atlantic Ave., Suite 230
Cocoa Beach, FL  32931
VOICE:  321.853.8130  FAX:  321.853.8415
EMAIL:  lambert.winnie@ensco.com
 
AMU Quarterly Reports are available online:
http://science.ksc.nasa.gov/amu
*****************************************************************
 
<Prev in Thread] Current Thread [Next in Thread>