Hi,
I have two identical tables of test results from two different times.
Is there a simple function that can calculate the difference for each case?
And this would be the idea using data table subscripting and creating a new table
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = Open("$SAMPLE_DATA/Big Class Families.jmp");
dt2 << Sort(By(:sports),Replace Table,Order(Ascending),Copy formula(0)); // demo purposes
If(N Rows(dt) != N Rows(dt),
Throw("Rows do not match");
);
cont_cols1 = dt << Get Column Names(Continuous, "String");
cont_cols2 = dt2 << Get Column Names(Continuous, "String");
If(cont_cols1 != cont_cols2,
Throw("Columns do not match");
);
res = dt[0, cont_cols1] - dt2[0, cont_cols2];
dt_res = As Table(res);
For Each({colname, idx}, cont_cols1,
Column(dt_res, idx) << Set Name(colname);
);
I'm not sure what the identical means here (in identical tables the difference would be 0?). Do you have same column names? Where should the result be stored? What is "each case", difference of columns?
Hi,
Thanks for you reply.
Labels of Colums and Rows are the same. Values are differents. I want to calculate the drift of each cell (sorry not each case).
Not sure where the results should be calculated, so I will demonstrate fairly simple process which will create new table with the result
Join tables together using By Row Number
Pick columns in pairs and create the formulas
And you should end up with the result columns as formulas
Here is a simple script that will take 2 identical all numeric tables....identical in column names and number of rows, and create a new table that is the difference between the 2 tables
names default to here(1);
dt1 = data table("name of first table");
dt2 = data table("name of second table");
// Create a new table from one of the 2 tables
dt3 = dt1 << subset( selected rows(0), selected columns(0));
// Replace cell values in the third data table with the
// differences between table 1 and table 2
dt3[0,0] = dt1[0,0]-dt2[0,0];
And this would be the idea using data table subscripting and creating a new table
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
dt2 = Open("$SAMPLE_DATA/Big Class Families.jmp");
dt2 << Sort(By(:sports),Replace Table,Order(Ascending),Copy formula(0)); // demo purposes
If(N Rows(dt) != N Rows(dt),
Throw("Rows do not match");
);
cont_cols1 = dt << Get Column Names(Continuous, "String");
cont_cols2 = dt2 << Get Column Names(Continuous, "String");
If(cont_cols1 != cont_cols2,
Throw("Columns do not match");
);
res = dt[0, cont_cols1] - dt2[0, cont_cols2];
dt_res = As Table(res);
For Each({colname, idx}, cont_cols1,
Column(dt_res, idx) << Set Name(colname);
);
Thank you for your help. It works.