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) -- View this message in context: http://r.789695.n4.nabble.com/Subsetting-subsets-of-data-frames-tp2245556p2245556.html Sent from the R help mailing list archive at Nabble.com.
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)
Hi some example would be helpful. r-help-bounces at r-project.org napsal dne 07.06.2010 09:01:27:> > 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 samedate.> > I would like to remove the duplicates per different id (removingduplicate> dates for the entire data.frame would leave nothing since different id'sall> have the same dates) > > subset(x,!duplicated(x$date_)) works for just one ID, but i am havingHowever if above works on one id so use split sapply/lapply approach. Split your data according to id and use sapply or lapply wit above function for splitted object. I believe this is what ddply does so maybe it can be used too. Regards Petr> trouble figuring out how to apply this to each subset of IDs (andretaining> the original data.frame structure) > -- > View this message in context: http://r.789695.n4.nabble.com/Subsetting- > subsets-of-data-frames-tp2245556p2245556.html > 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 guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
subset(x, !duplicated(paste(x$id, x$date)) On Mon, Jun 7, 2010 at 3:01 AM, Jeff08 <jefferyding at gmail.com> 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) > -- > View this message in context: http://r.789695.n4.nabble.com/Subsetting-subsets-of-data-frames-tp2245556p2245556.html > 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. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?