[R] Subsetting subsets of data.frames

Uwe Ligges ligges at statistik.tu-dortmund.de
Mon Jun 7 12:11:08 CEST 2010


PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Uwe Ligges

On 07.06.2010 09:01, Jeff08 wrote:
>
> Hey Everyone,
>
> I have been stumped by this all day.
>
> Basically, I have a data.frame of multiple columns. Of concern are "id"&
> "date"
>
> For some reason, oftentimes there are duplicates of data with the same date.
>
> I would like to remove the duplicates per different id (removing duplicate
> dates for the entire data.frame would leave nothing since different id's all
> have the same dates)
>
> subset(x,!duplicated(x$date_)) works for just one ID, but i am having
> trouble figuring out how to apply this to each subset of IDs (and retaining
> the original data.frame structure)



More information about the R-help mailing list