你好,我想实现一个公式来“初始化”我们表格中的某些数据。具体来说,我想从列中的所有元素中减去测试运行的第一次重复的值(重复信息包含在另一列中)。
我附上了我正在处理的表格。公式将集成在“X_35”列中。想法是将分析第一次重复(列 X_21)时获得的 X_22 中包含的值分配给每个测试,但要按测试条件进行过滤,特别是我感兴趣的是按其他列(例如 X_5、X_7 和 X_8)进行分离。之后,我将对每一行应用差值,从第一次重复中获得每个点的偏移量。如果可能的话,我想使用列公式找到解决方案,避免手动输入值。
我正在使用 JMP 17
谢谢
这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。
已接受的解答
可以使用列公式来创建您想要的
As Constant( dt = Current Data Table() );
currentType = :Type;
theInitialValue = :Value[(dt << get rows where( :Type == CurrentType & :Repetition == 1 ))[1]];
:Value - theInitialValue;
该方法有效,但是,对于包含 55,000 多个数据表,该公式效率不高。
更有效的方法是使用一个简单的脚本来创建一个仅包含初始值的新表,然后将该表合并回原始表,其中匹配将允许将初始值复制到所有匹配的记录
names default to here(1);
dt=
New Table( "Example2",
Add Rows( 8 ),
New Column( "Type",
Character,
Set Values( {"A", "A", "A", "A", "B", "B", "B", "B"} )
),
New Column( "Repetition",
Numeric,
Set Values( [1, 2, 3, 4, 1, 2, 3, 4] )
),
New Column( "Value",
Numeric,
Set Values( [4, 10, 8, 7, 6, 9, 5, 10] )
)
);
// Create a table with the initial values
dt << select where(:Repetition == 1 );
initialDT = dt << subset( selected rows(1), columns({:Type,:Value}));
// Rename column Value to Initial Value
initialDT:Value << set name("Initial Value");
// Merge the values back to the original table
dt << Update(
With( initialDT ) ,
Match Columns( :Type = :Type )
);
// Create a column that contains the difference
dt << New Column( "Difference",
formula( :Value - :Initial Value )
);
欢迎来到社区。
我有点搞不懂你在问什么。我在你的数据中看到的是
X_31 列定义了数据的 8 个级别中的每一个,其中 X_21 列的每行分组均具有 1 至 980 的子分组值。
我认为您想要做的是,对于 X_21 值不为 1 的给定行,查看其 X_5、X_7 和 X_8 的值,然后找到 X 的初始值,即列 X_22 的匹配值,并从列 X_22 的当前行值中减去该值。
我对自己的评估一点信心都没有。检查数据后发现,对于 X_31 个初始值的每个分组,X_5、X_7 和 X_8 列的组合要多得多。
您目前在提供的数据表中显示的内容(如果 X_21 的值等于 1,则 X_35 的值将从 X_22 列复制)在 JMP 中很容易实现。了解您对其他行的要求会让人感到困惑。如果您可以提供第 7 行和第 14 行的预期结果以及得出结果的步骤,将会非常有帮助。
这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。
可以使用列公式来创建您想要的
As Constant( dt = Current Data Table() );
currentType = :Type;
theInitialValue = :Value[(dt << get rows where( :Type == CurrentType & :Repetition == 1 ))[1]];
:Value - theInitialValue;
该方法有效,但是,对于包含 55,000 多个数据表,该公式效率不高。
更有效的方法是使用一个简单的脚本来创建一个仅包含初始值的新表,然后将该表合并回原始表,其中匹配将允许将初始值复制到所有匹配的记录
names default to here(1);
dt=
New Table( "Example2",
Add Rows( 8 ),
New Column( "Type",
Character,
Set Values( {"A", "A", "A", "A", "B", "B", "B", "B"} )
),
New Column( "Repetition",
Numeric,
Set Values( [1, 2, 3, 4, 1, 2, 3, 4] )
),
New Column( "Value",
Numeric,
Set Values( [4, 10, 8, 7, 6, 9, 5, 10] )
)
);
// Create a table with the initial values
dt << select where(:Repetition == 1 );
initialDT = dt << subset( selected rows(1), columns({:Type,:Value}));
// Rename column Value to Initial Value
initialDT:Value << set name("Initial Value");
// Merge the values back to the original table
dt << Update(
With( initialDT ) ,
Match Columns( :Type = :Type )
);
// Create a column that contains the difference
dt << New Column( "Difference",
formula( :Value - :Initial Value )
);
这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。
如果您经常执行此类规范化步骤,您可以考虑使用Normalization GUI 。
除了减去“第一个”值之外,它还提供更多选项,如“最后一个”,N-1,“中位数”,“平均值”(后者甚至考虑了行排除)。
您可以决定是否要计算值 - 或者是否更喜欢在输入列更新时自动更新值的公式。
这篇帖子最初是用 English (US) 书写的,已做计算机翻译处理。当您回复时,文字也会被翻译成 English (US)。