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

Passing column name to function as variable in JMPPRO 14.3

Very simply, I am trying to modularize some variability charts. In total there are 3-4 different parameters that I want to plot these charts for, so I need to pass in a key to the function to tell it which column to plot and let it set up some specific handling of that column. Namely, what sort of transformation that column needs to undergo as part of the plot operation.

 

The way I've started is to pass in a string and then use a set of conditionals to specify the name of the column to be transformed (colname) and then the striong to be applied to the transformation (yname).

 

I've tried several methods to do this and no matter what solution I use, I cannot get the plot to work correctly. Hard-coding the Y of the variability chart always works correctly for the given filters so I know there is data present, I just can't seem to select it using my variable approach. This is what I've tried for the var chart Y-line so far:

 

  1. Y( Transform Column( yname, Formula( Column(colname) ) ) ),
    1. JMP Alert: Invalid Argument (dialog box)
    2. Group has no data because all rows have missing values or are excluded (log window)
  2. Y( Transform Column( yname, Formula( Column(dt,colname) ) ) ),
    1. JMP Alert: Invalid Argument (dialog box)
    2. Group has no data because all rows have missing values or are excluded (log window)
  3. Y( Transform Column( yname, Formula( Column( As Column(colname)) ) ) ),
    1. JMP Alert: Unresolved Column 256 times (dialog box)
    2. "Invalid argument 256 times, One column or group has no data because all rows have missing values or are excluded (log)
  4. Y( Transform Column( yname, Formula( Column( As Column(dt,colname)) ) ) ),
    1. JMP Alert: Scoped data table access requires a data table column or variable 256 times (dialog box)
    2. Invalid argument 256 times, One column or group has no data because all rows have missing values or are excluded (log)
  5. Y( Transform Column( yname, Formula( As Column(colname) ) ) ),
    1. JMP Alert: Unresolved Column 267 times (dialog box)
    2. (no log errors)
  6. Y( Transform Column( yname, Formula( As Column(dt,colname) ) ) ),
    1. JMP Alert: Scoped data table access requires a data table column or variable 267 times (dialog box)
    2. (no log errors)

If it isn't obvious by my attempts, it still isn't clear to me what the difference between As Column() and Column() are. I've seen solutions on forums with either and both so I tried them all and got nowhere. The only clue I see is that when As Column() is used independently, I get a different number of access violations (267) as compared to the case where it's wrapped by Column() (256). I do know that 267 is the "correct" number of rows to be returned by that filter because hard-coding the column name in the transformation formula correctly plots 267 rows.

 

Additionally I've tried setting the colname variable directly to the column (colname = :R and colname = ":R") and various combinations of using those directly and/or wrapping them in combinations of the Column() and As Column() functions as well with no success.

 

Can anyone see what I'm doing wrong here?

 

Note: This exact code is untested, var names have been genericized.

//
// Build plot functions
//
var_chart = Function( {dutname, ytype, stressname, bias, ver},
	{chart, ax_min, ax_max, ax_step, len, colname, yname},
    
ax_min = 0;
ax_max = 1;
ax_step = 0.1;
If(ytype == "r", (colname = "R"; yname = "R [Ω]"));
If(ytype == "l", (colname = "L"; yname = "L [H]"));
If(ytype == "c", (colname = "C"; yname = "C [F]")); If(stressname == "s1", len = 1.1); If(stressname == "s2", len = 2.2); If(stressname == "s3", len = 3.3); chart = Variability( Y( Transform Column( yname, Formula( As Column(colname) ) ) ), X( :X1, :X2, :X3, :X4 ), Analysis Type( "Choose best analysis (EMS REML Bayesian)" ), Std Dev Chart( 0 ), Points Jittered( 1 ), Show Box Plots( 1 ), <<Set Scale( Normal, Simultaneous ), Confidence Interval Method( Wald ), Automatic Recalc( 1 ), Where( :Dutname == dutname & :Len == len & :Bias == bias ), SendToReport( Dispatch( {"Variability Gauge"}, "2", ScaleBox, {Scale( "Lin" ), Min(ax_min), Max(ax_max), Inc(ax_step), Minor Ticks( 1 )} ) ) ); return(chart) );
3 REPLIES 3
jthi
Super User

Re: Passing column name to function as variable in JMPPRO 14.3

Break your problem into smaller parts. Start with something very simple like (my syntax might not work for JMP14 as I'm using JMP17)

 

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Variability Data/2 Factors Crossed.jmp");

yname = "namechange";
col_name = "Measurement";

var_chart = Variability Chart(
	Y(Transform Column(yname, Formula(colname))),
	X(:Operator, :part#)
);

You can already get your issues with this type of script but it is much easier to test with something like this.

 

 

With script like this I would most likely resort to using Eval(EvalExpr()) because it allows me to do something like below (I can see the expression which will be evaluated if I just run EvalExpr() part)

jthi_0-1684574450780.png

If you are using Transform just for renaming the Y-axis column, there might be easier options than using Transform Column.

 

After you get that part working then it is time to start tackling the filters or scaling but don't do these at the same time.

-Jarmo
TheSource
Level II

Re: Passing column name to function as variable in JMPPRO 14.3

Thanks for the reply. I have already individually validated all of the other components of the code so I wasn't concerned about the additional complexity.

 

The first snipped of code that you posted doesn't work in JMP14. The error message is "One column of By group has no data, because all rows have missing values or are excluded.

 

I did find a solution by wrapping the variability chart function call with Eval(EvalExpr()) and then wrapping the column name inside of the transformation in Expr(Name Expr(AsColumn())).

txnelson
Super User

Re: Passing column name to function as variable in JMPPRO 14.3

The following will work in JMP 14

Names Default To Here( 1 );

dt = Open(
	"$SAMPLE_DATA/Variability Data/2 Factors Crossed.jmp"
);

yname = "namechange";
col_name = "Measurement";

Variability Chart(
	Y( Transform Column( yname, Formula( as column(col_name)) ) ),
	X( :Operator, :part# )
);
Jim