s-news
[Top] [All Lists]

Re: easy question

To: "Lambert.Winnie" <lambert.winnie@ensco.com>
Subject: Re: easy question
From: Spencer Graves <spencer.graves@PDF.COM>
Date: Wed, 27 Aug 2003 15:13:18 -0700
Cc: S-PLUS Newsgroup <s-news@lists.biostat.wustl.edu>
References: <8986151694190742869D08450EE4DCDE33325D@amu-exch.ensco.win>
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20030208 Netscape/7.02
Have you considered something like the following:

  yr.day1 <- paste(df1$year, df1$day, sep=":")
  yr.day2 <- paste(df2$year, df2$day, sep=":")
  yr.day3 <- paste(df3$year, df3$day, sep=":")
  common.dates <- intersect(yr.day1, intersect(yr.day2, yr.day3))
  df1s <- df1[is.element(yr.day1, common.dates), ]
  df2s <- df2[is.element(yr.day2, common.dates), ]
  df3s <- df3[is.element(yr.day3, common.dates), ]

If the data frames all have the same column names, I'm not certain if you even need the last 2 lines or what you want to do from here.

hope this helps.  spencer graves

Lambert.Winnie wrote:
I know this is an easy question - I must be having a brain-blip. I am using S-PLUS 6 on Windows XP. I have 3 data frames, each with the same column names. I want to compare the Year and Day columns in all 3 and get a resulting data frame with just the records that have the same Year and Day combination in each data frame. I tried merge(df1, df2, by=intersect(Year, Day)), but that didn't work. Am I at least on the right track? Thanks for the help.

**********************************************
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.winifred@ensco.com

AMU Quarterly Reports are available online:
http://science.ksc.nasa.gov/amu/home.html
********************************************




<Prev in Thread] Current Thread [Next in Thread>
  • easy question, Lambert.Winnie
    • Re: easy question, Spencer Graves <=