[R] the first. from SAS in R
NutterB at ccf.org
Mon Nov 29 14:45:50 CET 2010
My apologies for coming to the party so late.
I'm sure this question has been answered a couple of times. The
attached function is one I pulled from the help archives, but I can't
seem to duplicate the search that led me to it.
In any case, I've attached the function I found, and an .Rd file I use
as part of a local package. I've also attached a pair of accompanying
records to retrieve the last record and the nth record. These have the
advantage of not requiring data frames to be sorted prior to
extraction--the function will sort them for you.
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of David Katz
Sent: Wednesday, November 24, 2010 10:17 AM
To: r-help at r-project.org
Subject: Re: [R] the first. from SAS in R
Often the purpose of first/last in sas is to facilitate grouping of
observations in a sequential algorithm. This purpose is better served in
R by using vectorized methods like those in package plyr.
Also, note that first/last has different meanings in the context of "by
versus "by x notsorted;". R "duplicated" does not address the latter,
which splits noncontiguous records with equal x.
View this message in context:
Sent from the R help mailing list archive at Nabble.com.
R-help at r-project.org mailing list
PLEASE do read the posting guide
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
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