On Wed, Feb 08, 2012 at 03:36:45PM +0100, Francisco wrote: > Hello, > I have a dataset with many rows, starting from a row that I choose I > would like to find the other rows in the dataset which are identical to > this row (with the same values per each column) and assign them to a > variable. > How could I do?
Hello: Try the following. # prepare a data frame df1 <- expand.grid(x=1:2, y=letters[1:2]) df <- rbind(df1, df1, df1) # look for later occurences of df[i, ] i <- 6 ind <- unname(which(rowSums(df == df[rep(i, times=nrow(df)), ]) == ncol(df))) ind[ind >= i] [1] 6 10 Hope this helps. See also duplicated(df). This finds all duplicates, not only duplicates of a given row. Petr Savicky. ______________________________________________ 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.