[R] First. Last. Data row selection

Nutter, Benjamin NutterB at ccf.org
Tue Feb 23 19:39:08 CET 2010


I've attached some functions I've written based on previous questions
that have been posted here.  Unfortunately, I was too lazy to give
credit to previous commenters in my Rd file, and for that I hope they'll
forgive me.  

In any case, please be assured that the functions I've attached are in
no way my original work.

Benjamin

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of wookie1976
Sent: Tuesday, February 23, 2010 12:40 PM
To: r-help at r-project.org
Subject: [R] First. Last. Data row selection


I am in the process of switching from SAS over to R.  I am working on
very large CSV datasets that contain vehicle information.  As I am
processing the data, I need to select the first (or sometimes the
second) record (by date) for any records that have the same license
plate number.  In SAS, there is a function called 'first.' that can be
used on sorted datasets to pull out those first entries for each
occurrence of a particular variable  (in this case the variable is
'license plate') found in the data.  I have spent some time looking
around and cannot seem to find an equivalent function in R. 
Can anyone recommend an efficient technique that would pull this off?  I
assume the database must first be sorted by vehicle plate and date, and
then apply the filter or function.  Any help would be greatly
appreciated.  

Thanks, Joe
--
View this message in context:
http://n4.nabble.com/First-Last-Data-row-selection-tp1566260p1566260.htm
l
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.


===================================

P Please consider the environment before printing this e-mail

Cleveland Clinic is ranked one of the top hospitals
in America by U.S.News & World Report (2009).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.


More information about the R-help mailing list