Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11173

Re: Data Format

From Alexei Boulbitch <Alexei.Boulbitch@iee.lu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Data Format
Date 2012-08-02 08:55 +0000
Message-ID <jvdf9a$c4v$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


Please consider the following code, which is data imported directly into
Mathematica via a .mtp file (Minitab Portable Worksheet), and then using
list assignment:

    list = {"C1" -> {5.`, 4.`, 7.`, 3.`, 6.`, 6.`, 7.`, 1.`, 5.`, 6.`}, "C2"
-> {2.`, 5.`, 6.`, 7.`, 7.`, 1.`, 5.`, 4.`, 7.`, 2.`}}

The following two commands work:

    Mean["C1" /. list]

    Mean["C2" /. list]

However I would prefer to be able to issue the following commands instead:

    Mean[C1]

    Mean[C2]

How can the code at top be converted so that these simpler commands will
work?

Thanks.

Nicholas Kormanik

Hi, Nicholas,

I cannot tell what is it for a file, .mtp, but it is quite clear what the output means and how to operate further.

The notation

"C1" -> {5.`, 4.`,.}

means that the string C1 will from now be the corresponding list. It is not what you want, I guess you need a plain list. Part[ ] will help:

list = {"C1" -> {5.`, 4.`, 7.`, 3.`, 6.`, 6.`, 7.`, 1.`, 5.`, 6.`},
   "C2" -> {2.`, 5.`, 6.`, 7.`, 7.`, 1.`, 5.`, 4.`, 7.`, 2.`}};

lst1 = list[[1, 2]]
lst2 = list[[2, 2]]
lst3 = {lst1, lst2}


{5., 4., 7., 3., 6., 6., 7., 1., 5., 6.}

{2., 5., 6., 7., 7., 1., 5., 4., 7., 2.}

{{5., 4., 7., 3., 6., 6., 7., 1., 5., 6.}, {2., 5., 6., 7., 7., 1.,
  5., 4., 7., 2.}}

You may now operate as usually. For example here is Mean acting on the first sublist:

Mean[lst1]

5.

If you have not done this before, have a look into Menu/Help/Part, Menu/Help/ExpressionStructure and Menu/Help/PartsOfExpressions.

Have fun, Alexei


Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch@iee.lu



Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Data Format Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2012-08-02 08:55 +0000

csiph-web