Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a function of this form


that gives me a list as an output,where the first column collects names of output variables.
Is it possible to customize TableForm so that when I evaluate:


it takes that first column and displays it as a column table heading, and the rest columns as data?
I don't want to make another function for this because I want to make it as simple as possible. The function should look something like this:

    TableForm[ Garch[a_, b_, c_, ___]] := 
      TableForm[ Garch[a, b, c][[All, 2 ;; -1]],
        TableHeadings -> {ToString /@ Garch[a, b, c][[All, 1]], None}]

So,I'll try to be more precise.The reason I don't want to define a new function is because in the end I want to create a compact mathematica package(this is part of my master thesis) that other students would use without learning another function. If you are familiar with RLink and the mathematica representation of data.frame object you'll understand what I mean.For example evaluate the next code:


Now when we do


we should get the table with row names 1,2,3 and column names a,b.So I'm guessing that TableForm is somehow modified to recognize the functions in first output and show them like in the second case. Analogically to this I would like to modify the TableForm function to recognize my Garch function and do the operations you suggested.

share|improve this question

I am not certain about what you are asking, so this may be off target. My understanding is your Garch function returns a list like this one;

test = {{a, 91, 48, 30, 50}, {b, 49, 81, 18, 74}, {c, 30, 23, 98, 96}};

If that is right, then defining a function

garchForm[g_List] := 
  TableForm[g[[All, 2 ;; -1]], TableHeadings -> {ToString /@ g[[All, 1]], None}]

will give the following result:

test // garchForm


I think this the easiest to do what I think you are looking for. I further note that you might not need to map ToString over the row labels. TableForm doesn't require labels to be strings.

However, because you say you don't want to define a new function (although it escapes me why a new function is bad), I also note you can always use a pure function:

test // TableForm[#[[All, 2 ;; -1]], TableHeadings -> {ToString /@ #[[All, 1]], None}] &
share|improve this answer
Thanks for responding,I edited my question,hope is now clear what I want to do,basically you understood it correctly,now it's just the problem of finding the solution. – Milos Cipovic Apr 3 '14 at 1:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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