That works. Thank you! On Fri, Sep 28, 2012 at 4:22 PM, Rui Barradas <ruipbarra...@sapo.pt> wrote:
> Hello, > > Try the following. > > > idx <- duplicated(df) | duplicated(df, fromLast = TRUE) > df[idx, ] > > Note that they are returned in their original order in the df. > > Hope this helps, > > Rui Barradas > > Em 28-09-2012 21:11, Adam Gabbert escreveu: > >> I would like to select a all the duplicate rows of a data frame including >> the original. Any help would be much appreciated. This is where I'm at >> so >> far. Thanks. >> >> #Sample data frame: >> df <- read.table(header=T, con <- textConnection(' >> label value >> A 4 >> B 3 >> C 6 >> B 3 >> B 1 >> A 2 >> A 4 >> A 4 >> ')) >> close(con) >> >> # Duplicate entries >> df[duplicated(df),] >> >> # label value >> # B 3 >> # A 4 >> # A 4 >> >> #I want to select all the rows that are duplicated including the original >> #This is the output I want >> # label value >> # B 3 >> # B 3 >> # A 4 >> # A 4 >> # A 4 >> >> [[alternative HTML version deleted]] >> >> ______________________________**________________ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting guide http://www.R-project.org/** >> posting-guide.html <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.