Close
Close using Window
Example 1
Summary: Opens and closes data tables, retrieving window titles, and checking for table names in the title, utilizing a With Window Handler to manage new windows.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", private );
thisTitle = dt << Get Name;
testWins = Window() << Get Window Title;
testThisWin = Contains( testWins, thisTitle );
Close( dt, nosave );
dt = New Table( "test table", private );
thisTitle = dt << Get Name;
testWins = Window() << Get Window Title;
testThisWin = Contains( testWins, thisTitle );
Code Explanation:
- Open data table;
- Retrieve data table's name.
- Get all window titles.
- Check if current window title contains data table's name.
- Close data table without saving.
- Create new private table named "test table".
- Retrieve new table's name.
- Get all window titles again.
- Check if current window title contains new table's name.
Example 2
Summary: Opens and closes data tables, retrieving window titles, and checking for table name matches in JMP.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", invisible );
thisTitle = dt << Get Name;
testWins = Window() << Get Window Title;
testThisWin = Contains( testWins, thisTitle );
Close( dt, nosave );
dt = New Table( "test table", invisible );
thisTitle = dt << Get Name;
testWins = Window() << Get Window Title;
testThisWin = Contains( testWins, thisTitle );
Close( dt, nosave );
dt = Open( "$SAMPLE_DATA/data_table.jmp", private );
thisTitle = dt << Get Name;
testWins = Window() << Get Window Title;
testThisWin = Contains( testWins, thisTitle );
Close( dt, nosave );
dt = New Table( "test table", private );
thisTitle = dt << Get Name;
testWins = Window() << Get Window Title;
testThisWin = Contains( testWins, thisTitle );
Code Explanation:
- Open data table;
- Get table name.
- Get window titles.
- Check if title contains.
- Close table without saving.
- Create new table invisibly.
- Get table name.
- Get window titles.
- Check if title contains.
- Close table without saving.
Close using If
Example 1
Summary: Process of opening a data table, saving it as a SAS dataset, and closing the dataset on Windows hosts.
Code:
If( Host is( "Windows" ),
exdt = Open("data_table.jmp");
Close( exdt, Save( "$TEMP/BC_SAS_2.sas7bxat" ) );
);
Code Explanation:
- Check if host is Windows.
- Open data_table data
- Close the opened dataset.
- Save dataset as "BC_SAS_2.sas7bxat" in temp folder.
Example 2
Summary: Opens and closes a data table in JMP Pro, defining arrays for states and dw values.
Code:
If( Contains( JMP Product Name(), "Pro" ) > 0,
dt = Open("data_table.jmp");
Close( dt, no save );
);
b states = {states(
rs( 3, 101, 80 ),
rs( 0, Dot, 0 ),
rs( 3, 101, 80 ),
rs( 0, Dot, 0 ),
rs( 3, 101, 80 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 3, 101, 80 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 3, 101, 80 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 3, 101, 80 ),
rs( 3, 101, 80 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 ),
rs( 0, Dot, 0 )
)};
b dw = [2.36853031620002 33 -0.220364731639365 0.56151647869676];
Code Explanation:
- Check if JMP is Pro.
- Open data table.
- Close data table without saving.
- Define b states array.
- Define b dw array.
Example 3
Summary: Runs the ordinal fit process in JMP Pro, extracting linear values, cumulative probabilities, and predicted outcomes.
Code:
If( Contains( JMP Product Name(), "Pro" ) > 0,
dt = Open("data_table.jmp");
n1 = N Items( dt << get column names( string ) );
obj = dt << Run Script( "Ordinal Fit" );
obj << Save Probability Formula( 1 );
lin1 = dt:Linear << get values( 1 );
cum1 = (dt:Name( "Cum[1]" ) << get values( 1 )) || (dt:Name( "Cum[2]" ) << get values( 1 )) || (dt:Name( "Cum[3]" ) << get values( 1 ))
|| (dt:Name( "Cum[4]" ) << get values( 1 ));
prob1 = (dt:Name( "Prob[1]" ) << get values( 1 )) || (dt:Name( "Prob[2]" ) << get values( 1 )) || (dt:Name( "Prob[3]" ) <<
get values( 1 )) || (dt:Name( "Prob[4]" ) << get values( 1 )) || (dt:Name( "Prob[5]" ) << get values( 1 ));
pred1 = dt:Most Likely Taste Test << get values( 1 );
dt << Delete Columns( n1 + 1 :: N Cols( dt ) );
depot1 = obj << Publish Probability Formulas( 1 );
depot1 << Run Script( 1 );
lin2 = dt:Linear << get values( 1 );
cum2 = (dt:Name( "Cum[1]" ) << get values( 1 )) || (dt:Name( "Cum[2]" ) << get values( 1 )) || (dt:Name( "Cum[3]" ) << get values( 1 ))
|| (dt:Name( "Cum[4]" ) << get values( 1 ));
prob2 = (dt:Name( "Prob[1]" ) << get values( 1 )) || (dt:Name( "Prob[2]" ) << get values( 1 )) || (dt:Name( "Prob[3]" ) <<
get values( 1 )) || (dt:Name( "Prob[4]" ) << get values( 1 )) || (dt:Name( "Prob[5]" ) << get values( 1 ));
pred2 = dt:Most Likely Taste Test << get values( 1 );
Close( dt, no save );
Window( "Formula Depot" ) << close window( 1 );
);
Code Explanation:
- Check for JMP Pro.
- Open data table;
- Get number of columns.
- Run "Ordinal Fit" script.
- Save probability formula.
- Extract linear values.
- Concatenate cumulative values.
- Concatenate probability values.
- Extract predicted values.
- Delete new columns.
- Publish probability formulas.
- Run published script.
- Extract updated linear values.
- Concatenate updated cumulative values.
- Concatenate updated probability values.
- Extract updated predicted values.
- Close table without saving.
- Close "Formula Depot" window.
Example 4
Summary: Runs a predictive modeling workflow in JMP Pro, generating predicted values and publishing the formula for further analysis.
Code:
If( Contains( JMP Product Name(), "Pro" ) > 0,
dt = Open("data_table.jmp");
n1 = N Items( dt << get column names( string ) );
obj = dt << Run Script( "Model" );
obj << Save Prediction Formula( 1 );
pred1 = dt:Y Prediction Formula << get values;
dt << delete columns( n1 + 1 :: N Cols( dt ) );
depot1 = obj << Publish Prediction Formula( 1 );
depot1 << Run Script;
pred2 = dt:Y Prediction Formula << get values;
Close( dt, no save );
Window( "Formula Depot" ) << close window( 1 );
);
Code Explanation:
- Check for JMP Pro.
- Open data table.
- Count initial columns.
- Run "Model" script.
- Save prediction formula.
- Retrieve predicted values.
- Delete added columns.
- Publish prediction formula.
- Run published script.
- Retrieve new predicted values.
- Close data table without saving.
- Close Formula Depot window.
Example 1
Summary: Process of saving a JMP data table to a text file on the desktop.
Code:
folderPathTmp = "$DESKTOP";
dt1 = Open("data_table.jmp");
Close( dt1, save( folderPathTmp || "\S1261564.txt" ) );
Code Explanation:
- Set folder path to desktop.
- Open data_table data
- Close dataset, save as "S1261564.txt".
Example 2
Summary: Opens and closes a JMP data table, ignoring specific columns and defining a list of column names.
Code:
dt2 = Open( "$SAMPLE_DATA/data_table.jmp", ignore columns( "name", "sex" ) );
Close( dt2, nosave );
mylist = {"age", "height", "weight"};
Code Explanation:
- Open data table.
- Ignore specific columns.
- Close table without saving.
- Define list of column names.
Example 3
Summary: Runs the conversion of a data table to a matrix and subsequent closure without saving, utilizing the As C Expr function.
Code:
dt1 = Open("data_table.jmp");
mat1 = dt1 << Get As Matrix;
Close( dt1, Nosave );
Code Explanation:
- Open data table;
- Convert table to matrix.
- Close dataset without saving.
Close using Column
Example 1
Summary: Recoding process for a selected column in a JMP data table, utilizing the Match function to update values based on specific patterns.
Code:
dt = Open("data_table.jmp");
Column( "weight" ) << Set Selected;
Main Menu( "Cols:Recode" );
Close( dt, no save );
dt = New Table( "test recode1",
Add Rows( 7 ),
New Column( "Recode Column",
Character,
"Nominal",
Set Values(
{"qwe123456789abc", "qwe123456789abc", "qwe123456789abc", "qwe123456789a", "qwe123456789a", "qwe123456789abc", "qwe123456789"}
)
)
);
Column( dt, "Recode Column" ) << Set Selected;
dt << Begin Data Update;
For Each Row(
:Recode Column = Match( :Recode Column, "qwe123456789a", "qwe123456789abc", "qwe123456789", "qwe123456789abc", :Recode Column )
);
dt << End Data Update;
vals = dt:Recode Column << Get values;
Code Explanation:
- Open data table.
- Select "weight" column.
- Recode selected column via menu.
- Close table without saving.
- Create new table "test recode1".
- Add 7 rows to new table.
- Add "Recode Column" with character data type.
- Set initial values for "Recode Column".
- Select "Recode Column" in new table.
- Update data for "Recode Column" using Match function.
Example 2
Summary: Runs the setup and retrieval of a column's field width in a JMP data table, allowing for precise control over display formatting.
Code:
dt = Open("data_table.jmp");
ncol = Column( "weight" );
ncol << set field width( 2 );
fw = ncol << Get Field Width;
Close( dt, nosave );
certm = [1 1, 1 2, 2 1, 2 2];
Code Explanation:
- Open data table.
- Assign weight column to variable.
- Set field width to 2.
- Retrieve field width.
- Close table without saving.
- Define matrix certm.
Example 3
Summary: Creates and customizes marker segment graphs in JMP, allowing users to visualize data with varying colors and sizes.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", invisible );
xx = Column( "height" ) << Get Values;
aa = [=> 0];
sz = Column( "age" ) << get values;
yy = J( N Rows( xx ), 1, 0 );
For( ii = 1, ii <= N Rows( xx ), ii++,
aa[xx[ii]]++;
yy[ii] = aa[xx[ii]];
);
nw26 = New Window( "Marker Seg Example",
g = Graph Box(
Frame Size( 300, 120 ),
X Scale( Min( xx ) - 5, Max( xx ) + 5 ),
Y Scale( 0, 10 ),
Marker Seg( xx, yy, Row States( dt ), Sizes( sz ) )
)
);
frame = g[FrameBox( 1 )];
seg = (frame << Find Seg( "Marker Seg" ));
seg << Delete;
nw26 << Close Window;
Close( dt, no save );
nw32 = New Window( "Test32",
g32 = Graph Box(
Marker Seg(
[10 20 30 40],
[40 30 20 10],
Row states( Eval List( {Color State( "blue" ), Color State( "orange" ), Color State( "fuchsia" ), Color State( "green" )} ) )
)
)
);
frame = g32[framebox( 1 )];
seg = frame << Find Seg( "MarkerSeg" );
rsColors = seg << Get Colors;
nw32 << Close Window;
nw32b = New Window( "Test32",
g32b = Graph Box(
Marker Seg( [10 20 30 40], [40 30 20 10], Row states( Eval List( {Color State( "blue" ), Color State( "orange" )} ) ) )
)
);
frame = g32b[framebox( 1 )];
seg = frame << Find Seg( "MarkerSeg" );
rsColors = seg << Get Colors;
nw32b << Close Window;
Code Explanation:
- Open data table.
- Extract height values.
- Initialize age array.
- Extract age values.
- Create zero-filled array for counts.
- Loop through rows to count heights.
- Create new window for marker segment graph.
- Configure graph box size and scales.
- Add marker segment plot.
- Close first window without saving.
- Create second window for test graph.
- Add marker segment plot with colors.
- Retrieve segment colors.
- Close second window.
- Create third window for test graph.
- Add marker segment plot with fewer colors.
- Retrieve segment colors.
- Close third window.
Close using Select Where
Summary: Data filtering and manipulation tasks for a specific player, Rick Robey, in JMP, including selecting rows, excluding/hiding rows, and creating matrices.
Code:
dt = Open("data_table.jmp");
dt << Select Where( :Player == "Rick Robey" );
dt2 = dt << data view();
m = dt2 << Get All Columns As Matrix;
Close( dt2, nosave );
dt2 = dt << data view( selected );
m = dt2 << Get All Columns As Matrix;
Close( dt2, nosave );
robey = {"Rick Robey", "Rick Robey", "Rick Robey", "Rick Robey"};
rick2 = [54, 37, 49, 31];
dt << Clear Row States;
r = dt << Select Where( :Player == "Rick Robey" );
r << Exclude( 1 );
dt << Select All Rows;
dt2 = dt << data view( excluded );
m = dt2 << Get As Matrix;
v = dt2:Player << Get Values;
Close( dt2, nosave );
dt << Clear Row States;
r = dt << Select Where( :Player == "Rick Robey" );
r << Hide( 1 );
dt << Select All Rows;
dt2 = dt << data view( hidden );
m = dt2 << Get All Columns As Matrix;
Close( dt2, nosave );
dt << Clear Row States;
r = dt << Select Where( :Player == "Rick Robey" );
r << Label( 1 );
dt << Select All Rows;
dt2 = dt << data view( labeled );
m = dt2 << Get All Columns As Matrix;
Close( dt2, nosave );
dt << Clear Row States;
r = dt << Select Where( :Player == "Rick Robey" );
r << Label( 1 );
dt << Select All Rows;
dt2 = dt << data view( labelled );
m = dt2 << Get All Columns As Matrix;
Close( dt2, nosave );
Close( dt, nosave );
dt = New Table( "MyDt", New Column(), New Column(), New Column(), New Column() );
dt << Add Rows( 5 );
:Column 1 << set initial data( Today() );
:Column 2 << set initial data( 99 );
:Column 3 << set initial data( "abc" );
:Column 4 << set initial data( Today() );
:Column 4 << set initial data();
v = dt:Column 1 << get values;
If( !Is Missing( v[1] ),
val = 1,
val = 0
);
Code Explanation:
- Open table.
- Select rows where Player is Rick Robey.
- Create data view.
- Get all columns as matrix.
- Close data view.
- Create data view with selected rows.
- Get all columns as matrix.
- Close data view.
- Define array robey.
- Define array rick2.
- Clear row states.
- Select rows where Player is Rick Robey.
- Exclude selected rows.
- Select all rows.
- Create data view with excluded rows.
- Get values from Player column.
- Close data view.
- Clear row states.
- Select rows where Player is Rick Robey.
- Hide selected rows.
- Select all rows.
- Create data view with hidden rows.
- Get all columns as matrix.
- Close data view.
- Clear row states.
- Select rows where Player is Rick Robey.
- Label selected rows.
- Select all rows.
- Create data view with labeled rows.
- Get all columns as matrix.
- Close data view.
- Clear row states.
- Select rows where Player is Rick Robey.
- Label selected rows.
- Select all rows.
- Create data view with labeled rows.
- Get all columns as matrix.
- Close data view.
- Close original table.
- Create new table MyDt.
- Add 5 rows to new table.
- Set initial data for Column 1.
- Set initial data for Column 2.
- Set initial data for Column 3.
- Set initial data for Column 4.
- Get values from Column 1.
- Check if first value is missing.
- Assign value based on check.
Close using N Table
Summary: Opens and closes a JMP data table, with intermediate counting of tables after each operation.
Code:
dt2 = Open( "$SAMPLE_DATA/Students2.JMP", invisible );
afterOpen2 = N Table();
Close( dt2, no save );
afterClosing = N Table();
Code Explanation:
- Open data table;
- Count tables after opening.
- Close data_table.jmp without saving.
- Count tables after closing.
Close using Add Rows
Summary: Creates and modifies a new JMP table with various numeric and character columns, utilizing formulas and conditional statements.
Code:
dt = Open("data_table.jmp");
dt << add rows( 5 );
dt = dt << revert();
dt << set dirty;
Close( dt, nosave );
nt = New Table( "Empty Test",
Add Rows( 10 ),
New Column( "Column 1", Numeric, Continuous, Format( "Best", 10 ), Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ) )
);
nt << New Column( "Num Col 1", Numeric, Continuous, Width( 5 ), <<Set Each Value( Empty() ) );
nt << New Column( "Num Col 2", Numeric, Set Values( Empty() ) );
nt << New Column( "Num Col 3", Numeric, Formula( If( :Column 1 <= 5, 1, Empty() ) ) );
nt << New Column( "Num Col 4", Numeric, Set Values( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ) );
For( i = 6, i <= N Rows( nt ), i++,
:Num Col 4[i] = Empty()
);
nt << New Column( "Char Col 1", Character, Nominal, Width( 5 ), <<Set Each Value( Empty() ) );
nt << New Column( "Char Col 2", Character, Set Values( Empty() ) );
nt << New Column( "Char Col 3", Character, Formula( If( :Column 1 <= 5, "1", Empty() ) ) );
nt << New Column( "Char Col 4", Character, Nominal, Set Values( {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"} ) );
For( i = 6, i <= N Rows( nt ), i++,
:Char Col 4[i] = Empty()
);
nt << New Column( "RS Col 1", Row State, Row State, Width( 5 ), <<Set Each Value( Empty() ) );
nt << New Column( "RS Col 2", Row State, Set Values( Empty() ) );
nt << New Column( "RS Col 3a: Empty", Row State, Formula( If( :Column 1 <= 5, Color State( 3 ), Empty() ) ) );
nt << New Column( "RS Col 3b: Color State(Empty)", Row State, Formula( If( :Column 1 <= 5, Color State( 5 ), Color State( Empty() ) ) ) );
nt << New Column( "RS Col 4", Row State, Row State, Set Values( [12, 12, 12, 12, 12, 11, 11, 11, 11, 11] ) );
For( i = 2, i <= N Rows( nt ), i++,
:RS Col 4[i] = Empty()
);
Code Explanation:
- Open data table.
- Add 5 rows to table.
- Revert table changes.
- Mark table as dirty.
- Close table without saving.
- Create new empty table.
- Add 10 rows to new table.
- Add numeric column with values.
- Add numeric columns with formulas.
- Modify numeric column values conditionally.
Close using Function
Example 1
Summary: Runs data table management by opening a dataset, subscribing to column rename events, and closing the dataset without saving, while defining functions for adding and removing dataset names from an empty list.
Code:
dt = Open("data_table.jmp");
x = dt << subscribe( "abc", on column rename( renameNotify ) );
w = dt << unsubscribe( x, on column rename );
Close( dt, nosave );
varOpen = {};
f1 = Function( {dtab},
{dtname},
dtname = ((Words( (dtab << getname()), "." ))[1]);
Insert Into( varOpen, dtname );
);
f2 = Function( {dtab},
{dt},
dt = Contains( varOpen, (Words( (dtab << getname()), "." ))[1] );
Remove From( varOpen, dt );
);
Code Explanation:
- Open data table;
- Subscribe to column rename event.
- Unsubscribe from column rename event.
- Close dataset without saving.
- Initialize empty list
varOpen. - Define function
f1for adding dataset name tovarOpen. - Define function
f2for removing dataset name fromvarOpen.
Example 2
Summary: Opens and closes a data table, as well as defining a logbegin function with the current date.
Code:
dt2 = Open("data_table.jmp");
Close( dt2, nosave );
logbegin = Function( {},
begintime = Today()
);
Code Explanation:
- Open data table.
- Close table without saving.
- Define logbegin function.
- Assign current date to begintime variable.
Example 3
Summary: Runs table renaming and tracking, utilizing JMP's data manipulation capabilities to dynamically update table names and store open tables in a variable.
Code:
dt = Open("data_table.jmp");
dname = dt << get name;
f = Function( {dtab, tabname},
Print( "oldname", dname );
Print( "new name", dtab << get name );
);
dt << Subscribe( "test1", On Rename( f ) );
dt << set name( "Best Class" );
dt << Run Script( "Distribution" );
dt << unsubscribe( "test1", onRename );
dt << set name( "Better Class" );
Close( dt, no save );
varOpen = {};
f1 = Function( {dtab},
{dtname},
dtname = ((Words( (dtab << getname()), "." ))[1]);
Insert Into( varOpen, dtname );
);
Code Explanation:
- Open data table;
- Get table name.
- Define function
ffor renaming. - Subscribe to rename event.
- Rename table to "Best Class".
- Run distribution script.
- Unsubscribe from rename event.
- Rename table to "Better Class".
- Close table without saving.
- Define function
f1for tracking open tables.
Example 4
Summary: Runs various data table operations, including adding and deleting rows and columns, renaming columns, and saving the data table.
Code:
dt = Open("data_table.jmp");
addRowsFn = Function( {},
Print( "hello add row" )
);
dt << subscribe( "Test Add", onAddRows( addRowsFn, 3 ) );
deleteRowsFn = Function( {},
Print( "hello delete row" )
);
dt << subscribe( "Test Delete", onDeleteRows( deleteRowsFn, 3 ) );
addColsFn = Function( {},
Print( "hello add column" )
);
dt << subscribe( "Test Add", onAddColumns( addColsFn, 2 ) );
deleteColsFn = Function( {},
Print( "hello delete col" )
);
dt << subscribe( "Test Delete", onDeleteCols( deleteColsFn, 2 ) );
renameColsFn = Function( {},
Print( "hello rename column" )
);
dt << subscribe( "Test Rename", onRenameColumns( renameColsFn, 3 ) );
saveFn = Function( {},
Print( "hello save" )
);
dt << subscribe( "Test Save", onSave( saveFn, 3 ) );
closeFn = Function( {},
Print( "hello close" )
);
dt << subscribe( "Test Close", onClose( closeFn, 2 ) );
Code Explanation:
- Open data table.
- Define function for adding rows.
- Subscribe to add rows event.
- Define function for deleting rows.
- Subscribe to delete rows event.
- Define function for adding columns.
- Subscribe to add columns event.
- Define function for deleting columns.
- Subscribe to delete columns event.
- Define function for renaming columns.
- Subscribe to rename columns event.
- Define function for saving.
- Subscribe to save event.
- Define function for closing.
- Subscribe to close event.
Example 5
Summary: Runs the renaming of a data table and defines a custom function to expand a list based on binary representation.
Code:
dt2 = Open("data_table.jmp");
dt2 << set name( "utBigClass" );
ut_expected = dt2 << get script;
Close( dt2, nosave );
expand list = Function( {v},
{Default Local},
n = N Items( v );
m = 2 ^ n;
l = Repeat( {{}}, n );
For( i = 0, i < m, i++,
b = 0;
For( j = i, j > 0, j = Floor( j / 2 ),
b += Modulo( j, 2 )
);
Insert Into( l[b], i );
);
l;
);
Code Explanation:
- Open data table.
- Rename table to "utBigClass".
- Get table's script.
- Close table without saving.
- Define function "expand list".
- Initialize variable "n" with item count.
- Calculate power of 2 for "n".
- Initialize list "l" with empty lists.
- Loop through range 0 to m-1.
- Calculate binary representation sum.
Close using New Window
Example 1
Summary: Opens a data table, creation of a new window with an outline box and column list box, retrieval of items from the column list box, and closure of the original data table and new window.
Code:
dt = Open("data_table.jmp");
nw = New Window( "Test Case 1a", Outline Box( "Test", clb = Col List Box( all ) ) );
colItems = clb << get items;
Close( dt, no save );
nw << close window;
Code Explanation:
- Open data table.
- Create new window.
- Add outline box to window.
- Add column list box to outline box.
- Get items from column list box.
- Close original data table.
- Close new window.
Example 2
Summary: Creates a column list box with font settings and closes it, while also deleting a symbol.
Code:
dt = Open("data_table.jmp");
New Window( "Col List Box Example", Col List Box( all, width( 250 ), maxSelected( 1 ) ), lb = Col List Box() );
lb << append( "weight" );
lb << append( "height" );
lb << Set Base Font( "Title" );
tt = "Heading";
lb << Set Base Font( tt );
Small = "Mono";
lb << Set Base Font( Small );
lb << Set Base Font( "duh" );
lb << Set Base Font( 2 );
lb << Set Base Font();
lb << Set Base Font( . );
lb << Set Base Font( Empty() );
lb << Set Base Font( "text" );
lb << Set Base Font( "SMALL" );
lb << Set Base Font( "formula editor" );
lb << Set Base Font( "ANNOtatioN" );
lb << Set Base Font( "axiS" );
Close( dt, "nosave" );
lb << close window;
Delete Symbols( Small );
Code Explanation:
- Open data table.
- Create new window.
- Add column list box.
- Append "weight" to list box.
- Append "height" to list box.
- Set base font to "Title".
- Set base font to variable "tt".
- Set base font to "Mono".
- Set base font to "duh".
- Set base font to number 2.
- Set base font to default.
- Set base font to empty.
- Set base font to "text".
- Set base font to "SMALL".
- Set base font to "formula editor".
- Set base font to "ANNOtatioN".
- Set base font to "axiS".
- Close data table without saving.
- Close list box window.
- Delete symbol "Small".
Example 3
Summary: Creates a column list box with font scaling options, capturing log messages for various font scale settings.
Code:
dt = Open("data_table.jmp");
New Window( "Col List Box Example", Col List Box( all, width( 250 ), maxSelected( 1 ) ), lb = Col List Box() );
lb << append( "weight" );
lb << append( "height" );
lb << Set Font Scale( 2 );
tt = .75;
lb << Set Font Scale( tt );
log = "";
log = Log Capture( lb << Set Font Scale( 0 ) );
log = "";
log = Log Capture( lb << Set Font Scale() );
log = "";
log = Log Capture( lb << Set Font Scale( . ) );
log = "";
log = Log Capture( lb << Set Font Scale( Empty() ) );
log = "";
log = Log Capture( lb << Set Font Scale( -5 ) );
lb << Set Font Scale( 1 );
Close( dt, "nosave" );
lb << close window;
Code Explanation:
- Open table.
- Create new window.
- Add column list box.
- Append "weight" to list box.
- Append "height" to list box.
- Set font scale to 2.
- Set font scale to 0.75.
- Capture log for setting font scale to 0.
- Capture log for setting font scale without argument.
- Capture log for setting font scale to empty.
- Capture log for setting font scale to -5.
- Set font scale to 1.
- Close table without saving.
- Close list box window.
Example 4
Summary: Creates a new window with a filter column selector, allowing users to interactively set the number of lines displayed.
Code:
dt = Open("data_table.jmp");
nw = New Window( "Col List Box Example", lb = Filter Col Selector( width( 250 ) ) );
lb << Set N Lines( 20 );
numLines = lb << Get Nlines;
numLines = lb << Get Nlines;
lb << Set N Lines( 0 );
numLines = lb << Get Nlines;
lb << Set N Lines( 5 );
numLines = lb << Get Nlines;
Close( dt, no save );
nw << Close window;
log = "";
Code Explanation:
- Open data table.
- Create new window.
- Add filter column selector.
- Set selector width.
- Set number of lines.
- Retrieve number of lines.
- Retrieve number of lines again.
- Set number of lines to zero.
- Retrieve number of lines.
- Set number of lines to five.
- Retrieve number of lines.
- Close data table.
- Close window.
- Initialize log variable.
Example 5
Summary: Runs font settings and window management in JMP, creating a new window with a filter column selector and setting various font styles.
Code:
dt = Open("data_table.jmp");
New Window( "Test Case 30", lb = Filter Col Selector( width( 250 ) ) );
lb << Set Base Font( "Title" );
tt = "Heading";
lb << Set Base Font( tt );
Small = "Mono";
lb << Set Base Font( Small );
lb << Set Base Font( "duh" );
lb << Set Base Font( 2 );
lb << Set Base Font();
lb << Set Base Font( . );
lb << Set Base Font( Empty() );
lb << Set Base Font( "text" );
lb << Set Base Font( "SMALL" );
lb << Set Base Font( "formula editor" );
lb << Set Base Font( "ANNOtatioN" );
lb << Set Base Font( "axiS" );
Close( dt, "nosave" );
lb << close window;
Delete Symbols( Small );
Code Explanation:
- Open data table.
- Create new window titled "Test Case 30".
- Add filter column selector to window.
- Set base font to "Title".
- Define variable
ttas "Heading". - Set base font to
tt. - Define variable
Smallas "Mono". - Set base font to
Small. - Attempt to set base font to "duh".
- Attempt to set base font to number 2.
- Reset base font.
- Attempt to set base font to empty symbol.
- Attempt to set base font to "text".
- Attempt to set base font to "SMALL".
- Attempt to set base font to "formula editor".
- Attempt to set base font to "ANNOtatioN".
- Attempt to set base font to "axiS".
- Close data table without saving.
- Close the new window.
- Delete symbol
Small.
Example 6
Summary: Runs font scaling and logging operations in a JMP script, creating new windows with filter column selectors, text boxes, and combo boxes.
Code:
dt = Open("data_table.jmp");
New Window( "Test Case 31", lb = Filter Col Selector( width( 250 ) ) );
lb << Set Font Scale( 2 );
tt = .75;
lb << Set Font Scale( tt );
log = "";
log = Log Capture( lb << Set Font Scale( 0 ) );
log = "";
log = Log Capture( lb << Set Font Scale() );
log = "";
log = Log Capture( lb << Set Font Scale( . ) );
log = "";
log = Log Capture( lb << Set Font Scale( Empty() ) );
log = "";
log = Log Capture( lb << Set Font Scale( -5 ) );
lb << Set Font Scale( 1 );
Close( dt, "nosave" );
lb << close window;
nw = New Window( "test", H List Box( Text Box( "left" ), fcs = Filter Col Selector(), Combo Box( {"a", "b", "c"} ) ) );
Code Explanation:
- Open table.
- Create new window.
- Add filter column selector.
- Set font scale to 2.
- Initialize log variable.
- Capture log for setting font scale to 0.75.
- Clear log.
- Capture log for default font scale.
- Clear log.
- Capture log for setting font scale to 0.
- Clear log.
- Capture log for setting font scale to empty.
- Clear log.
- Capture log for setting font scale to -5.
- Set font scale to 1.
- Close table without saving.
- Close filter column selector window.
- Create new window.
- Add horizontal list box.
- Add text box.
- Add filter column selector.
- Add combo box.
Close using GetAsMatrix
Summary: Runs data extraction and table creation by opening a JMP dataset, defining variable ranges, and generating new columns with specific properties.
Code:
dt = Open("data_table.jmp");
vars = 4 :: 5;
Answer = [59 95, 61 123, 55 74, 66 145, 52 64, 60 84, 61 128, 51 79, 60 112, 61 107, 56 67, 65 98, 63 105, 58 95, 59 79, 61 81, 62 91, 65
142, 63 84, 62 85, 63 93, 64 99, 65 119, 64 92, 68 112, 64 99, 69 113, 62 92, 64 112, 67 128, 65 111, 66 105, 62 104, 66 106, 65 112, 60
115, 68 128, 62 116, 68 134, 70 172];
xData = dt << GetAsMatrix( 4 :: 5 );
xData2 = dt << GetAsMatrix( vars );
xData3 = dt << GetAsMatrix( Eval( vars ) );
xData4 = dt << GetAsMatrix( Eval( 4 :: 5 ) );
Close( dt, no save );
dt = New Table( "S1051899",
Add Rows( 3 ),
New Column( "End Spaces", Character, Nominal, Set Values( {" trim this ", " trim that ", "trim some more "} ) ),
New Column( "No end spaces", Character, Nominal, Set Values( {"trim this", "trim that", "trim some more"} ) ),
New Column( "End Spaces with List Check",
Character,
Nominal,
List Check( {" trim that ", " trim this ", "trim some more "} ),
Set Values( {" trim this ", " trim that ", "trim some more "} )
),
New Column( "No End Spaces with List Check",
Character,
Nominal,
List Check( {"trim some more", "trim that", "trim this"} ),
Set Values( {"trim this", "trim that", "trim some more"} )
)
);
tableScript = dt << Get Script;
newDt = Eval( tableScript );
Code Explanation:
- Open data table;
- Define variable range.
- Define Answer matrix.
- Extract columns 4-5 as xData.
- Extract columns 4-5 as xData2.
- Extract columns 4-5 as xData3.
- Extract columns 4-5 as xData4.
- Close dataset without saving.
- Create new table S1051899.
- Add columns with specific properties.
Close using Log Capture
Example 1
Summary: Creates a new column in a data table, defines a formula with syntax error, and configures a Column List Box to print a message on change.
Code:
log string = Log Capture(
dt = Open("data_table.jmp");
dt << New Column( "crashy", Numeric, Formula( Local( {mal + formed}, 1 + 1 ) ) );
);
Close( dt, nosave );
New Window( "colwin", clb = Col List Box( dt, On Change( Print( "Changed" ) ) ) );
clb << Append( "Age" );
Code Explanation:
- Capture log output.
- Open data table.
- Add new column "crashy".
- Define formula with syntax error.
- Close table without saving.
- Create new window "colwin".
- Add column list box.
- Set on change event to print message.
- Append "Age" to column list box.
Example 2
Summary: Executes Python scripts within JMP, capturing log output and retrieving Python objects.
Code:
iris = Open("data_table.jmp");
commands = "\[
iris = jmp.current()
print(iris.name)
]\";
s = Log Capture( Python Submit( commands ) );
iris = Python Get( iris );
Close( iris, nosave );
commands = "\[
jmpdt=jmp.current()
print(jmpdt)
]\";
s = Log Capture( Python Submit( commands ) );
Code Explanation:
- Open data_table;
- Prepare Python script.
- Execute Python script.
- Capture log output.
- Retrieve Python object.
- Close data_table dataset.
- Prepare another Python script.
- Execute second Python script.
- Capture second log output.
Close using Select where
Summary: Runs data table operations to select, hide, label, and exclude rows based on specific conditions.
Code:
dt = Open("data_table.jmp");
dt << Select where( :age == 13 );
dt << Exclude;
dt << Exclude( 1 );
dt << Exclude;
dt << Exclude;
dt << Exclude( 0 );
Close( dt, no save );
dt = Open("data_table.jmp");
dt << Select where( :age == 13 );
dt << Hide;
dt << Hide( 1 );
dt << Hide;
dt << Hide;
dt << Hide( 0 );
Close( dt, no save );
dt = Open("data_table.jmp");
dt << Select where( :age == 13 );
dt << Label;
dt << Label( 1 );
dt << Label;
dt << Label;
dt << Label( 0 );
Close( dt, no save );
dt = Open("data_table.jmp");
dt << Select where( :age == 13 );
dt << Label << Hide( 1 ) << Exclude( 0 );
dt << Label( 1 ) << Hide << Exclude;
dt << Label << Hide( 0 ) << Exclude( 0 );
dt << Label << Hide << Exclude;
dt << Label( 0 ) << Hide( 0 ) << Exclude( 0 );
Code Explanation:
- Open data table;
- Select rows where age is 13.
- Exclude selected rows.
- Exclude row 1.
- Exclude selected rows again.
- Exclude selected rows once more.
- Exclude row 0.
- Close table without saving.
- Reopen "data_table.jmp".
- Select rows where age is 13.
- Hide selected rows.
- Hide row 1.
- Hide selected rows again.
- Hide selected rows once more.
- Hide row 0.
- Close table without saving.
- Reopen "data_table.jmp".
- Select rows where age is 13.
- Label selected rows.
- Label row 1.
- Label selected rows again.
- Label selected rows once more.
- Label row 0.
- Close table without saving.
- Reopen "data_table.jmp".
- Select rows where age is 13.
- Label, hide row 1, exclude row 0.
- Label row 1, hide, exclude.
- Label, hide row 0, exclude row 0.
- Label, hide, exclude.
- Label row 0, hide row 0, exclude row 0.
Close using New Column
Summary: Creates a new column in a JMP data table, applying a Munger formula to extract specific information from existing columns.
Code:
dt = Open("data_table.jmp");
dt << New Column( "X", Formula( Munger( :name, 1, "M" ) ) );
Column( "X" ) << Eval Formula;
colVals = Column( dt, "x" ) << Get Values;
Close( dt, NoSave );
certv = {"a", "b", "c", "1", "2", "3"};
Code Explanation:
- Open data table.
- Create new column "X".
- Apply Munger formula to "Name".
- Evaluate formula for "X".
- Retrieve values from "X".
- Close data table without saving.
- Define certification variables.
Close using Try
Example 1
Summary: Runs the opening, closing, and renaming of data tables in JMP, utilizing Try() and Contains() functions to manage window titles.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", "private" );
thisTitle = dt << Get Name;
testWins = Try( Get Window List() << Get Window Title, Window() << Get Window Title );
testThisWin = Contains( testWins, thisTitle );
Close( dt, nosave );
dt = New Table( "test table", "private" );
thisTitle = dt << Get Name;
testWins = Try( Get Window List() << Get Window Title, Window() << Get Window Title );
testThisWin = Contains( testWins, thisTitle );
Close( dt, nosave );
Delete Symbols( dt, biv );
Code Explanation:
- Open data table.
- Retrieve table name.
- Get window list titles.
- Check if table title in list.
- Close table without saving.
- Create new private table.
- Retrieve new table name.
- Get updated window list titles.
- Check if new table title in list.
- Close new table without saving.
Example 2
Summary: Runs the opening, closing, and summarizing of data tables in JMP, utilizing various technical features such as Try(), Get Window List(), and Summarize()
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", "invisible" );
thisTitle = dt << Get Name;
testWins = Try( Get Window List() << Get Window Title, Window() << Get Window Title );
testThisWin = Contains( testWins, thisTitle );
Close( dt, nosave );
dt = New Table( "test table", "invisible" );
thisTitle = dt << Get Name;
testWins = Try( Get Window List() << Get Window Title, Window() << Get Window Title );
testThisWin = Contains( testWins, thisTitle );
Close( dt, nosave );
dt = Open( "$SAMPLE_DATA/data_table.jmp", "private" );
thisTitle = dt << Get Name;
testWins = Try( Get Window List() << Get Window Title, Window() << Get Window Title );
testThisWin = Contains( testWins, thisTitle );
Close( dt, nosave );
dt = New Table( "test table", "private" );
thisTitle = dt << Get Name;
testWins = Try( Get Window List() << Get Window Title, Window() << Get Window Title );
testThisWin = Contains( testWins, thisTitle );
Close( dt, nosave );
Delete Symbols( dt, biv );
dt = Open( "$SAMPLE_DATA/Big Class.jmp", "private" );
biv = dt << Run Script( "Bivariate" );
Close( dt, "nosave" );
Delete Symbols( dt, biv );
dt = Open( "$SAMPLE_DATA/Big Class.jmp", "invisible" );
biv = dt << Run Script( "Bivariate" );
Close( dt, "nosave" );
Delete Symbols( dt, biv );
Delete Symbols( dt, exg, exm );
dt = Open( "$SAMPLE_DATA/Big Class.jmp", "private" );
Summarize( dt, exg = By( :sex ), exm = Mean( :height ) );
Close( dt, "nosave" );
Delete Symbols( dt, exg, exm );
dt = Open( "$SAMPLE_DATA/Big Class.jmp", "invisible" );
Summarize( dt, exg = By( :sex ), exm = Mean( :height ) );
Close( dt, "nosave" );
Delete Symbols( dt, exg, exm );
Code Explanation:
- Open data table;
- Get window title.
- Check if title exists.
- Close data_table.jmp without saving.
- Create new invisible table.
- Get window title.
- Check if title exists.
- Close table without saving.
- Open data table;
- Get window title.
- Check if title exists.
- Close data_table.jmp without saving.
- Create new private table.
- Get window title.
- Check if title exists.
- Close table without saving.
- Delete symbols.
- Open data table;
- Run Bivariate script.
- Close data_table.jmp without saving.
- Delete symbols.
- Open data table;
- Run Bivariate script.
- Close data_table.jmp without saving.
- Delete symbols.
- Delete symbols.
- Open data table;
- Summarize data by sex.
- Close data_table.jmp without saving.
- Delete symbols.
- Open data table;
- Summarize data by sex.
- Close data_table.jmp without saving.
- Delete symbols.
Example 3
Summary: Runs the training and evaluation of a neural network model using JMP's Neural platform, with cross-validation and customizable parameters.
Code:
Open("data_table.jmp");
test = Try(
obj = Neural Net(
Y( :Y ),
X( :X ),
crossvalidation( 1 ),
hidden nodes( 3 ),
overfit penalty( 0.001 ),
number of tours( 20 ),
max iterations( 50 ),
converge criterion( 0.00001 ),
set random seed( 1261684285 ),
Go,
SendToReport( Dispatch( {"Current Fit Results"}, "Parameter Estimates", OutlineBox, Close( 0 ) ) )
),
1
);
Code Explanation:
- Open data table;
- Initialize neural network object.
- Set response variable.
- Set predictor variable.
- Enable cross-validation.
- Define hidden nodes.
- Set overfit penalty.
- Specify number of tours.
- Define max iterations.
- Set convergence criterion.
Close using Run Script
Example 1
Summary: Executes a Bivariate script on a dataset, followed by closing and deleting symbols without saving.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", "private" );
biv = dt << Run Script( "Bivariate" );
Close( dt, "nosave" );
Delete Symbols( dt, biv );
Code Explanation:
- Open data table;
- Run Bivariate script on dataset.
- Close dataset without saving.
- Delete symbols for dataset and bivariate object.
Example 2
Summary: Executes a Bivariate script and subsequent cleanup operations on a data table, including closing the table without saving and deleting symbols.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", "invisible" );
biv = dt << Run Script( "Bivariate" );
Close( dt, "nosave" );
Delete Symbols( dt, biv );
Delete Symbols( dt, exg, exm );
Code Explanation:
- Open data table.
- Run Bivariate script.
- Close data table without saving.
- Delete Bivariate object symbol.
- Delete other symbols.
Example 3
Summary: Creates and customizes a bubble plot for specific country data, executing 26 steps to refine the visualization.
Code:
dt = Open("data_table.jmp");
bp = dt << Run Script( "Bubble Plot Dynamic" );
dt << Select Where( :Country == 3365 );
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Step();
bp << Selectable Across Gaps( 1 );
bp << Close Window;
Close( dt, nosave );
dt = Open("data_table.jmp");
dt << Select Where( :Country == 3365 );
bp = dt << Run Script( "Bubble Plot Dynamic" );
bp << Time Index( 19 );
bp << No Labels;
bp << All Labels;
bp << Close Window;
Code Explanation:
- Open data table.
- Run bubble plot script.
- Select specific country.
- Execute 26 steps on bubble plot.
- Enable selectable across gaps.
- Close bubble plot window.
- Close data table without saving.
- Reopen data table.
- Select specific country again.
- Run bubble plot script again.
- Set time index to 19.
- Disable all labels.
- Enable all labels.
- Close bubble plot window.
Close using Summarize
Summary: Runs data summarization by sex and calculates the mean height, then closes the dataset without saving and deletes temporary symbols.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", "private" );
Summarize( dt, exg = By( :sex ), exm = Mean( :height ) );
Close( dt, "nosave" );
Delete Symbols( dt, exg, exm );
Code Explanation:
- Open data table;
- Summarize data by sex.
- Calculate mean height.
- Close dataset without saving.
- Delete temporary symbols.
Close using Expr
Summary: Runs table operations, including copying cell values, creating a matrix difference, and defining a new table creation.
Code:
dt = Open("data_table.jmp");
dt[1, 1] = dt[2, 1];
dt[1, {height, weight}] = dt[2, 4 :: 5];
dt[0, {height}] = dt[0, {weight}];
mat = (dt:height << get as matrix) - (dt:weight << get as matrix);
dt[[5 3 1], 0] = .;
Close( dt, "nosave" );
makedt = Expr(
dt = New Table( "Untitled",
Add Rows( 10 ),
New Column( "name",
Character,
"Nominal",
Set Values( {"KATIE", "LOUISE", "JANE", "JACLYN", "LILLIE", "TIM", "JAMES", "ROBERT", "BARBARA", "ALICE"} )
),
New Column( "color",
Character,
"Nominal",
Set Values( {"red", "black", "orange", "blue", "pink", "green", "yellow", "purple", "magenta", "cyan"} )
),
New Column( "fruit",
Character,
"None",
Set Values( {"peach", "blueberry", "apple", "pear", "strawberry", "kiwi", "orange", "lime", "tangerine", "lemon"} )
),
New Column( "age", Numeric, "Ordinal", Format( "Best", 12 ), Set Values( [4, 6, 8, 3, 5, 10, 9, 9, 5, 10] ) ),
New Column( "weight", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [6, 2, 9, 8, 7, 3, 9, 2, 2, 8] ) ),
New Column( "pictures",
Expression,
"None",
Set Values( {Empty(), Empty(), Empty(), Empty(), Empty(), Empty(), Empty(), Empty(), Empty(), Empty()} )
)
)
);
dt = "";
makedt;
log = "";
log = Trim( Log Capture( dt:name[1] = . ) );
dt[1, 2] = .;
dt[5, 2] = .;
dt[5, 3] = .;
dt:pictures[1] = .;
dt[5, 6] = .;
Code Explanation:
- Open table.
- Copy cell value.
- Copy multiple cells.
- Rename column.
- Create matrix difference.
- Clear specified rows.
- Close table without saving.
- Define new table creation.
- Reset variable.
- Execute table creation.
Close using Add Column Properties
Summary: Runs data table operations, adding value labels to the 'sex' column, selecting rows where sex is Female, and creating a new column 'x' with a formula and format.
Code:
dt = Open("data_table.jmp");
dt:sex << Add Column Properties( Value Labels( {"F" = "Female", "M" = "Male"} ), Use Value Labels( 1 ) );
dt << select where( Column( dt, "sex", "formatted" )[] == "Female" );
Close( dt, nosave );
dt = Open("data_table.jmp");
dt << New Column( "x", Formula( :age / :weight ), Format( "Fixed Dec", 10, 4 ) );
Code Explanation:
- Open data table;
- Add value labels to sex.
- Enable value labels for sex.
- Select rows where sex is Female.
- Close table without saving.
- Reopen data_table.jmp.
- Create new column x.
- Set formula for x: age divided by weight.
- Format x as fixed decimal with 4 places.
- Save changes.
Close using Row
Summary: Runs repetitive data table operations and creates a new column with a formula-based calculation.
Code:
dt = Open("data_table.jmp");
Row() = 3;
Close( dt, nosave );
dt = Open("data_table.jmp");
Row() = 3;
Close( dt, nosave );
dt = Open("data_table.jmp");
Row() = 3;
Close( dt, nosave );
dt = Open("data_table.jmp");
Row() = 3;
Close( dt, nosave );
dt = Open("data_table.jmp");
Row() = 3;
Close( dt, nosave );
dt = Open("data_table.jmp");
Row() = 10;
Close( dt, nosave );
dt = Open("data_table.jmp");
dt << New Column( "Lag Test", "Character", "Nominal", Formula( If( :sex == "M", Lag( :name ), Lag() ) ) );
Code Explanation:
- Open data table;
- Set row to 3.
- Close data_table.jmp without saving.
- Repeat steps 1-3.
- Open data table;
- Set row to 3.
- Close data_table.jmp without saving.
- Open data table;
- Set row to 3.
- Close data_table.jmp without saving.
- Open data table;
- Set row to 3.
- Close data_table.jmp without saving.
- Open data table;
- Set row to 10.
- Close data_table.jmp without saving.
- Open data table;
- Create new column "Lag Test".
- Set column type to Character, Nominal.
- Define formula for "Lag Test".
Close using Color or Mark by Column
Example 1
Summary: Runs data visualization and filtering operations on a JMP data table, including color-marking by the Age column, selecting female rows, hiding selected rows, and creating two graph windows.
Code:
dt = Open("data_table.jmp");
dt << Color or Mark by Column( :Age, Color theme( "pastel" ), Marker theme( "alphanumeric" ) );
dt << Select Where( :sex == "F" );
dt << Hide;
dt << Clear Select;
dt << show window;
sz = [11, 12, 13, 14];
nw15 = New Window( "Test", g15 = Graph Box( Line Seg( [10 20 30 40], [40 30 20 10], Row states( dt, [5 11 21 30] ), Sizes( sz ) ) ) );
frame = g15[FrameBox( 1 )];
nw15 << Close Window;
Close( dt, no save );
nw16 = New Window( "Test",
g16 = Graph Box(
Line Seg(
[10 20 30 40],
[40 30 20 10],
Row states( {Hidden State( 0 ), Hidden State( 0 ), Hidden State( 1 ), Hidden State( 1 )} )
)
)
);
frame = g16[FrameBox( 1 )];
nw16 << Close Window;
Code Explanation:
- Open data table;
- Color/mark by Age column.
- Select rows where sex is Female.
- Hide selected rows.
- Clear row selection.
- Show data table window.
- Define sizes array.
- Create first graph window.
- Get frame box reference.
- Close first graph window.
- Close data table without saving.
- Create second graph window.
- Get frame box reference.
- Close second graph window.
Example 2
Summary: Visualizes and filters a data table, creating two new windows with graph boxes that display marker segments based on age and sex.
Code:
dt = Open("data_table.jmp");
dt << Color or Mark by Column( :Age, Color theme( "pastel" ), Marker theme( "alphanumeric" ) );
dt << Select Where( :sex == "F" );
dt << Label;
dt << Clear Select;
sz = [11, 12, 13, 14];
nw15 = New Window( "Test", g15 = Graph Box( Marker Seg( [10 20 30 40], [40 30 20 10], Row states( dt, [5 11 20 29] ), Sizes( sz ) ) ) );
frame = g15[FrameBox( 1 )];
nw15 << Close Window;
Close( dt, no save );
sz = [11, 12, 13, 14];
nw14 = New Window( "Test13",
g14 = Graph Box(
Marker Seg(
[10 20 30 40],
[40 30 20 10],
Row states(
{Combine States( Color State( "red" ), Marker State( "star" ), Labeled State( 1 ), Hidden State( 0 ) ),
Combine States( Marker State( 8 ), Color State( 8 ), Labeled State( 1 ), Hidden State( 1 ) ),
Combine States( Color State( "fuchsia" ), Marker State( Filled Left Triangle ), Labeled State( 1 ), Hidden State( 0 ) ),
Combine States( Marker State( "T" ), Color State( -2648061 ), Labeled State( 1 ), Hidden State( 1 ) )}
),
sizes( sz )
)
)
);
frame = g14[FrameBox( 1 )];
nw14 << Close Window;
Code Explanation:
- Open data table.
- Color/mark by age.
- Select female rows.
- Label selected rows.
- Clear selection.
- Define marker sizes.
- Create new window with graph.
- Access graph frame.
- Close window.
- Close data table without saving.
Example 3
Summary: Vizualizes a data table by coloring and marking rows based on Age, selecting females, and creating new windows with graph boxes.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", invisible );
dt << Color or Mark by Column( :Age, Color theme( "pastel" ), Marker theme( "alphanumeric" ) );
dt << Select Where( :sex == "F" );
dt << Hide;
dt << Clear Select;
sz = [11, 12, 13, 14];
nw15 = New Window( "Test", g15 = Graph Box( Marker Seg( [10 20 30 40], [40 30 20 10], Row states( dt, [5 11 20 29] ), Sizes( sz ) ) ) );
frame = g15[FrameBox( 1 )];
nw15 << Close Window;
Close( dt, no save );
sz = [11, 12, 13, 14];
nw14 = New Window( "Test13",
g14 = Graph Box(
Marker Seg(
[10 20 30 40],
[40 30 20 10],
Row states(
{Combine States( Color State( "red" ), Marker State( "star" ), Labeled State( 1 ), Excluded State( 0 ) ),
Combine States( Marker State( 8 ), Color State( 8 ), Labeled State( 1 ), Excluded State( 1 ) ),
Combine States( Color State( "fuchsia" ), Marker State( Filled Left Triangle ), Labeled State( 1 ), Excluded State( 0 ) ),
Combine States( Marker State( "T" ), Color State( -2648061 ), Labeled State( 1 ), Excluded State( 1 ) )}
),
sizes( sz )
)
)
);
frame = g14[FrameBox( 1 )];
nw14 << Close Window;
Code Explanation:
- Open data table;
- Color by Age, pastel theme.
- Mark by Age, alphanumeric theme.
- Select females.
- Hide selected rows.
- Clear selection.
- Define sizes array.
- Create new window "Test".
- Add graph box with marker segments.
- Get frame box.
- Close window "Test".
- Close data table without saving.
- Redefine sizes array.
- Create new window "Test13".
- Add graph box with detailed marker segments.
- Get frame box.
- Close window "Test13".
Example 4
Summary: Creates a graph box with marker segments, color-coded by age and marked by sex, in JMP.
Code:
dt = Open( "$SAMPLE_DATA/data_table.jmp", invisible );
dt << Color or Mark by Column( :Age, Color theme( "pastel" ), Marker theme( "alphanumeric" ) );
dt << Select Where( :sex == "F" );
dt << Exclude;
dt << Clear Select;
sz = [11, 12, 13, 14];
nw29 = New Window( "Test", g29 = Graph Box( Marker Seg( [10 20 30 40], [40 30 20 10], Row states( dt, [5 11 20 29] ), Sizes( sz ) ) ) );
frame = g29[FrameBox( 1 )];
nw29 << Close Window;
Close( dt, no save );
sz = [11, 12, 13, 14];
nw30a = New Window( "Test13",
g30a = Graph Box(
Marker Seg(
[10 20 30 40],
[40 30 20 10],
Row states(
{Combine States( Color State( "red" ), Marker State( "star" ), Labeled State( 1 ), Selected State( 0 ) ),
Combine States( Marker State( 8 ), Color State( 8 ), Labeled State( 1 ), Selected State( 1 ) ),
Combine States( Color State( "fuchsia" ), Marker State( Filled Left Triangle ), Labeled State( 1 ), Selected State( 0 ) ),
Combine States( Marker State( "T" ), Color State( -2648061 ), Labeled State( 1 ), Selected State( 1 ) )}
),
sizes( sz )
)
)
);
frame = g30a[FrameBox( 1 )];
nw30a << Close Window;
Code Explanation:
- Open table.
- Color or mark by column.
- Select females.
- Exclude selected rows.
- Clear selection.
- Create new window.
- Add graph box.
- Plot marker segments.
- Get frame box.
- Close window.
Close using SVD
Summary: Runs the computation and reconstruction of matrices using SVD and Sparse SVD techniques, with additional functionality for sparse matrix decomposition and function calls.
Code:
dt1 = Open("data_table.jmp");
mat1 = dt1 << Get As Matrix;
Close( dt1, Nosave );
x = [0 0 1, 1 0 1, 1 0 1, 0 1 1, 0 1 1, 0 0 1, 1 1 1, 0 0 0, 1 1 1, 0 0 0];
{U1, D1, V1} = SVD( x );
{U2, D2, V2} = Sparse SVD( x );
newX2 = U2 * Diag( D2 ) * V2`;
x = [0 0 0, 0 0 1, 1 0 1, 0 0 0, 0 0 0, 0 0 0, 0 1 0, 0 0 1, 1 1 0, 0 1 0];
{U1, D1, V1} = SVD( x );
{U2, D2, V2} = Sparse SVD( x );
newX2 = U2 * Diag( D2 ) * V2`;
x = Diag( 1 :: 500 );
{U, D, V} = Sparse SVD( x );
actD = 500 :: 1;
newX = U * Diag( D ) * V`;
x = Diag( 8 * Identity( 5 ), 5 * Identity( 5 ), 2 * Identity( 5 ) );
{U1, D1, V1} = Sparse SVD( x );
newX1 = U1 * Diag( D1 ) * V1`;
ChrisExample2Fun = Function( {nSing},
{nR, nC, U0, S0, V0, A0, nNonZero, A, Ub, Sb, Vb},
Random Reset( 123456789 );
nR = 1000;
nC = 100;
A0 = J( nR, nC, Random Integer( 0, 1 ) );
{U0, S0, V0} = SVD( A0 );
nNonZero = 50;
S0[nNonZero + 1 :: 100] = 0;
A = U0 * Diag( S0 ) * V0`;
{Ub, Sb, Vb} = Sparse SVD( A, nSing );
If( nSing > 50,
result = S0 || (Sb |/ J( N Rows( S0 ) - N Rows( Sb ), 1, 0 )),
result = S0[1 :: nSing] || Sb
);
);
nSing2 = ChrisExample2Fun( 2 );
nSing4 = ChrisExample2Fun( 4 );
nSing5 = ChrisExample2Fun( 5 );
nSing10 = ChrisExample2Fun( 10 );
nSing15 = ChrisExample2Fun( 15 );
nSing30 = ChrisExample2Fun( 30 );
nSing40 = ChrisExample2Fun( 40 );
nSing50 = ChrisExample2Fun( 50 );
nSing60 = ChrisExample2Fun( 60 );
nSing29 = ChrisExample2Fun( 29 );
Code Explanation:
- Open data table.
- Convert table to matrix.
- Close data_table.jmp data table.
- Define matrix x.
- Perform SVD on x.
- Perform Sparse SVD on x.
- Reconstruct matrix newX2.
- Redefine matrix x.
- Perform SVD on new x.
- Perform Sparse SVD on new x.
- Reconstruct matrix newX2.
- Define diagonal matrix x.
- Perform Sparse SVD on x.
- Adjust diagonal matrix actD.
- Reconstruct matrix newX.
- Define block diagonal matrix x.
- Perform Sparse SVD on x.
- Reconstruct matrix newX1.
- Define function ChrisExample2Fun.
- Call ChrisExample2Fun with argument 2.
- Call ChrisExample2Fun with argument 4.
- Call ChrisExample2Fun with argument 5.
- Call ChrisExample2Fun with argument 10.
- Call ChrisExample2Fun with argument 15.
- Call ChrisExample2Fun with argument 30.
- Call ChrisExample2Fun with argument 40.
- Call ChrisExample2Fun with argument 50.
- Call ChrisExample2Fun with argument 60.
- Call ChrisExample2Fun with argument 29.
Close using Chart
Example 1
Summary: Creates and customizes multiple charts from a data table, showcasing mean height and weight by sex and age, with interactive color overlays.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :sex, :age ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << Show Level Legend( 1 );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << Show Level Legend( 1 );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart( X( :sex, :age ), Y( Mean( :height ) ) );
obj << Show Level Legend( 1 );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << Y[1] << Overlay Color( 41 );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << Y[2] << Overlay Color( Red );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << (Y[1] << Overlay Color( 41 ));
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << (Y[2] << Overlay Color( Red ));
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart(
X( :age, :sex ),
Y( Mean( :height ), Mean( :weight ) ),
Overlay( 1 ),
Y[1] << Overlay Color( 41 ),
Y[2] << Overlay Color( Red )
);
Code Explanation:
- Open data table;
- Create chart with sex and age on X, mean height and weight on Y.
- Show level legend.
- Close dataset without saving.
- Repeat steps 1-4 with age and sex on X.
- Repeat steps 1-4 with sex and age on X, only mean height on Y.
- Repeat steps 1-4 with age and sex on X, color mean height overlay.
- Repeat steps 1-4 with age and sex on X, color mean weight overlay.
- Repeat steps 1-4 with age and sex on X, color mean height overlay.
- Repeat steps 1-4 with age and sex on X, color mean weight overlay.
- Open data table;
- Create chart with age and sex on X, mean height and weight on Y, color overlays.
Example 2
Summary: Creates and customizes multiple charts in JMP, utilizing the Chart() function to visualize mean height and weight by sex and age.
Code:
Open("data_table.jmp");
obj = Chart( X( :sex, :age ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << Show Level Legend( 1 );
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << Show Level Legend( 1 );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart( X( :sex, :age ), Y( Mean( :height ) ) );
obj << Show Level Legend( 1 );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << Y[1] << Overlay Color( 41 );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << Y[2] << Overlay Color( Red );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << (Y[1] << Overlay Color( 41 ));
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart( X( :age, :sex ), Y( Mean( :height ), Mean( :weight ) ), Overlay( 1 ) );
obj << (Y[2] << Overlay Color( Red ));
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart(
X( :age, :sex ),
Y( Mean( :height ), Mean( :weight ) ),
Overlay( 1 ),
Y[1] << Overlay Color( 41 ),
Y[2] << Overlay Color( Red )
);
Code Explanation:
- Open data table;
- Create chart with sex, age on X, mean height, weight on Y.
- Enable level legend.
- Reopen "data_table.jmp" table.
- Create chart with age, sex on X, mean height, weight on Y.
- Enable level legend.
- Close table without saving.
- Reopen "data_table.jmp" table.
- Create chart with sex, age on X, mean height on Y.
- Enable level legend.
- Close table without saving.
- Reopen "data_table.jmp" table.
- Create chart with age, sex on X, mean height, weight on Y.
- Set overlay color for Y1 to 41.
- Close table without saving.
- Reopen "data_table.jmp" table.
- Create chart with age, sex on X, mean height, weight on Y.
- Set overlay color for Y2 to Red.
- Close table without saving.
- Reopen "data_table.jmp" table.
- Create chart with age, sex on X, mean height, weight on Y.
- Set overlay color for Y1 to 41.
- Close table without saving.
- Reopen "data_table.jmp" table.
- Create chart with age, sex on X, mean height, weight on Y.
- Set overlay color for Y2 to Red.
- Close table without saving.
- Reopen "data_table.jmp" table.
- Create chart with age, sex on X, mean height, weight on Y.
- Set overlay colors for Y1 to 41, Y2 to Red.
Example 3
Summary: Creates and customizes multiple charts in JMP, utilizing various data manipulation techniques and visualization options.
Code:
dt = Open("data_table.jmp");
obj = Chart( X( :YearWeek ), Y( Max( :High ), Min( :Low ), Mean( :Close ) ), Range Chart( 1 ), Y[3] << Connect Points( 1 ) );
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart(
X( :Date ),
Y( :High, :Low, :Close ),
Range Chart( 1 ),
Y[3] << {Connect Points( 1 ), Pen Style( 1 )},
SendToReport( Dispatch( {}, "Chart", FrameBox, {Frame Size( 868, 207 ), Line Width Scale( 0.5 )} ) )
);
Close( dt, NoSave );
dt = Open("data_table.jmp");
obj = Chart( X( :Size Co ), Y( Mean( :Name( "Sales ($M)" ) ), Mean( :Name( "Profits ($M)" ) ) ), Range Chart( 1 ) );
Code Explanation:
- Open data table;
- Create a chart with YearWeek on X.
- Plot High, Low, and Close on Y.
- Add a range chart.
- Connect points for Close.
- Close the dataset without saving.
- Reopen "data_table.jmp".
- Create another chart with Date on X.
- Plot High, Low, and Close on Y.
- Add a range chart.
- Connect and style points for Close.
- Adjust frame size and line width.
- Close the dataset without saving.
- Open data table;
- Create a chart with Size Co on X.
- Plot mean Sales and Profits on Y.
- Add a range chart.
Close using Python Send
Summary: Runs the interaction between JMP and Python to send data, execute commands, capture log output, and retrieve updated data.
Code:
iris = Open("data_table.jmp");
Python Send( iris );
commands = "\[
iris = jmp.table('data_table.jmp')
print(iris.name)
]\";
s = Log Capture( Python Submit( commands ) );
iris = Python Get( iris );
Close( iris, nosave );
commands = "\[
jmp.DataTable('Powered by Python', 30)
mydt = jmp.table('Powered by Python')
print(mydt.name)
]\";
s = Log Capture( Python Submit( commands ) );
mydt = Python Get( mydt );
Code Explanation:
- Open data table;
- Send data to Python.
- Define Python commands.
- Execute Python commands.
- Capture log output.
- Retrieve updated data.
- Close dataset without saving.
- Define new Python commands.
- Execute new Python commands.
- Capture new log output.
Close using Informat
Summary: Opens and closes a data table, formatting a date string, sending it to Python, capturing log output, and submitting a print command.
Code:
d2 = Open("data_table.jmp");
L3 = {d1, d2};
Close( d2, nosave );
date = Informat( "07/15/2000 22:01:31", "Format Pattern", "<MM>/<DD>/<YYYY> <hh24>:<mm>:<ss>" );
Python Send( date );
s = Log Capture( Python Submit( "print(date)" ) );
Code Explanation:
- Open data_table;
- Create list with datasets.
- Close data_table dataset without saving.
- Format date string.
- Send date to Python.
- Capture log from Python.
- Submit print command in Python.
- Store log capture result.
Close using Python Connect
Example 1
Summary: Runs Python connectivity and data manipulation tasks, including matrix operations, list definitions, log captures, and dataset interactions.
Code:
Python Connect();
M = [1 2 3, 4 5 6, 7 8 9];
L = {1.2, -2, 3, 124};
L2 = {1, 2 + 3, [11 22]};
s = Log Capture( Python Submit( "print(L2)" ) );
iris = Open("data_table.jmp");
Python Send( iris );
commands = "\[
import jmp
iris = jmp.table('data_table.jmp')
print(iris.__class__)
]\";
s = Log Capture( Python Submit( commands ) );
Close( iris, nosave );
d1 = Open("data_table.jmp");
d2 = Open("data_table.jmp");
L3 = {d1, d2};
Close( d1, nosave );
Close( d2, nosave );
date = Informat( "07/15/2000 22:01:31", "Format Pattern", "<MM>/<DD>/<YYYY> <hh24>:<mm>:<ss>" );
Python Send( date );
s = Log Capture( Python Submit( "print(date)" ) );
dt = Open("data_table.jmp");
Python Send( dt:weight );
w = Log Capture( Python Submit( "print(dt_weight)" ) );
Close( dt );
dt = Open("data_table.jmp");
Python Send( dt:weight, Python Name( "weight" ) );
s = Log Capture( Python Submit( "print(weight)" ) );
Code Explanation:
- Connect to Python.
- Define matrix M.
- Define list L.
- Define list L2.
- Capture log of Python output for L2.
- Open data table;
- Send Iris dataset to Python.
- Execute Python commands on Iris dataset.
- Close Iris dataset without saving.
- Open data table;
- Open data table;
- Define list L3 with datasets.
- Close Big Class dataset without saving.
- Close Iris dataset without saving.
- Convert string to date.
- Send date to Python.
- Capture log of Python output for date.
- Open data table;
- Send weight column to Python.
- Capture log of Python output for weight.
- Close Big Class dataset.
- Open data table;
- Send weight column with name to Python.
- Capture log of Python output for named weight.
Example 2
Summary: Runs Python connectivity and data transfer between JMP and Python, logging output and handling exceptions.
Code:
Python Connect();
Python Send File( "$SAMPLE_DATA/data_table.jmp" );
s = Log Capture( Python Submit( "print(Big_Class)" ) );
If( Host is( Windows ), , );
Close( "data_table", nosave );
Python Send File( "$SAMPLE_DATA/Baseball.jmp", python name( "python_Baseball" ) );
s = Log Capture( Python Submit( "print(python_Baseball)" ) );
If( Host is( Windows ), , );
Close( "Baseball", nosave );
s = Log Capture( Python Submit( "print(python_Baseball2)" ) );
Try( Python Send File( "$SAMPLE_SCRIPTS/Python/JMP2pandas.py" ), exception_msg );
Try( Python Send File( "$SAMPLE_DATA/Non Existing.jmp" ), exception_msg );
Code Explanation:
- Connect to Python.
- Send data_table.jmp to Python.
- Log Python output.
- Check if host is Windows.
- Close data_table without saving.
- Send Baseball.jmp to Python.
- Log Python output.
- Check if host is Windows.
- Close Baseball without saving.
- Log Python output.
- Try sending JMP2pandas.py to Python.
- Try sending Non Existing.jmp to Python.
Example 3
Summary: Runs the establishment of a Python connection, data table operations, and date conversion using JMP's JSL scripting language.
Code:
pythonconn = Python Connect();
M = [1 2 3, 4 5 6, 7 8 9];
L = {1.2, -2, 3, 124};
L2 = {1, 2 + 3, [11 22]};
s = Log Capture( Python Submit( "print(L2)" ) );
iris = Open("data_table.jmp");
pythonconn << Set( iris );
commands = "\[
import jmp
iris = jmp.table('data_table.jmp')
print(iris.__class__)
]\";
s = Log Capture( Python Submit( commands ) );
Close( iris, nosave );
d1 = Open("data_table.jmp");
d2 = Open("data_table.jmp");
L3 = {d1, d2};
Close( d1, nosave );
Close( d2, nosave );
date = Informat( "07/15/2000 22:01:31", "Format Pattern", "<MM>/<DD>/<YYYY> <hh24>:<mm>:<ss>" );
pythonconn << Set( date );
s = Log Capture( Python Submit( "print(date)" ) );
Code Explanation:
- Establish Python connection.
- Define matrix M.
- Define list L.
- Define list L2.
- Capture Python print output.
- Open data table;
- Send data_table dataset to Python.
- Execute Python commands on data_table.
- Close data_table dataset without saving.
- Open data table;
- Open data table;
- Define list L3 with datasets.
- Close Big Class dataset without saving.
- Close data_table dataset without saving.
- Convert string to date.
- Send date to Python.
- Capture Python print output.