s-news
[Top] [All Lists]

Beginner's question: Merging dataset

To: s-news@lists.biostat.wustl.edu
Subject: Beginner's question: Merging dataset
From: Jindan Zhou <jindan@jindan.homedns.org>
Date: Mon, 13 Dec 2004 13:06:57 -0600
In-reply-to: <6.1.0.6.2.20041213104431.0617db90@mailhost.blackmesacapital.com>
References: <OFFB8EDC80.90B2CF07-ON87256F66.00529C96-87256F66.00531701@npsp.com> <41B9D3A8.80801@uvm.edu> <6.1.0.6.2.20041213104431.0617db90@mailhost.blackmesacapital.com>
Hello members!

I need to merge two datasets in the following manner:

The first dataset, mydata, has 6 columns

  SiteID Summ.Per. Year  NO3      Dates          X
1   AL02    Summer 2001 0.86   6/5/2001  8/28/2001
2   AL02      Fall 2001 0.47  8/28/2001 11/27/2001
3   AL02    Winter 2002 0.62 11/27/2001  2/26/2002
....
21   AL10    Winter 1986 0.62 12/3/1985 3/4/1986
22   AL10    Spring 1986 0.73  3/4/1986 6/3/1986
23   AL10    Summer 1986 1.36  6/3/1986 9/2/1986

Notice each SiteID may appear multiple times.

The second dataset, latlong, has 3 columns

  Site.ID Latitude Longitude
1    AL02  30.7905  -87.8497
2    AL10  32.4583  -87.2422
3    AL24  30.4741  -88.1411
...

Each Site.ID will appear exactly one time.

What I need to do is to generate two additional columns in mydata, using
information from latlong, for *each* occurrence of SiteID in mydata.
What is the syntax in S for this job? Will the syntax be different from
R? I have been struggling for the solution since last night without a
clue, so sad!

Thanks for any hint!

Jindan

<Prev in Thread] Current Thread [Next in Thread>