带分组的字符串数据计算模式我尝试使用以下方法计算按 B 列分组的 A 列的众数:Col Mode(:A,:B)函数。然而,由于 A 列包含字符串数据,因此没有输出任何值。然后我发现Mode(:A)即使对于字符串数据,也可以获取众数。现在的问题是我不知道如何进行分组。我应该如何构建公式?
自动化和脚本编写回复:带分组的字符串数据的计算模式你需要公式还是只需要结果?
回复:带分组的字符串数据的计算模式谢谢你的回复,jthi。
我需要一个公式,想把它写进数据表中。
回复:带分组的字符串数据的计算模式最简单的办法可能是创建一个新列,将数值转换为数字(可以使用“重新编码”->“标签转代码”功能),然后使用该列进行计算。之后,可以使用“复制列属性”功能将“标签值”列属性复制过来。
此外,希望添加一个愿望清单项 Col Mode() 以支持字符列
回复:带分组的字符串数据的计算模式所以,这意味着需要多一个步骤。我明白了。我希望 Col Mode() 函数能够支持字符串列。非常感谢。
回复:带分组的字符串数据的计算模式您可以在这里创建愿望清单项。例如,您可以创建工作流程或脚本来处理这个额外的步骤。
用公式可能也可以,但我不知道效率如何。这应该能得到性别相对于年龄的众数。
As Constant(
score_indices = Associative Array(:sex) << get keys
);
score_indices[Col Mode(Col Score(:sex), :age)]

回复:带分组的字符串数据的计算模式我会在那里发布愿望清单,谢谢。
你是如何创建“S”列的?我对这个想法很感兴趣!
回复:带分组的字符串数据的计算模式我已经提供了 S 的公式(需要 JMP19)。
回复:带分组的字符串数据的计算模式// データテーブルを取得
dt = Current Data Table();
// B列のユニークな値を取得(グループ化のため)
unique_groups = As List(dt:B<< Get As Matrix);
// 新しい列 "mother" を作成
dt << New Column("mother", Character, "Nominal");
// 各グループごとに処理を実行
For(i = 1, i <= N Items(unique_groups), i++,
// 現在のグループをフィルタリング
current_group = unique_groups[i];
Show(current_group);
subset_rows = As List(dt << Get Rows Where(:B == current_group));
Show(subset_rows);
Show(Type(subset_rows));
// A列のキーを取得
score_indices = dt:A[subset_rows] << Get As List;
Show(score_indices);
// グループ内の "mother" 列を更新
dt:mother[subset_rows] = If(
Is Missing(score_indices[Col Mode(Col Score(dt:A[subset_rows]))]),
score_indices[2],
score_indices[Col Mode(Col Score(dt:A[subset_rows]))]
);
);
提取 B 列中的唯一值,并用于处理每个组。
但是,这样做会输出错误信息:“您需要为 Send 输入一个可脚本化的对象。 ”
如果您有任何见解,请告诉我。
回复:带分组的字符串数据的计算模式// データテーブルを取得
dt = Current Data Table();
// B列のユニークな値を取得(グループ化のため)
unique_groups = As List(dt:B<< Get As Matrix);
// 新しい列 "mother" を作成
dt << New Column("mother", Character, "Nominal");
// 各グループごとに処理を実行
For(i = 1, i <= N Items(unique_groups), i++,
// 現在のグループをフィルタリング
current_group = unique_groups[i];
Show(current_group);
subset_rows = As List(dt << Get Rows Where(:B == current_group));
Show(subset_rows);
Show(Type(subset_rows));
// A列のキーを取得
score_indices = Associative Array(Set Unique(dt:A[subset_rows])); Show(score_indices);
// グループ内の "mother" 列を更新
dt:mother[subset_rows] = If(
Is Missing(score_indices[Col Mode(Col Score(dt:A[subset_rows]))]),
score_indices[2],
score_indices[Col Mode(Col Score(dt:A[subset_rows]))]
);
);
这样就解决了获取 A 列键值的问题。
jthi,给您添麻烦了,非常抱歉。
回复:带分组的字符串数据的计算模式// データテーブルを取得
dt = Current Data Table();
process_nm = "A";
// B列のユニークな値を取得(グループ化のため)
unique_groups = dt:B << Get values;
// 新しい列 "mother" を作成
dt << New Column("mother", Character, "Nominal");
// 各グループごとに処理を実行
For(i = 1, i <= N Items(unique_groups), i++,
// 現在のグループをフィルタリング
current_group = unique_groups[i];
subset_rows = dt << Get Rows Where(:B == current_group);
// A列のキーを取得
score_indices = Associative Array(Set Unique(Column(process_nm)[subset_rows])) << get keys;
// グループ内の "mother" 列を更新
dt:mother[subset_rows] = Mode(Column(process_nm)[subset_rows]);
);
带分组的字符串数据计算模式
- 列模式()不支持字符串
・Mode() 支持字符串
・Mode() 不支持分组
【对策】
1. 将字符串视为数字,并使用列模式()。
2. 预先筛选行并使用 Mode()。
回复:带分组的字符串数据的计算模式一个类似的愿望:
:folded_hands: 汇总和制表:为字符列添加聚合选项
该功能实现后,您就可以使用表格/汇总功能来完成此任务。