I'm a new user trying to learn JMP script. I've a very simple script but encountered an expected result. May be someone can give me a pointer on what did I do wrong here. Thanks in advance. (BTW: I'm using JMP 8.02)
I have a very simple table as below (test1.csv):
| Tool_first | Tool_second | Process_time | Tool_third | Group_1 | Real_beta | Base |
| A | C | 4/3/2011 0:53 | E | A-E | 0.0058 | Y |
| A | C | 4/3/2011 1:08 | E | A-E | 0.0058 | Y |
| A | C | 4/3/2011 5:27 | E | A-E | 0.0058 | Y |
| A | C | 4/3/2011 6:26 | E | A-E | 0.0058 | Y |
| A | D | 4/3/2011 6:39 | E | A-E | 0.0058 | Y |
| A | C | 4/3/2011 6:49 | E | A-E | 0.0058 | Y |
| A | C | 4/3/2011 18:43 | E | A-E | 0.0058 | Y |
| A | C | 4/3/2011 23:42 | E | A-E | 0.0058 | Y |
| A | C | 4/4/2011 5:20 | E | A-E | 0.0058 | Y |
| A | C | 4/4/2011 8:34 | E | A-E | 0.0058 | Y |
| A | C | 4/4/2011 10:43 | E | A-E | 0.0058 | Y |
| A | D | 4/4/2011 11:02 | E | A-E | 0.0058 | Y |
| A | C | 4/4/2011 13:57 | E | A-E | 0.0058 | Y |
| A | C | 4/4/2011 14:28 | E | A-E | 0.0058 | Y |
| A | D | 4/4/2011 16:43 | E | A-E | 0.0058 | Y |
| A | C | 4/4/2011 20:01 | E | A-E | 0.0058 | Y |
| A | C | 4/4/2011 20:17 | E | A-E | 0.0058 | Y |
| A | D | 4/4/2011 21:45 | E | A-E | 0.0058 | Y |
| A | C | 4/5/2011 18:20 | E | A-E | 0.0058 | Y |
| A | D | 4/5/2011 20:02 | E | A-E | 0.0058 | Y |
| A | C | 4/5/2011 20:35 | E | A-E | 0.0058 | Y |
The following script reads in the .csv file and added two more columns to the table based on comparison of one row with its previous row. My script is below
Source_Table=Open ("c:\test1.csv");
Source_Table <<Sort(By(group_1, process_time), order(Ascending), Replace Table);
new column("Inspect_pt",
formula(
if(row()==1,1,
(:group_1[row()] != :group_1[row()-1]),1,
(:group_1[row()] == :group_1[row()-1]),0)));
new column("tool_Change",
formula(
if(row()==1,1,
(:tool_second[row()] != :tool_second[row()-1]),1,
(:tool_second[row()] == :tool_second[row()-1]),0
)
)
);
show(current data table());
/* try to output the value of the last two columns */
for (i=1, i<n_row, i++, row()=i; show(i, row(),:inspect_pt,:tool_Change););
The result table is OK but the last line of the script did not return any result on the two newly created columns. The log window showed the index becomes ::i.
Output table:
[Missing image]
But the log window showed the result of the last two columns not pulled correctly. Did I used the wrong indexing? Log window output here:
Current Data Table:DataTable("test1")
i:1
Row:1
:Inspect_pt[::i]:. <-- this is not correct
:tool_Change[::i]:. <-- this is not correct
i:2
Row:2
:Inspect_pt[::i]:.
:tool_Change[::i]:.
i:3
Row:3
:Inspect_pt[::i]:.
:tool_Change[::i]:.
i:4
Row:4
:Inspect_pt[::i]:.
:tool_Change[::i]:.