Subscribe Bookmark RSS Feed

JSL - Creating a loop for custom distribution report

mvcands

Community Trekker

Joined:

Jun 23, 2015

Hello,

is there a way to create a place holder variable via array that can be substituted into the distribution report layer syntax? The code I have just loops the distribution giving me 10 windows with 10 graphs each with no frame adjustments. I want 1 window with 10 graphs that have had the frame size adjusted.

My Code

/*Run Analyte Array*/

analyteArr = Associative Array(:Analyte) << Get Keys;

For( eachAnalyte = 1, eachAnalyte <= N Items( analyteArr ), eachAnalyte++,

/*Slope Distribution*/

Current Data Table (dtmain);

       dtmain << Distribution(

              Automatic Recalc( 1 ),

              SendToByGroup( {:Analyte == analyteArr[eachAnalyte]} ),

              SendToByGroup(

                     {:Analyte == analyteArr[eachAnalyte]},

                     Continuous Distribution( Column( :Slope ), Vertical( 0 ) )

              ),

              By( :Analyte ),

              SendToByGroup(

                     {:Analyte == analyteArr[eachAnalyte]},

                     SendToReport(

                           Dispatch(

                                  {"Distributions Analyte=" || analyteArr[eachAnalyte], "Slope"},

                                  "Distrib Outlier Box",

                                  FrameBox,

                                  {Frame Size( 550, 50 )}

                           ),

                           Dispatch(

                                  {"Distributions Analyte=" || analyteArr[eachAnalyte], "Slope"},

                                  "Distrib Histogram",

                                  FrameBox,

                                  {Frame Size( 550, 325 )}

                           )

                     )

              )

       )

);

5 REPLIES
txnelson

Super User

Joined:

Jun 22, 2012

Here is your script modified to place all of the distributions into a single window.  I am not clear as to what you mean by "frame size adjusted".  Could you please clarify that?  Is it that you want all of the results shrunk down so they all fit within your display screen?

// Create a display window and place the distributions in it

New Window( "All Together",

// layout the distributions side by side

                H List Box(

/*Run Analyte Array*/

          analyteArr = Associative Array( :Analyte ) << Get Keys;

           For( eachAnalyte = 1, eachAnalyte <= N Items( analyteArr ), eachAnalyte++,

/*Slope Distribution*/

                  Current Data Table( dtmain );

               dtmain << Distribution(

               Automatic Recalc( 1 ),

               SendToByGroup( {:Analyte == analyteArr[eachAnalyte]} ),

               SendToByGroup(

               {:Analyte == analyteArr[eachAnalyte]},

               Continuous Distribution( Column( :Slope ), Vertical( 0 ) )

               ),

               By( :Analyte ),

               SendToByGroup(

               {:Analyte == analyteArr[eachAnalyte]},

               SendToReport(

               Dispatch(

                   {"Distributions Analyte=" || analyteArr[eachAnalyte], "Slope"},

                      "Distrib Outlier Box",

                    FrameBox,

                   {Frame Size( 550, 50 )}

                    ),

              Dispatch(

                   {"Distributions Analyte=" || analyteArr[eachAnalyte], "Slope"},

                       "Distrib Histogram",

                   FrameBox,

                   {Frame Size( 550, 325 )}

                   )

               )

           )

         );

      );

    )

);

Jim
mvcands

Community Trekker

Joined:

Jun 23, 2015

Thank you Jim,

That certainly stops the 10 windows from popping up.

As far as frame size adjuesments, I'm speaking about the part of the code that dictates the frame sizes should be 550, 50 and 550, 325 respectively. Currently, despite having the array variable listed, I'm still getting the default frame sizes of 227, 46 and 277, 110.

txnelson

Super User

Joined:

Jun 22, 2012

The issue is, that you are attempting to change items within a list, and JMP looks at lists and says that a list is just a bunch of stuff, so it isn't going to touch it.  So the method I use to build the lists to the form I want them is to use the Substitute function, and then when I have the list the way I want it, I have JMP evaluate what I have built.  I can not be sure the code below is exactly what you need, but it should be close.  to test out that the Substitute is working correctly, just run eliminate the "Eval" function that surrounds the Substitute command and just run the Substitute command by itself, and it will show the results in the log......

//Create a display window and place the distributions in it

New Window(

      "All Together",

// layout the distributions side by side

      H List Box(

/*Run Analyte Array*/

            analyteArr = Associative Array( :Analyte ) << Get Keys;

            For( eachAnalyte = 1, eachAnalyte <= N Items( analyteArr ), eachAnalyte++,

/*Slope Distribution*/

                  Current Data Table( dtmain );

Eval(

      Substitute(

            Expr(

                  dtmain << Distribution(

                        Automatic Recalc( 1 ),

                        SendToByGroup( {__by__} ),

                        SendToByGroup(

                              {__by__},

                              Continuous Distribution( Column( :Slope ), Vertical( 0 ) )

                        ),

                        By( :Analyte ),

                        SendToByGroup(

                              {__by__},

                              SendToReport(

                                    Dispatch(

                                          {__Dist__, "Slope"},

                                          "Distrib Outlier Box",

                                          FrameBox,

                                          {Frame Size( 550, 50 )}

                                    ),

                                    Dispatch(

                                          {__Dist__, "Slope"},

                                          "Distrib Histogram",

                                          FrameBox,

                                          {Frame Size( 550, 325 )}

                                    )

                              )

                        )

                  );

                  ),Expr(__by__),Parse(":Analyte ==" char(eval( analyteArr[eachAnalyte]))),

                  Expr(__Dist__),"Distributions Analyte=" || char(eval(analyteArr[eachAnalyte])))

                  )

            );

      )

);

Jim
mvcands

Community Trekker

Joined:

Jun 23, 2015

Thank you for the help with this,

This seems to adjust the first of my by variables but not the rest. I think there must be something wrong with the way I'm looping. Not only does it only adjust the first of my by variables, but I just noticed that in the single window I have 100 graphs rather than just the 10 I expected (the 10 x 10 I was getting just all in one window).

txnelson

Super User

Joined:

Jun 22, 2012


You appear to be both looping, and also using  By Grouping.....that maybe what can account for your 10x number of graphs

Jim