Re: How to extract numbers from list elements with text?

• To: mathgroup at smc.vnet.net
• Subject: [mg70379] Re: How to extract numbers from list elements with text?
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Sat, 14 Oct 2006 03:08:52 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <egn9a3\$1em\$1@smc.vnet.net>

```Henning Heiberg-Andersen wrote:
> Hi,
>
> I have a list looking like this:
>
> { 1 Intensity 0.23523,  2 Intensity 0.00005,  3 Intensity 0.00004, ..}
>
> Is there a command which allows extraction of only the last number appearing
> in each element
> of the list?. If not, how can I modify the list elements?
>
> Best regards,
>
> Henning Heiberg-Andersen
>
>
As written, Mathematica is going to undergo some simplifications and
assume that a space is an implicit multiplication.

In[1]:=
{1 Intensity 0.23523,2 Intensity 0.00005,3 Intensity 0.00004}

Out[1]=
{0.23523 Intensity,0.0001 Intensity,0.00012 Intensity}

To avoid this, your data must be imported/transformed as a list of list.
Then, extracting the third column is straightforward.

In[1]:=
data=ReleaseHold[HoldForm[{1 Intensity 0.23523,2 Intensity 0.00005,3
Intensity 0.00004}] /. Times -> List]

Out[1]=
{{1,Intensity,0.23523},{2,Intensity,0.00005},{3,Intensity,0.00004}}

In[2]:=
data[[All,3]]

Out[2]=
{0.23523,0.00005,0.00004}

Regards,
Jean-Marc

```

• Prev by Date: Re: How do you open all cells?
• Next by Date: Re: How to extract numbers from list elements with text?
• Previous by thread: Re: How to extract numbers from list elements with text?
• Next by thread: Re: How to extract numbers from list elements with text?