From: Murta on 6 Aug 2010 06:57 Hello All I Would like to split this array: l={{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}}, by the second element of each group, to group what are between 0-2, 2-4,4-6 and so on (just the second element) Using BinLists look like a good idea. I get my desirable result with: BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}}, {0, 10, 10}, {0, 10, 2}] But I would like to don't have to put any struction to the first element (the "{0, 10, 10}" information) How I can ignore it? I tried something like BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}},None, {0, 10, 2}] BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}},Automatic, {0, 10, 2}] BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}},All, {0, 10, 2}] But isn't the way. Thanks in advande Murta
From: Darren Glosemeyer on 7 Aug 2010 01:31 Murta wrote: > Hello All > > I Would like to split this array: l={{1, 0}, {1, 1}, {1, 2}, {2, > 3}, {2, 4}}, by the second element of each group, to group what are > between 0-2, 2-4,4-6 and so on (just the second element) > Using BinLists look like a good idea. I get my desirable result > with: > BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}}, {0, 10, 10}, > {0, 10, 2}] > > But I would like to don't have to put any struction to the first > element (the "{0, 10, 10}" information) > How I can ignore it? I tried something like > BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}},None, {0, 10, > 2}] > BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}},Automatic, > {0, 10, 2}] > BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}},All, {0, 10, > 2}] > But isn't the way. > > Thanks in advande > Murta > I assume the main issue is not having to look at the data to determine what the range should be to capture all the data values in that particular coordinate. You could use the allSpec function that follows to construct a specification that captures all values in the i^th column of the data without manually constructing it. In[1]:= allSpec[dataset_, i_] := With[{min = Min[dataset[[All, i]]], max = Max[dataset[[All, i]]]}, {min - 1, max + 1, max - min + 2}] In[2]:= data = {{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}}; In[3]:= BinLists[data, allSpec[data, 1], {0, 10, 2}] Out[3]= {{{{1, 0}, {1, 1}}, {{1, 2}, {2, 3}}, {{2, 4}}, {}, {}}} Darren Glosemeyer Wolfram Research
From: Bob Hanlon on 7 Aug 2010 01:33 BinLists[l, {{-Infinity, Infinity}}, {Range[0, Max[l[[All, 2]]] + 3, 2]}] Bob Hanlon ---- Murta <rodrigomurtax(a)gmail.com> wrote: ============= Hello All I Would like to split this array: l={{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}}, by the second element of each group, to group what are between 0-2, 2-4,4-6 and so on (just the second element) Using BinLists look like a good idea. I get my desirable result with: BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}}, {0, 10, 10}, {0, 10, 2}] But I would like to don't have to put any struction to the first element (the "{0, 10, 10}" information) How I can ignore it? I tried something like BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}},None, {0, 10, 2}] BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}},Automatic, {0, 10, 2}] BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}},All, {0, 10, 2}] But isn't the way. Thanks in advande Murta
From: Rodrigo Murta on 7 Aug 2010 06:21 Thanks!... very elegant solution. It's this that I was looking for. > Date: Fri, 6 Aug 2010 09:04:18 -0400 > From: hanlonr(a)cox.net > To: rodrigomurtax(a)gmail.com; mathgroup(a)smc.vnet.net > Subject: Re: BinLists in Array > > > BinLists[l, {{-Infinity, Infinity}}, > {Range[0, Max[l[[All, 2]]] + 3, 2]}] > > > Bob Hanlon > > ---- Murta <rodrigomurtax(a)gmail.com> wrote: > > ========================== > Hello All > > I Would like to split this array: l=={{1, 0}, {1, 1}, {1, 2}, {2, > 3}, {2, 4}}, by the second element of each group, to group what are > between 0-2, 2-4,4-6 and so on (just the second element) > Using BinLists look like a good idea. I get my desirable result > with: > BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}}, {0, 10, 10}, > {0, 10, 2}] > > But I would like to don't have to put any struction to the first > element (the "{0, 10, 10}" information) > How I can ignore it? I tried something like > BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}},None, {0, 10, > 2}] > BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}},Automatic, > {0, 10, 2}] > BinLists[{{1, 0}, {1, 1}, {1, 2}, {2, 3}, {2, 4}},All, {0, 10, > 2}] > But isn't the way. > > Thanks in advande > Murta >
|
Pages: 1 Prev: Suggestions Next: automatically include automatic numbering in a |