In addition Array
and Map
work. Thanks Mr.Wizard. There are some subtle differences in their arguments the documentation does a good job of explaining them.
I assume you were looking for counts of the occurrences of values 0 - 100 in col7.
min = 0;
max = 9; (* In your example it would be 100 *)
col7 = RandomInteger[{min, max}, max*10];
a = {}; For[i = min, i <= max, i++, AppendTo[a, Count[col7, i]]]; a
Array[Count[col7, #] &, max + 1 - min, min]
Map[Count[col7, #] &, Range[min, max]]
Table[Count[col7, i], {i, min, max}]
Sort[Tally[col7], #1[[1]] < #2[[1]] &][[All, 2]]
BinCounts[col7, {min, max + 1, 1}]
Results:
{6, 11, 14, 6, 11, 9, 7, 10, 7, 9}
{6, 11, 14, 6, 11, 9, 7, 10, 7, 9}
{6, 11, 14, 6, 11, 9, 7, 10, 7, 9}
{6, 11, 14, 6, 11, 9, 7, 10, 7, 9}
{6, 11, 14, 6, 11, 9, 7, 10, 7, 9}
{6, 11, 14, 6, 11, 9, 7, 10, 7, 9}
The numbers will vary because of how I generated col7, but they should be the same for all six examples.
Performance results:
min = 0;
max = 100;
col7 = RandomInteger[{min, max}, 10000];

Table
doesn't work for you, but maybe I'm just too tired. Can you explain? $\endgroup$col7 = {}
) before using it in AppendTo? Note thatAppendTo[col7,someList]
is the same ascol7 = Append[col7,someList]
but both requirecol7
in this case to be defined $\endgroup$