やあみんな、
私の目標は、各列で最も一般的な値 (文字タイプ) を持つ行のみを選択することです。
たとえば、私のテーブルには A、B、C、D の 4 つの列があります。 列 A、B、C、D で最も多く出現する値は、それぞれ A1、B2、C3、D4 です。 これらの値で行をフィルタリングし、フィルタリングされたデータを含む新しいテーブルを作成する JSL コードを作成するにはどうすればよいですか? ありがとう。
ありがとう
(COL -> 最多出現数) が A -> A1、B -> B2、C -> C1 であるこのようなデータがある場合 (実際には C は同点ですが、これらはどのように処理すればよいでしょうか?)

A1、B2、C1 があるため、row1 のみを保持しますか? 同じ値を持つ行がさらにあった場合、それらをすべて保持したいと思いますか? それとも、まったく別のものを探していますか。たとえば、最もよく出現する値だけを含むテーブルが必要ですか?
問題の解決に役立つスクリプトを次に示します。
Names Default To Here( 1 );
// build an example data table
dt = New Table( "Example",
add rows( 20 ),
New Column( "A",
character,
formula(
rand = Random Uniform( 0, 100 );
If(
rand >= 0 & rand <= 40, x = 1,
rand >= 40 & rand <= 60, x = 2,
rand >= 60 & rand <= 80, x = 3,
x = 4
);
"A" || Char( x );
)
),
New Column( "B",
character,
formula(
rand = Random Uniform( 0, 100 );
If(
rand >= 0 & rand <= 20, x = 1,
rand >= 20 & rand <= 60, x = 2,
rand >= 60 & rand <= 80, x = 3,
x = 4
);
"B" || Char( x );
)
),
New Column( "C",
character,
formula(
rand = Random Uniform( 0, 100 );
If(
rand >= 0 & rand <= 20, x = 1,
rand >= 20 & rand <= 40, x = 2,
rand >= 40 & rand <= 80, x = 3,
x = 4
);
"C" || Char( x );
)
),
New Column( "D",
character,
formula(
rand = Random Uniform( 0, 100 );
If(
rand >= 0 & rand <= 20, x = 1,
rand >= 20 & rand <= 40, x = 2,
rand >= 40 & rand <= 60, x = 3,
x = 4
);
"D" || Char( x );
)
)
);
// The JSL below is the code that does the actual work
Data Table( "Example" ) << Stack(
columns( :A, :B, :C, :D</img> ),
Source Label Column( "Column" ),
Stacked Data Column( "Data" ),
Output Table( "Stacked" )
);
dtS = Data Table( "Stacked" ) << Summary(
Group( :Column, :Data ),
Freq( "None" ),
Weight( "None" ),
output table name( "Summary" )
);
dtS << select where( :N Rows[Row()] == col max(:N Rows, :Data));
dtS << new column("Mode", formula(
Col Max(:N Rows, :Column)
));
dtS << select where( :N Rows == :Mode);
dtS << invert row selection << delete rows;
eval(parse(
"dt << Select Where (dt:\!"" || dts:column[1] || "\!"n == dtS:Data[1] );"));
For( i=2,i<=NRows(dtS), i++,
eval(parse(
"dt << Select Where (dt:\!"" || dts:column[i] || "\!"n == dtS:Data[i] , current selection(\!"extend\!"));"));
);
dtFinal = dt << Subset( selected columns(0), selected rows(1), output table("Final"));