Thank you very much, both Dimitris and Erik.
Erik - you are right, I was trying to remove any duplication (i.e., if
there are the same values in 2 or 3 or 4 columns).
And it looks like that's what your solution does.
But doesn't it do the same thing as Dimitris' solution?

Dimitri

On Mon, Sep 21, 2009 at 2:55 PM, Erik Iverson <eiver...@nmdp.org> wrote:
> Hello,
>
> Do you mean exactly any 2 columns.  What if the value is equal in more than 2 
> columns?
>
>>
>> I built a data frame "grid" (below) with 4 columns. I want to exclude
>> all rows that have equal values in ANY 2 columns. Here is how I am
>> doing it:
>>
>> index<-expand.grid(1:4,1:4,1:4,1:4)
>
> If a value is equal in 2 or more rows, i.e., duplicated, then the following 
> should work, assuming index can be changed to a matrix for apply ...
>
> t3 <- index[apply(index, 1, function(x) all(!duplicated(x))),]
>



-- 
Dimitri Liakhovitski
Ninah.com
dimitri.liakhovit...@ninah.com

______________________________________________
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.

Reply via email to