I am trying to generate a matrix with the following scripts and have a few questions:
1. in order to correctly get "row" do I need to first sort the fruit column? Is there a Random formula to pick just one number out of "r"?
2. I need the final "run" matrix with the furitName info (the i variable) and be just one matrix. The current script I had would generate 3 run matrices (depending on the N Items(fruitName))
3. Once all run matrices are concatenated in one, is there a way to output the matrix to a data table?
TIA!
Names Default To Here( 1 );
dt = Current Data Table();
Summarize( dt, fruitName = by( :fruit ) );
For( i = 1, i <= N Items( fruitName ), i++,
r = dt << get rows where( :fruit == fruitName[i] );
row = Random Integer( Max( r ) - Min( r ) );
/*show(r);
show(row);*/
runTime = 5;
run = [](0, 2);
For( j = 1, j <= runTime, j++,
row = Random Integer( Max( r ) - Min( r ) );
run |/= Matrix( {{j, dt:name( "price hi" )[row] - dt:price lo[row]}} );
);
Show( run );
);