I think we can declare this the global minimum in terms of size. Thanks to
all for their contributions. On a personal note, what escaped me was the
existence of MARGIN in set-related operations.

-g

On Thu, Aug 7, 2008 at 11:51 AM, Charles C. Berry <[EMAIL PROTECTED]>wrote:

> On Thu, 7 Aug 2008, Dan Davison wrote:
>
>  On Wed, Aug 06, 2008 at 06:32:43PM -0400, Giuseppe Paleologo wrote:
>>
>>> I was posed the following problem/teaser:
>>>
>>> given two matrices, come up with an "elegant" (=fast & short) function
>>> that
>>> returns a matrix with all and only the non-duplicated columns of both
>>> matrices; the column order does not matter. In essence, a matrix
>>> equivalent
>>> of union(x,y), where x and y are vectors. I could not come with anything
>>> nice. Any ideas?
>>>
>>
>> union.matrices <- function(a, b) {
>>   u <- cbind(a,b)
>>   u[,!duplicated(u, MARGIN=2)]
>> }
>>
>> ?
>>
>
>
> Or just
>
> union.matrices <- function(a, b) unique( cbind( a , b ), MARGIN=2 )
>
> Chuck
>
>
>
>
>> (Obviously not attempting to deal with issues of identity of columns
>> containing real numbers)
>>
>> Dan
>>
>>
>>> Giuseppe
>>>
>>> --
>>> Giuseppe A. Paleologo :: Email: [EMAIL PROTECTED] :: AOL: gappy3000 ::
>>> Skype :: gappy3000 :: Gtalk: paleologo :: Mobile: 917.331.3497
>>> fact: 2^32,582,657-1 is a prime
>>>
>>>        [[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.
>>>
>>
>> ______________________________________________
>> 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.
>>
>>
> Charles C. Berry                            (858) 534-2098
>                                            Dept of Family/Preventive
> Medicine
> E mailto:[EMAIL PROTECTED]               UC San Diego
> http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901
>
>
>

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

Reply via email to