cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Arkawa
Level III

Script to rename a table coming from the Contingency Table option : Make Into Data Table

Hi all,

 

I made a code to obtain a data table with contingency table tool information, unfortunately, the table issued is named "Untitled xxx". I would like to know if by scripting it will be possible either to select the last table created and change its name, or to select the table containing Untitled in its name, to rename it at the end ?

 

The objective is to close the table at each launch if the script to avoid having several tables.

 

I tried to use Current Data Table () function but it does not work properly (another table is selected).

 

The code section :

Contingency(
	Y( :"Pass/Fail"n ),
	X( :Task ),
	Contingency Table(
		Count( 1, Format( "Fixed Dec", 2, 0 ) ),
		Total %( 1, Format( "Fixed Dec", 2, 2 ) ),
		Col %( 1, Format( "Fixed Dec", 2, 2 ) ),
		Row %( 1, Format( "Fixed Dec", 2, 2 ) ),
		Expected( 0, Format( "Best", 3 ) ),
		Deviation( 0, Format( "Best", 3 ) ),
		Cell Chi Square( 0, Format( "Fixed Dec", 2, 4 ) ),
		Col cumulative( 0, Format( "Fixed Dec", 2, 0 ) ),
		Col cumulative %( 0, Format( "Fixed Dec", 2, 2 ) ),
		Row cumulative( 0, Format( "Fixed Dec", 2, 0 ) ),
		Row cumulative %( 0, Format( "Fixed Dec", 2, 2 ) )
	),
	Mosaic Plot( 0 ),
	Make Into Data Table,
);

Thank you !

 

Best regards

4 ACCEPTED SOLUTIONS

Accepted Solutions
jthi
Super User

Re: Script to rename a table coming from the Contingency Table option : Make Into Data Table

I'm not sure if you can do if within just that one command, but I think you can send the Make Into Data Table message to the CrossTabBox

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
cont = dt << Contingency(
	Y(:Age),
	X(:sex),
	Contingency Table()
);

dt_cont = Report(cont)[OutlineBox("Contingency Table"), CrossTabBox(1)] << Make Into Data Table;

and for that you can get the reference

-Jarmo

View solution in original post

Arkawa
Level III

Re: Script to rename a table coming from the Contingency Table option : Make Into Data Table

The code works as follows : 

 

dt_cont << Set Name("Contingency Table");

Thank you !

View solution in original post

txnelson
Super User

Re: Script to rename a table coming from the Contingency Table option : Make Into Data Table

You need to use

dt_cont << set Name("Contingency Table")
Jim

View solution in original post

jthi
Super User

Re: Script to rename a table coming from the Contingency Table option : Make Into Data Table

Few different options doing this. Here is one using loop to go over different references you get from Contingency platform when using By column

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
conts = dt << Contingency(
	Y(:height),
	X(:age),
	By(:sex)
);

Show(conts); // two references

dt_conts = {};

For Each({cont, idx}, conts,
	dt_cont = Report(cont)[OutlineBox("Contingency Table"), CrossTabBox(1)] << Make Into Data Table;
	groupname = Word(-1, Report(cont)[OutlineBox(1)] << get title, "=");
	dt_cont << Set Name("Contingency Table " || groupname);
	Insert Into(dt_conts, dt_cont);
);
-Jarmo

View solution in original post

8 REPLIES 8
jthi
Super User

Re: Script to rename a table coming from the Contingency Table option : Make Into Data Table

I'm not sure if you can do if within just that one command, but I think you can send the Make Into Data Table message to the CrossTabBox

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
cont = dt << Contingency(
	Y(:Age),
	X(:sex),
	Contingency Table()
);

dt_cont = Report(cont)[OutlineBox("Contingency Table"), CrossTabBox(1)] << Make Into Data Table;

and for that you can get the reference

-Jarmo
Arkawa
Level III

Re: Script to rename a table coming from the Contingency Table option : Make Into Data Table

Hi jthi,

 

Thanks for your prompt answer. However, even if I add :

 

dt_cont << Data Table(Name("Contingency Table"))

I obtain the same result, the new data table is named as "Untitled XXX" (without code error).

 

Best regards

Arkawa
Level III

Re: Script to rename a table coming from the Contingency Table option : Make Into Data Table

The code works as follows : 

 

dt_cont << Set Name("Contingency Table");

Thank you !

txnelson
Super User

Re: Script to rename a table coming from the Contingency Table option : Make Into Data Table

You need to use

dt_cont << set Name("Contingency Table")
Jim
Arkawa
Level III

Re: Script to rename a table coming from the Contingency Table option : Make Into Data Table

Hi all,

 

I would like to upgrade my code, when I generate the Contingency Analysis, now I have two analyzes one named "1" and the second "2", I would like to make the same way to obtain two data tables at the end.

 

I tried to change the code as follows:

dt << Contingency(
    Y( :"Pass/Fail"n ),
    X( :Task ),
    By( :X ),
);

dt_cont1 = Report("Contingency Analysis of Pass/Fail By Task X=1")[OutlineBox("Contingency Table")][CrossTabBox(1)] << Make Into Data Table;
dt_cont1 << Set Name("Contingency Table 1");


dt_cont2 = Report("Contingency Analysis of Pass/Fail By TaskX=2")[OutlineBox("Contingency Table")][CrossTabBox(1)] << Make Into Data Table;
dt_cont2 << Set Name("Contingency Table 2");

But it didn't work and I don't find the solution.

 

Thank you in advance !

 

Best regards

Arkawa
Level III

Re: Script to rename a table coming from the Contingency Table option : Make Into Data Table

The error message is :

 

"object not subscriptable at row XXX in access or evaluation of 'Report("Contingency Analysis of Pass/Fail By Task X=1")[/*###*/Outline Box("Contingency Table")]', Report("Contingency Analysis of Pass/Fail By Task X=1")[/*###*/Outline Box("Contingency Table")]

jthi
Super User

Re: Script to rename a table coming from the Contingency Table option : Make Into Data Table

Few different options doing this. Here is one using loop to go over different references you get from Contingency platform when using By column

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
conts = dt << Contingency(
	Y(:height),
	X(:age),
	By(:sex)
);

Show(conts); // two references

dt_conts = {};

For Each({cont, idx}, conts,
	dt_cont = Report(cont)[OutlineBox("Contingency Table"), CrossTabBox(1)] << Make Into Data Table;
	groupname = Word(-1, Report(cont)[OutlineBox(1)] << get title, "=");
	dt_cont << Set Name("Contingency Table " || groupname);
	Insert Into(dt_conts, dt_cont);
);
-Jarmo
Arkawa
Level III

Re: Script to rename a table coming from the Contingency Table option : Make Into Data Table

Waaaaah jthi, thank you !

It is very complicated ^^' but it works as well

Thank you so much !