Hi All,
I'm noticing that the Distribution platform doesn't seem to accept column references in the same way that Graph Builder does, for example.
I have code where I am referencing different columns within a data table using the Column(dtname, number) format. For example, this is a bit of code where I do it with GB and it works just fine:
Graph Builder(
Size( 500, 350 ),
Show Control Panel( 0 ),
Variables(
X( Column( dt_results, NNxcol ) ),
Y( Column( dt_results, NNYCol + N Items( NNXList ) ) ),
Y( Column( dt_results, NNYCol + 1 + N Items( NNXlist ) ), Position( 1 ) ),
Y( Column( dt_results, NNYCol + 2 + N Items( NNXList ) ) )
),
Elements(
Position( 1, 1 ),
Points( X, Y( 1 ), Y( 2 ), Legend( 8 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Legend( 9 ) )
),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 10 ) ), Smoother( X, Y, Legend( 11 ) ) ),
SendToReport(
Dispatch(
{},
"graph title",
TextEditBox,
{Set Text( NNYList[NNYCol] || " Stats vs. " || NNXList[NNxcol] )}
),
Dispatch( {}, "Y title", TextEditBox, {Set Text( NNYList[NNYCol] || " Train & Valid" )} )
)
)
However, when I try to do something similar in the Distribution platform, nothing happens, and I think it's because the Continuous Distribution() call doesn't seem to like referencing a column this way. It seems to like referencing the column as Column(column name).
Distribution(
Continuous Distribution( Column( dt_results, NNYCol + NNcolshift ), Quantiles( 0 ) ),
Continuous Distribution( Column( dt_results, NNYCol + 1 + NNcolshift ), Quantiles( 0 ) ),
Continuous Distribution( Column( dt_results, NNYCol + 2 + NNcolshift ), Quantiles( 0 ) )
)
I want to use variables when I call the platform because it's more flexible in the code rather than hard-coding in the column name itself. Any idea why the Distribution platform behaves differently or how to correctly reference the column so I get the intended output?
Any thoughts/comments are appreciated.
Thanks!,
DS
You can just send a message to your data table and remove the table reference in the Column() function. As for why it doesn't like the syntax of the script that works with Graph Builder, I don't know.
dt_results << Distribution(
Continuous Distribution( Column( NNYCol + NNcolshift ), Quantiles( 0 ) ),
Continuous Distribution( Column( NNYCol + 1 + NNcolshift ), Quantiles( 0 ) ),
Continuous Distribution( Column( NNYCol + 2 + NNcolshift ), Quantiles( 0 ) )
)
You can use fun and confusing syntax like this
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
col1 = "height";
col2 = "weight";
dist = dt << Distribution(
Continuous Distribution(Column(Column(dt, col1)), Quantiles(0)),
Continuous Distribution(Column(Column(dt, col2)), Quantiles(0))
);
or this
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
col1 = "height";
col2 = "weight";
Eval(EvalExpr(
dist = dt << Distribution(
Continuous Distribution(Column(Eval(col1)), Quantiles(0)),
Continuous Distribution(Column(Eval(col2)), Quantiles(0))
);
));
Edit: Eval(EvalExpr()) is unnecessary in the above script. I left it there by accident when testing out different options (was playing around with Name Expr(AsColumn())).
Or just one of these:
dt = Open("$SAMPLE_DATA/Big Class.jmp");
col1 = "height";
col2 = "weight";
Distribution(Continuous Distribution(Column(Eval(col1))));
colList={col1,col2};
Distribution(column(EvalList(colList)));
Further details can be found here:
https://www.pega-analytics.co.uk/blog/handling-lists-of-columns/ (thanks @Ressel
and here:
https://community.jmp.com/t5/Discussions/Updating-column-list-box-using-list-stored-in-variable-not/m-p/687314/highlight/true#M87301
The confusion arises because (well known) Column is used as a name for a named argument in Continuous Distribution .Many Jmp users will assume that it was the Column() function and use it accordingly.
Same for Data Table() in Col List Box : Updating column list box using list stored in variable not working as expected. Is this how it is meant to be?
Hi All,
Thanks for some quick feedback and help on this. I ended up going with a blend of @mmarchandTSI and @jthi 's second suggestion. Unfortunately, the suggestion from @mmarchandTSI didn't end up working by itself, the platform still didn't like the variables for the column number within the Column() reference. However, if I then did an Eval() on the number variables within the Column() reference, then it worked out just fine. So, using Column(Eval()), as @jthi and @hogi did, ended up working as intended.
Thanks for the great suggestions!,
DS