jslの文字列を数えるバイナリ0/1応答(文字、名目)を持ついくつかのデータ列を持つデータテーブルがあります。 これらの列の「1」のインスタンスをカウントする新しい列(数値、連続)を作成したいと思います。
誰かがこの列を作成するためのスクリプトを作成するのを手伝ってもらえますか? これは簡単なはずなのに、障害にぶつかっています。 文字列を数値/連続列に変換し、合計式を実行する必要がありますか?ありがとうございました!
表の例
| 感染(性格、名目) | 血栓(キャラクター、名目) | 手術(性格、名目) | 新しい列: 合併症の数(数値、連続) |
| 0 | 1 | 1 | 2 |
1 | 1 | 1 | 3 |
| 1 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 |
スクリプティング再:jslの文字列を数える必要なのは数式だけです。

結果は次のとおりです。

再:jslの文字列を数える@markbailey良い解決策を提供しました
これが問題を解決する別の方法です
Names Default To Here( 1 );
dt = Current Data Table();
charNames = dt << get column names( character );
// convert char columns to numeric
For( i = 1, i <= N Items( charNames ), i++,
Column( dt, charNames[i] ) << data type( numeric )
);
// Create the jsl required to sum all of the specified columns
theExpr = "dt << new column(\!"number of complications\!", formula(sum(" ||
Substr( Char( charnames ), 2, Length( Char( charNames ) ) - 2 ) || "));";
// Execute the line of code created
Eval( Parse() );
// Delete the formula leaving the static values
Column( dt, "number of complications" ) << delete formula;
// Convert the binary columns back to character
For( i = 1, i <= N Items( charNames ), i++,
Column( dt, charNames[i] ) << data type( character )
);再:jslの文字列を数える両方のおかげで@markbaileyそして@txnelson私の問題に2つのアプローチを提供してくれて。 将来再び使用するデータテーブル作成用の完全なスクリプトを作成しようとしているので、スクリプトを使用します。
ありがとうございました!