MathGroup Archive 2012

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

Search the Archive

Re: Data Format

  • To: mathgroup at smc.vnet.net
  • Subject: [mg127547] Re: Data Format
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Fri, 3 Aug 2012 04:16:40 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <jvaran$751$1@smc.vnet.net> <jvdepb$bvi$1@smc.vnet.net>

On Aug 2, 1:46 am, awnl <a... at gmx-topmail.de> wrote:
>> Hi,
>> 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?
>
> For just this simple case I wouldn't suggest to create the symbols C1
> and C2. For more complicated cases it might be a reasonable choice but
> probably there are better ways to deal with this. Anyway, this will do
> what I think you want:
>
> (Set @@ {Symbol[#1], #2}) & @@@ list

You might want to precede that by

  Clear @@ (First /@ list)

just in case the symbols in 'list' are already defined.

>
> it will define the symbols C1 and C2 and set their values to the
> corresponding lists. @@ and @@@ are shortcuts for Apply.
>
> hth
>
> Albert



  • Prev by Date: Re: How do I create a circular lamina?
  • Next by Date: Strange runtime error in Compiled function
  • Previous by thread: Re: Data Format
  • Next by thread: Re: Data Format