s-news
[Top] [All Lists]

Re: first instance extraction

To: "Michael Slattery" <Michael.Slattery@epa.state.oh.us>
Subject: Re: first instance extraction
From: David L Lorenz <lorenz@usgs.gov>
Date: Wed, 25 Oct 2006 07:31:20 -0500
Cc: s-news@wubios.wustl.edu, s-news-owner@lists.biostat.wustl.edu
In-reply-to: <453F0CA9.C718.0085.0@epa.state.oh.us>

Michael,
  Check the documentation for the duplicated() function. It will return a vector indicating which entries are repeats of a previous entry, therefore !duplicated() returns a vector of the first instance of a value.
Dave


"Michael Slattery" <Michael.Slattery@epa.state.oh.us>
Sent by: s-news-owner@lists.biostat.wustl.edu

10/25/2006 06:05 AM

To
<s-news@wubios.wustl.edu>
cc
Subject
[S] first instance extraction





Hello all,
I am trying to understand how to extract the first instance of a dataframe record, in which the index may appear any number of times (at least once),  into a dataframe which then contains the _first_ record of each index (and subsequent data). The dataframe has mixed data types, and the index for extraction can either be a factor or a character, i.e.,
 
index      data1     data2    data3
 
char1      ...         ....        ...
char1
char1
char2
char2
char3
char3
char3
char3
char3
char4
 
 
On S-Plus 7.0 Pro, Windows XP Pro
thanks all !!
 
 
Michael W. Slattery
Geologist, Ohio EPA
122 S. Front Street
Lazarus Government Center
Columbus OH 43215
michael.slattery@epa.state.oh.us
614-728-1221 (Ph)
614-644-2909 (Fax)


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