Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Database like "left join" or SAS like Merge function

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83603] Re: [mg83569] Database like "left join" or SAS like Merge function
  • From: bsyehuda at gmail.com
  • Date: Sat, 24 Nov 2007 04:14:05 -0500 (EST)
  • References: <200711231031.FAA25047@smc.vnet.net>

It is easy to implement such a task
here is for a single column position
merge2Matrices[mat1_, mat2_, col_] :=
 If[Length[mat1] == Length[mat2] && col <= Length[mat1],
  MapThread[Flatten[Insert[#1, #2, col]] &, {mat1, mat2}]]

or

merge2Matrices[mat1_, mat2_, col_] :=
 MapThread[Flatten[Insert[#1, #2, col]] &, {mat1, mat2}] /;
  Length[mat1] == Length[mat2] && col <= Length[mat1]

The extension for multiple indexes is immediate

merge2Matrices[mat1_, mat2_, col_] :=
 MapThread[Flatten[Insert[#1, #2, #3]] &, {mat1, mat2, col}] /;
  Length[mat1] == Length[mat2]==Length[col]

note the change of conditions and the fact that col needs to be a list of
indexes

yehdua


On Nov 23, 2007 12:31 PM, Peter <pjcrosbie at gmail.com> wrote:

> Is there a builtin function that can "join" (merge) two two-
> dimensional data lists based on a single or multiple key column?
>
> This seems like such a basic requirement that I feel like I must be
> missing something obvious.
>
> Thanks, Peter
>
>



  • Prev by Date: float -> RGB
  • Next by Date: Re: Contour Lines
  • Previous by thread: Database like "left join" or SAS like Merge function
  • Next by thread: Re: Database like "left join" or SAS like Merge function