Subscribe Bookmark RSS Feed

JSL Loop

bluenose

Community Trekker

Joined:

Sep 11, 2011

Hello,

I have a dataset contianing 41 variables. I need to plot each of the first 40 against the last one, for example, to make 40 box plots, or jitter plots.

To create a nice fully featured plot via the create graph menu it's easy and even fun. I know how to save the script of what I did, but what I don't know, is how to write a loop that will take each iteration another variable and replace it in my original graph code. In other words, if I have 20 lines of code, I want a loop that will run the same code over and over again, and will change only the place where I define the dependent variable. In addition, I need a nice way of showing the results (40 windows are not practical), so I thought maybe to save each one as a JPG pre moving to next iteration. Is this possible with JMP ?

Thank you  !

2 REPLIES
mewing

Community Trekker

Joined:

Jun 23, 2011

Howdy!  What you want to do is fairly easy.

First, in your script you will want to define the current data table:

cd = Current Data Table();

Now, get the list of column names:

column_names = cd << Get Column Names;

Now, there are multiple ways to do the next part, but I find this to be the easiest.  You'll want to start a text string that we will eventually parse and evaluate.  The first part is to create a new window.

nw = "New Window(\"Graphs\",

     randomname = V List Box(";

Now we can write the loop which will insert your custom code with one minor alteration.  I'll assume you know how to use a JMP 'for' loop - I'm just going to iterate over all but the last column in the table.

for(i=1,i<=length(column_names)-1,i++,

nw = nw || "PUT YOUR CUSTOM CODE HERE*" || ",";

);

*In your custom code, where you define the dependent variable, remove it and replace it with :Name(\"" || column_name || "\")

What this will do is paste in the text name of each dependent variable you have within the custom script you've written.

Finally, we need to finish the new window we started earlier:  The first line finishes writing the code to make the new window, the second line first parses the text to make it code and then evaluates the code contained in nw.

nw = nw || "));";

eval(parse(nw));

That should do it - let me know if you have any questions or need specific help!

bluenose

Community Trekker

Joined:

Sep 11, 2011

Hi,

thanks for your attempt to help. Unfortunatelly, I am still not familier enough with JSL (when I'll have a break from work I'll get deep into it), and I got troubles with the brackets and all that, so your suggestion didn't work, I probably had one sign in the wrong place.

My original code is:

Graph Builder(

Size( 880, 750 ),

Show Control Panel( 0 ),

Variables(

  X( :Cutoff, Size( 0, 21 ) ),

  Y( :S1, Size( 0, 22 ) ),

  Color( :Cutoff )

),

Elements(

  Points( X, Y, Color, Legend( 1 ), Jitter( 1 ) ),

  Line(

   X,

   Y,

   Color,

   Legend( 2 ),

   Row order( 0 ),

   Error Bars( "Confidence Interval" ),

   Summary Statistic( "Mean" )

  )

),

SendToReport( Dispatch( {}, "Graph Builder", FrameBox, {Marker Size( 5 )} ) )

);

Can you please help me to wrap it with the loop ?

Cheers !