Accessing Elements of Arrays in TableForm
- To: mathgroup at smc.vnet.net
- Subject: [mg61667] Accessing Elements of Arrays in TableForm
- From: Gregory Lypny <gregory.lypny at videotron.ca>
- Date: Mon, 24 Oct 2005 21:07:33 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hello Everyone,
I've created a fairly inelegant function for computing seven
descriptive statistics on the columns of a matrix: total, mean,
median, and so on. It looks like this.
DescStatsIntegerForm[x_] :=
Transpose[
Flatten[
Round[
{{Total[x]}, {Mean[x]},
{Median[x]}, {StandardDeviation[x]},
{SampleRange[x]}, {Apply[Min, x\[Transpose], 2]}, {Apply[Max,
x\[Transpose], 2]}}], 1]]
For the results to read easily, I could make TableForm part of
the function as below, where the user supplies the names of the
series (the columns) and the names of the statistics are hard-wired
into the function. This will produce a nice table with variable
names as the row headings and the names of the statistics as column
headings. The problem is that individual elements, such as (3, 4),
are no longer accessible. Is there any way around this? That is,
can functions be built so that their output is in table form and
their individual elements can still be referenced for further
calculations?
Any advice would be most appreciated.
DescStatsIntegerFormTable[x_, varNamesList_] :=
TableForm[
Transpose[
Flatten[
Round[
{{Total[x]}, {Mean[x]},
{Median[x]}, {StandardDeviation[x]},
{SampleRange[x]}, {Apply[Min,
x\[Transpose], 2]}, {Apply[Max, x\[Transpose], 2]}}], 1]],
TableHeadings -> {varNamesList, {"
Total", "Mean", "Median", "S.d", "Range", "Min.", "Max."}}]
Regards,
Greg