While trying to get my solution working for Is there a faster way to loop? I came across an issue where first row of my data wasn't looking correct (in fact the issue was for whole first group).
Names Default To Here(1);
dt = New Table("Untitled 5",
Add Rows(8),
Compress File When Saved(1),
New Column("Vals", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4, 1, 2, 3, 4])),
New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4, 1, 2, 3, 4])),
New Column("Column 1 1", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4, 1, 2, 3, 4])),
New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([1, 2, 3, 4, 1, 2, 3, 4])),
New Column("A", Character, "Nominal", Set Values({"A", "A", "A", "A", "B", "B", "B", "B"})),
New Column("B", Character, "Nominal", Formula(Col Mean(:Vals, :A)))
);
dt << New Column("Column 3", Numeric, Continuous, <<Set Each Value(Col Mean(:Column 1, :A)));
Column(dt, "Column 1") << Set Each Value(Col Mean(:Column 1, :A));
// workaround
dt << Add Row(1, At Start);
Column(dt, "Column 1 1") << Set Each Value(Col Mean(:Column 1 1, :A));
dt << Delete Rows(1);
Show(Col Mean(:Column 2));
Show(Mean(dt[0, "Column 2"]), Mean(dt[[2 3 4], "Column 2"]));
Show(:Column 1 << get values);
Show(:Column 3 << get values);
Show(Mean([1 2 3 4]));
Show(Mean([2.5 2 3 4]));
Show(Mean([2.5 2.875 2.875 2.875]));
jthi_1-1678901605470.png
To me it looks like Col Mean is being calculated to the first row and then mean for rest of the group one is calculated using this already replaced value. There is a workaround where you can add empty row as first in data table -> use << set each value -> remove that first row.
I have already opened a ticket regarding this issue (TS-00036082) and JMP support has submitted bug report to development team, but I wanted to make it more visible. I might have to check some of my older script that there aren't any places where I use << Set Each Value() to replace existing values (usually I use it during column creation) when using statistical col functions.
-Jarmo