I am a beginner to use JMP, and cannot find similar answers to my questions in JMP community. Suppose that I have a data table with several columns, and the user needs to select the column from the data table and then a design matrix will be generated according the selected column. The selected column and the design matrix will be created in a new data table. But this is not enough. If the user want to change the value in the selected column in the new data table, then the design matrix will be updated accordingly. My problems is that I cannot update the design matrix correctly with the code below:
// create a window to select column
// omit some code to create the window
CheckAndConvert = Expr(
selectedColumns = c << Get Items;
// If inputs are valid, we continue
If(N Items(selectedColumns) > 0,
win << Close Window;
A = Column(selectedColumns);
s = A << GetAsMatrix; // extract the select column in s
// create the new data table "Design Matrix"
dt = New Table("Design Matrix");
dt << New Column("slice", Numeric, Values(s[0, 1])); // copy s to the column "slice" in the new data table
// create corresponding columns of design matrix and adding them into the new data table
For( i=1, i<=Col Max(dt:slice), i++,
dt << New Column("X"||Char(i), Numeric,
After Last,
Formula(
If(dt:slice == i, 1,
0
)
)
);
);
);
);
PS: I can get the correct answer when run the code without change the value in the slice column, but I cannot update X columns if I change the value of slice. Note that the number of X columns is the maximum value in the slice column, which is not fixed with different values. In following pictures, I show the examples to select column 1 and column 2 in the test data.
Thanks in advance,
Pulong