Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to format two separate lists in columns, rather than rows in Mathematica?
    primarykey
    data
    text
    <p>This seems like it should be a piece of cake, but I haven't found the answer in Mathematica's documentation. Say I have two separate lists, for example x={1,2,3,4,5} and y={1,4,9,16,25}. I want to format these lists as a table with each list as a column, like this: </p> <pre><code>x y 1 1 2 4 3 9 4 16 5 25 </code></pre> <p>But if I do TableForm[x,y], I get only the first column, like this: </p> <pre><code>1 2 3 4 5 </code></pre> <p>If I do Grid[{x,y}], I get a table, but formatted as rows instead of columns, like this: </p> <pre><code>1 2 3 4 5 1 4 9 16 25 </code></pre> <p>Now, if I have my values as {x,y} pairs, rather than separate lists, then I can get <em>almost</em> what I want,like so:</p> <pre><code>Input: Table[{n,n^2},{n,1,5}]//TableForm Output: 1 1 2 4 3 9 4 16 5 25 </code></pre> <p>I say <em>almost</em>, because I'd like to have the variable names at the top of each column, and I'd like the columns justified so that the ones digits are always placed vertically in the "ones place", the tens digits in the "tens place", etc.</p> <p>So, back to my question: If I have two separate lists of the same length, how can I format them as a table of columns? I checked the MMA documentation for Grid and TableForm, but I couldn't find a way to do it. Did I miss something? If there's no direct way to do it, is there a way to transform two separate lists into pairs of values that could then be formatted in columns using TableForm?</p> <p>Thanks for any suggestions you might have.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload