Re: Select All Lists Where Any Element is a Given Value
- To: mathgroup at smc.vnet.net
- Subject: [mg96621] Re: Select All Lists Where Any Element is a Given Value
- From: samuel.thomas.blake at gmail.com
- Date: Tue, 17 Feb 2009 06:27:49 -0500 (EST)
- References: <gncmgo$fkq$1@smc.vnet.net>
On Feb 17, 8:40 am, Gregory Lypny <gregory.ly... at videotron.ca> wrote: > Hello everyone, > > Suppose I have the list > > X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}, > > where NA is a string, although it need not be. How can I use Select = > to pull out all lists in X where NA appears in any element? In this = > example, I want to pull out the second and third list. > > Regards, > > Gregory Try this In[12]:= X = {{1, 2, 3}, {8, NA, 20}, {-7, 9, NA}}; In[13]:= Select[X, ! FreeQ[#, NA] &] Out[13]= {{8, NA, 20}, {-7, 9, NA}} Sam