Hi Ralf, Perhaps the following is what you are looking for:
d <- data.frame(timestamp=c(3,3,3,5,8), mylabel=c("a","a","a","b","c")) d d[!duplicated(d$timestamp),] HTH, Jorge On Fri, Jul 30, 2010 at 12:18 AM, Ralf B <> wrote: > I have to deal with data frames that contain multiple entries of the > same (based on an identifying collumn 'id'). The second collumn is > mostly corresponding to the the id collumn which means that double > entries can be eliminated with ?unique. > > a <- unique(data.frame(timestamp=c(3,3,3,5,8), > mylabel=c("a","a","a","b","c"))) > > However sometimes I have dataframes like this: > > a <- unique(data.frame(timestamp=c(3,3,3,5,8), > mylabel=c("a","z","a","b","c"))) > > which then results in: > > timestamp mylabel > 1 3 a > 2 3 z > 4 5 b > 5 8 c > > However, I want only the first occurance of timestamp and then > selected over the first label resulting in an output like this: > > timestamp mylabel > 1 3 a > 4 5 b > 5 8 c > > Is there something like groupBy (like in SQL) ? > > Best, > Ralf > > ______________________________________________ > R-help@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. > [[alternative HTML version deleted]] ______________________________________________ R-help@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.