回复:按组堆叠在 JSL 索引列中(传感器数据和资产)也许是这样的:
Names Default To Here( 1 );
//dt=open("input_example.jmp");
//Stack data table
Data Table( "input_example.jmp" ) << Stack(
columns( Column Group( "A sensors" ), Column Group( "B sensors" ) ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ),
Output Table( "Stacked Data" )
);
//Text to columns
Data Table( "Stacked Data" ) << Text to Columns(
columns( :Label ),
Delimiters( " " )
);
//Delete column: Label 2
Data Table( "Stacked Data" ) << Delete Columns( :Label 2 );
//Change column name: Label 1 → Asset
Data Table( "Stacked Data" ):Label 1 << Set Name( "Asset" );
//Change column name: Label 3 → Sensor
Data Table( "Stacked Data" ):Label 3 << Set Name( "Sensor" );
//New column: Column 6
Data Table( "Stacked Data" ) << New Column( "Stddev of Sensor by Asset by Index",
Numeric,
"Continuous",
Format( "Best", 12 )
);
//Change column formula: Stddev of Sensor by Asset by Index
Data Table( "Stacked Data" ):Stddev of Sensor by Asset by Index <<
Set Formula( Col Std Dev( :Data, :Asset, :Index ) );
//Report snapshot: Stacked Data - Graph Builder
Data Table( "Stacked Data" ) << Graph Builder(
Size( 517, 450 ),
Show Control Panel( 0 ),
Variables(
X( :Index ),
Y( :Stddev of Sensor by Asset by Index ),
Overlay( :Asset )
),
Elements( Line( X, Y, Legend( 7 ) ), Points( X, Y, Legend( 8 ) ) )
);
我使用 JMP 17 中的 Worflow Builder 来“编写”这个脚本。
关键是在公式中使用“by”参数。

这让我可以完全堆叠数据,使数据具有完整的层次结构,所有数据都在一列中。
然后我按资产和索引获取整列数据的标准偏差。 这让我制作了这张图:

回复:按组堆叠在 JSL 索引列中(传感器数据和资产)这是一个好方法。 然而,完全堆叠的表格存在局限于那些具有“by”参数的公式的问题。
例如,如果我想做一个公式:(sensor 1 - sensor 2) / sensor 3,将需要堆叠表。
回复:按组堆叠在 JSL 索引列中(传感器数据和资产)删除回复以避免未来读者的混淆
回复:按组堆叠在 JSL 索引列中(传感器数据和资产)如果您有层次结构表,一种选择是采用纯 JSL 路线。 代码也许能够自我解释:
Names Default To Here(1);
dt_hier = Open("$DOWNLOADS/hierarchy_example.jmp");
dt_input = Open("$DOWNLOADS/input_example.jmp");
// some assumptions:
// both parents will have same amount of columns
new_col = dt_hier << New Column("Data Cols", Character, Nominal, << Set Each Value(
Regex(:Child column, "sensor \d")
));
data_cols = Associative Array(new_col) << get keys;
dt_hier << Delete Column(new_col);
dt_collector = New Table("data",
New Column("Index", Numeric, Ordinal),
New Column("Group", Character, Nominal)
);
For Each({data_col}, data_cols,
dt_collector << New Column(data_col, Numeric, Continuous)
);
Summarize(dt_hier, parents = by(:Parent));
For Each({parent}, parents,
parent_rows = Loc(dt_hier[0, "Parent"], parent);
parent_cols = dt_hier[parent_rows, "Child column"];
parent_data = dt_input[0, parent_cols];
non_missing_idx = Loc(parent_data);
row_count = N Items(non_missing_idx) / n cols(parent_data);
parent_data_clean = Shape(parent_data[non_missing_idx], row_count);
first_row = N Rows(dt_collector) + 1;
last_row = first_row + row_count - 1;
dt_collector << Add Rows(row_count);
dt_collector[Index(first_row, last_row), "Index"] = Index(1, row_count)`;
dt_collector[Index(first_row, last_row), "Group"] = Repeat({parent}, row_count);
dt_collector[Index(first_row, last_row), data_cols] = parent_data_clean
);

这里做了很多假设,没有适当的错误处理
回复:按组堆叠在 JSL 索引列中(传感器数据和资产)层次结构可以作为元数据(列属性)已经存在于表中。
我已经更新了示例,因此您在表中嵌入了父项(组)、父项别名、子项和子项别名。
我认为最直观的方法是按资产(子集)堆叠表格,按标签拆分数据,然后将表格连接在一起。
回复:按组堆叠在 JSL 索引列中(传感器数据和资产)我还简化了要求(不再有空值)并找到了需要迭代完成(每个资产)的解决方案(堆栈、拆分、连接)。 层次结构数据现在嵌入到主表中(进度可以在 input_example 中找到)。
回复:按组堆叠在 JSL 索引列中(传感器数据和资产)我发现最直接的操作是自动化这些数据步骤。
1)堆栈

2)拆分

3)连接

按组堆叠在 JSL 索引列中(传感器数据和资产)在制造中,通常以以下形式提取传感器数据,其中A和B对应类似的设备(称为资产)。
在这种格式中,用户需要为每个父组创建一个组合公式。 例如:
(输入:传感器数据表需要每个父组的特定列)

当处理多个资产时,这会变得很麻烦,因此更好的方法是按组资产堆叠数据。
为了以编程方式执行此操作,我们需要包含层次结构的上下文数据。 例如:
(输入:资产层次结构)

在 JSL 中,如何从传感器数据和层次结构(输入)移动到资产表(所需输出)?
(输出:资产数据表)

所有表格和脚本均附后。 这是输入表脚本(包含父子的元数据添加为列属性)。
Names Default To Here( 1 );
// New data table
dt = New Table( "sensor table" );
n_rows = 10;
n_additional_rows = 0;
// New column: Index
dt << New Column( "Index", Numeric, "Continuous", Format( "Best", 12 ) ) <<
Begin Data Update << Add Rows( n_rows );
dt:Index << Set Formula( Row() );
dt << End Data Update;
// A sensor
dt << New Column( "A sensor 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected
) << New Column( "A sensor 2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected
) << New Column( "A sensor 3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected
) << Group Columns( "A sensors", {:A sensor 1, :A sensor 2, :A sensor 3} )
<< Begin Data Update;
For Each Row(
dt,
:A sensor 1 = Random Normal( 0, 1 );
:A sensor 2 = Random Normal( 0, 1 );
:A sensor 3 = Random Normal( 0, 1 );
);
dt << End Data Update;
// B sensors
dt << Add Rows( n_additional_rows );
dt << New Column( "B sensor 1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected
) << New Column( "B sensor 2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected
/*) << New Column( "B sensor 3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Selected*/
) << Group Columns( "B sensors", {:B sensor 1, :B sensor 2}) //, :B sensor 3} )
<< Begin Data Update;
For Each Row(
dt,
:B sensor 1 = Random Normal( 0, 3 );
:B sensor 2 = Random Normal( 0, 2 );
//:B sensor 3 = Random Normal( 0, 3.5 );
);
dt << End Data Update;
colnames = dt << Get Column Names( String );
for each({col, index}, colnames,
column(dt, col) << Set Property( "child", col ) );
// Calculations.
// New formula column: Stdev[A sensor ...r 2,A sensor 3]
dt << New Column( "Stdev[A sensors]",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( Std Dev( :A sensor 1, :A sensor 2, :A sensor 3 ) ));
// Move selected column: Stdev[A sensors]
dt <<MOVE selected="" columns=""></MOVE>
自动化和脚本编写