Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2006

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

Search the Archive

Selecting table rows

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66037] Selecting table rows
  • From: Skirmantas <skirmantas.janusonis at yale.edu>
  • Date: Thu, 27 Apr 2006 02:26:43 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I have a 2D-table whose first column contains the unique identifiers (ID) of each row (IDs can be any numbers). I need to delete all rows whose IDs are not members of another, control list.

The following works, but I'm wondering if there is a shorter way to do this.

TBL = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}, {17, 18, 19, 20}};

CNTR = {1, 9, 17};

Map[Part[TBL, #]&, Flatten[Map[Position[Transpose[TBL][[1]], #]&, CNTR]]]
  
Thanks --

Skirmantas


  • Prev by Date: Re: Printing Lists to file without {}
  • Next by Date: Re: Setting up equations
  • Previous by thread: Re: DiscreteMath question : ToAdjacencyMatrix and FromAdjacencyMatrix
  • Next by thread: Re: Selecting table rows