I have a rather naive question. How does one add a column from an already existing table to another already existing table?

  • $\begingroup$ Using the data given by @bill in his answer below: Table[Insert[table1[[i]], table2[[All,2]][[i]], 3], {i, 3}] (col-2 of table2 becomes col-3 of table1) $\endgroup$ – user1066 Jun 15 '19 at 19:45

Suppose you want to add the second column from your second table onto the end of the first table. Try this


which gives you this

{{a, b, c, 2}, {d, e, f, 5}, {g, h, i, 8}}

Look up and study MapThread and Append and All in the help system and see if you can figure out how each piece of this is working.

There are always several different ways of accomplishing anything in Mathematica.


An alternative way to insert a column of table2 (say the last column) as the last column of table1 is to use Join with level specification (third argument) set to 2:

table1 = Array[Subscript[a, Row@{##}] &, {5, 3}];
table2 = Array[Subscript[b, Row@{##}] &, {5, 3}];

col = -1; (* or col = 3 *)
table3 = Join[table1, table2[[All, {col}]], 2];

Row[MapThread[Labeled[MatrixForm @ #, #2, Top] &,
  {{table1, table2, table3}, {"table1", "table2", "table3"}}]]

enter image description here


Your question is unclear. When you say "add," do you mean "insert"? Or actually add? If the latter:

Transpose[a][[5]] + Transpose[b][[3]]

will add the 5th column of a to the 3rd column of b.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.