cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
Sebastienlg
Level II

JMP SCRIPT: Creation of a graph based on a user selection variable

Hi all,

 

I would like to create a graph based on a user filter selection.

However, JMP doesn't recognize the variable "Y" choosen by the user, and an error occurs.

Here is my code:

Y = concat(Y,"  (ppm)");

graph = RAW_DATA_TABLE << 
				Control Chart Builder(
					Size( 534, 450 ),
					Show Two Shewhart Charts( 0 ),
					Show Control Panel( 0 ),			
					Sort by Row Order( 1 ),
					Variables( Y( :"Y" ),Subgroup( :Numéro de lot ), Phase(:"Period")),	
					Get Limits(LIMIT_TABLE),
				)

Does anyone have a suggestion to help me out with the naming of the Y ?

Thanks a lot,

Sébastien

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: JMP SCRIPT: Creation of a graph based on a user selection variable

If you are sure that the column exists you could try wrapping the Y variable (I would use more descriptive variable name here) to Eval 

y_column = Concat(Y, "  (ppm)");

graph = RAW_DATA_TABLE << Control Chart Builder(
	Size(534, 450),
	Show Two Shewhart Charts(0),
	Show Control Panel(0),
	Sort by Row Order(1),
	Variables(Y(Eval(y_column)), Subgroup(:Numéro de lot), Phase(:"Period")),
	Get Limits(LIMIT_TABLE),
);
Names Default To Here(1);
y_col = "Weight";
dt = Open("$SAMPLE_DATA/Quality Control/Coating.jmp");
dt << Control Chart Builder(Variables(Y(Eval(y_col)), Subgroup(:Sample)));

 

-Jarmo

View solution in original post

7 REPLIES 7
jthi
Super User

Re: JMP SCRIPT: Creation of a graph based on a user selection variable

I'm not exactly sure what you are trying to do on line 1. Trying to build the column name based on something? How is Y chosen by user? Where does the "    (ppm)" come from?

-Jarmo
Sebastienlg
Level II

Re: JMP SCRIPT: Creation of a graph based on a user selection variable

The user selection is based on a list. However the selection made by the user from a list doesn't match with the datatable and I need to concatenate with "  (ppm)" in order to have the same variable name...

Then, I want to make the graph based on the "Y" concatenate with "ppm".

However, the "Y" is not recognize by the graph builder... 

Do you have any suggestion to help me out with the naming of the Y ?

 

Thanks a lot for your answer

 

jthi
Super User

Re: JMP SCRIPT: Creation of a graph based on a user selection variable

If you are sure that the column exists you could try wrapping the Y variable (I would use more descriptive variable name here) to Eval 

y_column = Concat(Y, "  (ppm)");

graph = RAW_DATA_TABLE << Control Chart Builder(
	Size(534, 450),
	Show Two Shewhart Charts(0),
	Show Control Panel(0),
	Sort by Row Order(1),
	Variables(Y(Eval(y_column)), Subgroup(:Numéro de lot), Phase(:"Period")),
	Get Limits(LIMIT_TABLE),
);
Names Default To Here(1);
y_col = "Weight";
dt = Open("$SAMPLE_DATA/Quality Control/Coating.jmp");
dt << Control Chart Builder(Variables(Y(Eval(y_col)), Subgroup(:Sample)));

 

-Jarmo
Sebastienlg
Level II

Re: JMP SCRIPT: Creation of a graph based on a user selection variable

Great ! this is exactly what I need. 

Now, I want to make a column selection based on the y_column to delete columns not desired by the user:

a = {Eval(y_colums)};
	limit_table << Invert Column Selection( a );
	limit_table << Delete Columns;

However, it does not work.

Do you have any idea to help me?

thank you

sebastien

Re: JMP SCRIPT: Creation of a graph based on a user selection variable

The Column Dialog() command allows users to select columns for roles in later analysis. You should be able to delete/modify from the example from the scripting index to get what you need, i.e., just keep the things relating to the "Y" column.

Jed_Campbell_0-1678729722929.png

 

pmroz
Super User

Re: JMP SCRIPT: Creation of a graph based on a user selection variable

Line 1 of your code is not a good practice - you are redefining Y in terms of itself.

Try this:

raw_data_table = New Table( "Test",Add Rows( 4 ),
	New Column( "Col1  (ppm)", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [1, 2, 3, 4] ) ),
	New Column( "Numéro de lot", Character, "Nominal",
		Set Values( {"a", "a", "b", "b"} ) ),
	New Column( "Period", Numeric, "Continuous", Format( "Best", 12 ),
		Set Values( [1, 2, 3, 4] ) )
);

Y = "Col1";		// Selected from your dialog box
ycol = Y || "  (ppm)";

graph = RAW_DATA_TABLE << 
				Control Chart Builder(
					Size( 534, 450 ),
					Show Two Shewhart Charts( 0 ),
					Show Control Panel( 0 ),			
					Sort by Row Order( 1 ),
					Variables( Y( column(RAW_DATA_TABLE, ycol) ),Subgroup( :Numéro de lot ), Phase(:"Period")),	
//					Get Limits(LIMIT_TABLE),
				);

 I commented out the reference to limit_table as I didn't have that data.  

pmroz
Super User

Re: JMP SCRIPT: Creation of a graph based on a user selection variable

pmroz_0-1678800356858.png