Re: [R] Duplicates among columns of a data frame

2008-12-15 Thread Charles C. Berry
Andrew, Is this what you seek? all.addresses <- Reduce( union, dat[-1] ) who.is.here <- sapply( all.addresses, function(x) dat$id[ rowSums(dat[ -1 ] == x ) != 0 ], simplify=FALSE) If not, try to give us more detail. HTH, Chuck On Mon, 15 Dec 2008, Andrew C. Ward w

Re: [R] Duplicates among columns of a data frame

2008-12-15 Thread Prof Brian Ripley
I think you mean duplicated *rows*, not columns, despite your subject line. See ?dublicated, which has a data.frame method. On Mon, 15 Dec 2008, Andrew C. Ward wrote: Dear list, I have a data frame of survey respondents, a little like this: set.seed(20081215) n <- 100 dat <- data.frame(id=1

[R] Duplicates among columns of a data frame

2008-12-15 Thread Andrew C. Ward
Dear list, I have a data frame of survey respondents, a little like this: set.seed(20081215) n <- 100 dat <- data.frame(id=1:100, addr1=sample(LETTERS, n, replace=TRUE), addr2=sample(LETTERS, n, replace=TRUE), addr3=sample(LETTERS, n, replace