MathGroup Archive 2011

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

Search the Archive

Re: To put name to columns

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116455] Re: To put name to columns
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Wed, 16 Feb 2011 04:34:03 -0500 (EST)
  • References: <ijdocr$fe1$1@smc.vnet.net>

Labeling can be done like the following example fron the
"Applications" section of the Grid doc page:

data = {{"first", 1, 2, 3}, {"second", 11, 5, 6}, {"third", 111, 8,
    9}, {"fourth", 1111, 10, 11}};

Text@Grid[Prepend[data, {"name", "a", "b", "c"}],
  Background -> {None, {Lighter[Yellow, .9], {White,
      Lighter[Blend[{Blue, Green}], .8]}}},
  Dividers -> {{Darker[Gray, .6], {Lighter[Gray, .5]},
     Darker[Gray, .6]}, {Darker[Gray, .6], Darker[Gray, .6], {False},
     Darker[Gray, .6]}}, Alignment -> {{Left, Right, {Left}}},
  ItemSize -> {{10, 3, 5, 5}}, Frame -> Darker[Gray, .6],
  ItemStyle -> 14, Spacings -> {Automatic, .8}]

You see that Prepend is used to insert names in the grid. TableForm
has an option TableHeadings that can be used for this as well.

Assigning a symbolic name to each column can be done thus:
{name,a,b,c}=Transpose[data]

In[4]:= Mean[b]

Out[4]= 25/4

In[5]:= Sort[name]

Out[5]= {"first", "fourth", "second", "third"}

Cheers -- Sjoerd

On Feb 15, 12:34 pm, "Carlos J. Andr=E9s Blasco" <cjand... at ono.com>
wrote:
> Please, how to put name to each column in a table with several columns, when you insert a grid?
> The idea is to manipulate these columns by means of their names, for example to find out the average, standard devaition, etc
> Thank you
> Carlos J,. Andres



  • Prev by Date: Re: To put name to columns
  • Next by Date: Re: 3D of combine plot
  • Previous by thread: Re: To put name to columns
  • Next by thread: pythonika - problems compiling