如何计算特定行中的非空行数?我有此处显示的表格,并想创建一个包含“N”的新列,该列是带有数字的列数,但仅限于标记为“DecodeCount_BW**”的列。例如,对于第一行,它应该返回“5”,对于第二行,它应该返回“2”,等等
在 Excel 中,我使用“counta”来执行此操作,但尝试学习 JMP 以改进统计分析,但我被困在这样简单的事情上,这可能是因为我的大脑是 Excel 格式的...抱歉,如果这是非常基础的,但我找不到在公式列表中执行此操作的公式..
谢谢
JMP17 用户
内容组织数据混合和清理回复:如何计算特定行中的非空行数?公式通常不太容易在这个方向上起作用(按行而不是按列计算)。根据你正在做的事情,先堆叠数据可能会有所帮助。
你可以使用公式(可能有点麻烦),但一般我会使用脚本。下面是一个例子

Names Default To Here(1);
dt = New Table("Untitled 3",
Add Rows(3),
Compress File When Saved(1),
New Column("Column 1", Numeric, "Continuous", Format("Best", 12), Set Values([., ., .])),
New Column("Column 2", Numeric, "Continuous", Format("Best", 12), Set Values([., ., .])),
New Column("AB1", Numeric, "Continuous", Format("Best", 12), Set Values([2, ., .])),
New Column("AB2", Numeric, "Continuous", Format("Best", 12), Set Values([., 2, 1])),
New Column("AB3", Numeric, "Continuous", Format("Best", 12), Set Values([., 5, .]))
);
dt << New Column("N", Numeric, Continuous);
cols_of_interest = Filter Each({colname}, dt << Get Column Names("String"),
Starts With(colname, "AB");
);
For Each Row(Current Data Table(),
:N = Sum(!Is Missing(dt[Row(), cols_of_interest]));
);
如果你真的想使用公式,你可以使用类似这样的方法
As Constant(cols_of_interest = Filter Each({colname}, Current Data Table() << Get Column Names("String"),
Starts With(colname, "AB");
));
Sum(!Is Missing(dt[Row(), cols_of_interest]));
您必须自己计算比较结果,以筛选出您感兴趣的列(Starts With 也适用于您的数据)
回复:如何计算特定行中的非空行数?表格/摘要可以为您计数。要使其计数到多列,您必须先堆叠数据:
dt = New Table( "test",
Add Rows( 6 ),
New Column( "W8",Set Values( [2, 5, ., 5, ., 6] )),
New Column( "W9",Set Values( [2, ., 3, 3, 1, 2] )),
New Column( "W1",Set Values( [2, ., ., ., ., .] )),
New Column( "W2",Set Values( [3, ., ., ., ., .] )),
New Column( "W3",Set Values( [3, ., ., ., ., .] )),
New Column( "W4",Set Values( [., ., 4, ., 2, .] )),
New Column( "W5",Set Values( [., 2, ., ., ., .] )),
New Column( "W6",Set Values( [., ., 5, ., 3, .] )));
dt << New Column( "row",Formula( Row() ));
dtstack =dt << Stack( columns( :W8, :W9, :W1, :W2, :W3, :W4, :W5, :W6 ),"Non-stacked columns"n( Keep( :row ) ));
dtstack << Summary( Group( :row ), N( :Data ) );
顺便提一句:
"Non-stacked columns"n
一个命名参数,需要写成“...”n 。啊!
增强日志如何知道这些细节......