BookmarkSubscribeRSS Feed

Community Trekker


Feb 13, 2015

Integrate group name into stacking data table and graph builder plotting loop.


My goal is to find certain columns, group them, and then stack them into a new data table ( each group separately ) and then plot each group using graph builder using the Label as X and the group name as Y axis. 

The grouping and stacking is working fine, however, I'm finding it difficult to determine how to use the group name as an axis and incorporate the graph builder plotting into the larger loop.  I've reviewed and taken some portions of code here from various discussions in the community.

If I replace the group name with a known column name I get only only graph builder and obviously not the plot that I'm looking for.



Names Default To Here( 1 );
dt = Current Data Table();
start = Tick Seconds();
// Columns
list = List();
dt = Current Data Table();
list << Get Column Names();
col_names = dt << get column names( string );
number_columns = N Cols( dt );
dt << Reorder By Name;
// Containing Keyword Column Grouping
// Empty list to be populated with found columns
found_list = {};
// Name of the groups based on the keyword that I'll look for later
keyword_group_list = {"Ahh", "Now" };
// Loop over columns and create groups
For( i = 1, i <= N Items( keyword_group_list ), i++,
// Empty list to be populated with found columns. Get's emptied for every new group/ keyword.
found_list = {};
one_group = keyword_group_list[i];
// Loop over all column names, looking for ones that start with "Ahh", "Now", etc from keyword_group_list
// Once found put into array "found_list"
For( k = 1, k <= N Items( col_names ), k++,
If( Starts With( col_names[k], one_group ),
Insert Into( found_list, col_names[k] )
// Move each column group to the front in original data table
dt << Move Column Group( To First, one_group );
If( N Items( found_list ) > 0,
dt << group columns( one_group, found_list );
Wait( 0.25 );
stkdata = dt << Stack(
columns( dt << get column group( one_group ) ),
Wait( 1.5 ),
Output Table( "Stacked " || one_group ),
/*stkdatatable = Current Data Table(),
Wait( 1.5 ),*/
stkdatatable << Graph Builder(
Variables( X( :Label ), Y( :one_group ) ),
Elements( Points( X, Y, Legend( 3 ) ) )
end = Tick Seconds();
runtime = end - start;




Community Trekker


Sep 23, 2015

Re: Integrate group name into stacking data table and graph builder plotting loop.

Can you provide a sample data table for this script?