I have a large set of data which is composed of lists of lists of lists. I have to sort through the data, applying functions to lists that fit my selection rules.

Because of these lists within lists, I useTable a lot and end up using Table within Table.

I have written a function that searches through my very large data set, this is called dataRT2. It uses 4 variables to search through a data set. It generates lists of pairs, e.g.

{{150, 46.9058}, {150, 46.8654}, {200, 46.0359}, {200, 46.1426},
 {250, 45.2678}, {250, 45.2213}, {300, 43.8255}, {300, 43.9024}}

I often combine this search function with Table, so that I can have groups of data sets; i.e.,

b = {x, y, z};
Table[dataRT2[a, b[[i]], c, d], {i, 1, Length[b]}

I then use GatherBy to collect these data by their first number, which gives:

{{{150, 46.9058}, {150, 46.8654}}, {{200, 46.0359}, {200, 46.1426}}, 
 {{250, 45.2678}, {250, 45.2213}}, {{300, 43.8255}, {300, 43.9024}}}

I then want to use the length of this data set as the maximum iteration number for another Table that is applied to this function. The actual code is given here:

    {#1, #2/Total[#2]} &, 
        dat = Map[Mean[#] &, GatherBy[dataRT2[species[[i]], 25, 4, 1], First]], 
        {i, 1, 3}][[{1, 2, 3}, j, {1, 2}]]], 
  {j, 1, Length[dat]}]

Notice the use of dat = for the inside Table that is used in the outside table to define the maximum number of iterations.

Currently this code works, but I have to run it twice in order to get meaningful data. The length of the the data in "dat" stays constant across all iterations of the outer table. Is there some way to "lock" the value of "dat" obtained from the first iteration, and use it repetitively until the outer Table has completed iterating?

I hope this all makes sense :/

  • $\begingroup$ Please provide species, so that the code runs. Also, Table[dataRT2[a,b[[i]],c,d],{i,1,Length[b]} is missing the closing bracket. In general, it is better to copy and paste code from your notebook into the question instead of typing it into the question. $\endgroup$ – bbgodfrey Jun 30 '17 at 14:39
  • $\begingroup$ I did copy it, I just had to backspace a few times so I must have deleted something by accident. Sorry! dataRT2 won't run without some further sample data and that code being defined, should I also give that? species={"C2H6","C2H4","C2H2"} $\endgroup$ – Butters Jun 30 '17 at 14:45
  • $\begingroup$ it would be helpful if you could provide the smallest possible instance of your problem that makes sense-along with dimensions, if not actual data, of the "lists of lists of lists" you work with... $\endgroup$ – user42582 Aug 28 '17 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.