Scripting Guide > Scripting Platforms > Make Platforms Invisible
Publication date: 08/13/2020

Make Platforms Invisible

In certain circumstances, you might want to make the platform analysis invisible. This means that no platform windows appear, and the platform runs in the background.

If you are doing a simulation or bootstrap analysis in your script, the script might call a platform hundreds or thousands of times. Perhaps you just want to pull one or two results out of each platform report. The following example performs a simulation and then creates a table of results and shows them in a Distribution report:

dt = As Table( (0 :: 10)`, << Column Names( {"X"} ) ); // create X variable
// set initial random seed to get reproducible results
Random Reset( 12345 );
dt << New Column( "Y",
	Set Formula( :X * 2 + 1 + Random Normal() )

// Y values have a random component

res = []; // define results matrix (empty to start)
For( i = 1, i <= 100, i++, // loop through simulation runs

// for each iteration, fit a regression line and save parameter estimates

	bv = dt << Bivariate( Y( :Y ), X( :X ), Fit Line( 1 ), Invisible );
	res |/= (Report( bv )["Parameter Estimates"][

// concatenate the results to the bottom of the results matrix

	Number Col Box( "Estimate" )] << Get as Matrix)`;

// close the window (even though it’s invisible)

	bv << Close Window;
		dt:Y << Eval Formula; // generate new Y values

// create table of results

dtres = As Table( res, << Column Names( {"Intercept", "Slope"} ) );

// show results in Distribution

dtres << Distribution( Y( :Intercept, :Slope ) );

If you want to run an analysis as an intermediate step in your script, and do not need the user to see the analysis, hide it with the invisible option. In this case, you might want to show only specific results from the report, which you can output to a journal or to the log.

The following example runs the Distribution platform as invisible, and outputs only the CDF plot to a new journal:

dt = Open( "$SAMPLE_DATA/Big" );
dist = dt << Distribution( Y( :height ), CDF Plot( 1 ), invisible );
Report( dist )["CDF Plot"] << Journal;
dist << Close Window;

The following example extracts the F-Ratio from an invisible Bivariate report, and outputs it to the log:

dt = Open( "$SAMPLE_DATA/Big" );
biv = dt << Bivariate( x( :height ), y( :weight ), invisible );
biv << Fit Line;
r = biv << Report;
fratio = r[ColumnBox( "F Ratio" )][1];
r << Close Window;
Show( fratio );

fratio = 1.15609545178219;

Tip: Invisible windows use resources that must be manually freed. Be sure to close the invisible window when the script is done with it.

You can also use the invisible option on the options in the Tables menu, such as Subset, Sort, Stack, and so on. The following example makes the Subset operation invisible:

dt = Open( "$SAMPLE_DATA/Big" );
dt << Select Where( :age == 14 );
subDt = dt << Subset( invisible );
subDt << Bivariate( x( :height ), y( :weight ), Fit Line );

Note that the preceding line could also be handled using a WHERE clause:

subDt << Bivariate( x( :height ),y( :weight ), Where( :age == 14 ), Fit Line );
Want more information? Have questions? Get answers in the JMP User Community (