cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
rahulsmils
Level III

passing variables to variability chart

Hi all,

I am new to jmp. So please overlook syntax.

I am trying to plot a variability chart as below:

Variability Chart(

       X( :age :height :gender ),

          ......

----------------

age, gender , height are data columns

I want to make arguments to X variable and store it separately.

Something like declaring first

Xarg_list=[:age :height :gender ]

and then using:

Variability Chart(

       X=Xargs_list;

          ......

----------------

So If I want to add new column of weight or delete any column in list of arguments I just need to change Xargs_list

Xarg_list=[:age :height :gender :weight];


Any help with forming correct syntax is welcome.


Thanks


1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: passing variables to variability chart

Here is an example that provides the functionality you are seeking.

 

 

Names Default To Here( 1 );
 
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
 
xlist = {"age", "sex"};
 
dt << Variability Chart(
       Y( :height, :weight ),
       X( Eval( xlist ) ),
       Max Iter( 100 ),
       Conv Limit( 0.00000001 ),
       Number Integration Abscissas( 128 ),
       Number Function Evals( 65536 ),
       Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),
       Std Dev Chart( 1 )
);

 

It appears that you are not aware that you can get JMP to produce the scripts that you desire, by just interactively running the platform you want, and then clicking on the red triangle and go to "Script" and to request to save the script to the Script Window.  It gives you a leg up in creating your scripts.

Jim

View solution in original post

12 REPLIES 12
txnelson
Super User

Re: passing variables to variability chart

Here is an example that provides the functionality you are seeking.

 

 

Names Default To Here( 1 );
 
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
 
xlist = {"age", "sex"};
 
dt << Variability Chart(
       Y( :height, :weight ),
       X( Eval( xlist ) ),
       Max Iter( 100 ),
       Conv Limit( 0.00000001 ),
       Number Integration Abscissas( 128 ),
       Number Function Evals( 65536 ),
       Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),
       Std Dev Chart( 1 )
);

 

It appears that you are not aware that you can get JMP to produce the scripts that you desire, by just interactively running the platform you want, and then clicking on the red triangle and go to "Script" and to request to save the script to the Script Window.  It gives you a leg up in creating your scripts.

Jim
rahulsmils
Level III

Re: passing variables to variability chart

Thanks, actually i figured out a way to do this by grouping columns into a column group first and then using get column group command to get the items.

However there when doing get column groups the order of columns changed from my original assignment.

I will try this one to see if it retains order.

Thanks !

Trung
Level I

Re: passing variables to variability chart

hi Jim,

can you help me to figure out the concern below?

I have 2 data table: table 1 and table 2

i want to run script variability chart for table 2, but need to have variable to get value from table 1, 

below is the example script detail, but it doest not work, please help to review and correct it

 

A={};
Open(table1);
A[i]=column name(i); // want to use A[i] as variable to get value from table 1 ( for for loop to get)
Open(table2);
Variability Chart(
Y(show(A)),    // this one does NOT work, please help
X( :Product, :Mequip, :Source_Lot, :lot_id ))
));

 

 

thanks,

regards,

Trung

txnelson
Super User

Re: passing variables to variability chart

Trung,

The Show() function displays values to the log window.  It does not place the values into the JSL code.  I believe what you want is to use the Eval() function to evaluate the elements in the list "A".

     Eval( A )

 

Jim
Trung
Level I

Re: passing variables to variability chart

hi Jim,

 

thanks for your prompt feedback,

 

i try to take simple script as below but it still doest not work, please advise more

 

A=column name(13);
New window("my report", obj = context box(
Variability Chart(
Y(eval(A)),   // not come out with exact text "
X( :Product, :Mequip, :Source_Lot, :lot_id ))
));
 
 
//it is okay if i change as below
New window("my report", obj = context box(
Variability Chart(
Y(:column name(13)),   //  it is working
X( :Product, :Mequip, :Source_Lot, :lot_id ))
));

 

txnelson
Super User

Re: passing variables to variability chart

Trung,

The reason the Eval() did not work, is that you changed the structure of your code.  In your first example, you placed the column name into a list:

A = {};
A[i] = Column Name(i);

In your second version of the code, you changed the variable "A" to a scaler variable

A=column name(13);

Please take the time to read the Scripting Guide, so you can discover the different code structures within JSL, and how to implement them.  It will make your path into JSL much easier and faster.

     Help==>Books==>Scripting Guide

Jim
Trung
Level I

Re: passing variables to variability chart

thanks Jim, i just figured out why it did work,

below is the mistake

 

Variability Chart(
Y(eval(A[i])),  // A[i] is not work
X( :Product, :Mequip, :Source_Lot, :lot_id ))

 

 

thank you for your advice, i am just new to JMP too, i will learn more on  Scripting Guide.

thank you very much.

Best regards,

Trung

wu
wu
Level III

Re: passing variables to variability chart

Appreciate if you advise the following two questions:

(1). In the following of Bivariate plot, the line By(eval(bylist[2])), didn't work;

how to go around by uisng dynamic variables?

(2). I used lines: r=obj<<report; r[outlinebox(3)]<<close all like this; 

      To minimized the outlinebox, is there way to remove them from the plots, so the Bivariate plot only showed plots without other outlineboxes.

Thanks.

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
xy_list = {"weight","height"};
bylist={"sex","age"};
groupbylist={"sex"};
obj=dt << Fit Group(Bivariate(
Y(Eval(xy_list[2] )),
X(Eval(xy_list[1])),
By(eval(bylist[2])); // this line didn't work, has to use By(:age);
Group by(eval (bylist)),
Fit Spline(0.1,Standardized, {Line Width(3)}),
Std Dev Chart(0 ),
SendToReport(
Dispatch(
{},
"Bivar Plot",
FrameBox,{Framesize( 200, 200 ),YAxis( Show Major Grid ),
Row Legend(:sex,Color(1), Color Theme("JMP Default"),Marker(0), Marker Theme(""),
Continuous Scale(0), Reverse Scale(0), Excluded Rows(0))})
),Show Points( 1 )
),<<{Arrange in Rows(4)},);
r=obj<<report;
r[outlinebox(3)]<<close all like this;
ms
Super User (Alumni) ms
Super User (Alumni)

Re: passing variables to variability chart

1) It should work as is with comma instead of semicolon after By(...) argument. 

 

2) Try this to delete all outlineboxes except the ones holding the graphs

(r << xpath("//IfBox/OutlineBox")) << delete;