Re: Grouping {x,y z} data set

*To*: mathgroup at smc.vnet.net*Subject*: [mg99626] Re: Grouping {x,y z} data set*From*: Szabolcs Horvát <szhorvat at gmail.com>*Date*: Sat, 9 May 2009 03:31:35 -0400 (EDT)*References*: <gu301l$ok1$1@smc.vnet.net>

graser wrote: > Hi! > > I have a question for you. > > I have arbitrary data set. > > For example, > > Data={{x_1,y_1,z_1},{x_2,y_2,z_1},{x_1, y_2, z_3},........{x_n, y_m, > z_L}} > I know that this is just an example, but be aware that symbol names are not allowed to contain underscores in Mathematica. > I tried to group this data set depending on z value. > > I mean I try to select all x, y values with same z value. > > But they are not evenly distributed and they are not integer either. > Sort by z values, and then use Split. data = RandomReal[1, {20, 3}]; Split[SortBy[data, Last], Quotient[Last[#1], .1] == Quotient[Last[#2], .1] &] Here I consider two z values the same if they fall into the same interval when dividing the real lines into intervals of length 0.1. You probably need a different "sameness" condition (possibly just plain equality).