<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />こんにちは、select where を使用して、for ループを使用して 2 列の条件を満たす行の数を数えようとしています。 スクリプトの最初 (図示されていません) では、ダイアログを使用してユーザーに 2 つの列を選択させ、これがリスト (collist) になります。 次に、それぞれに連想配列を使用して、列ごとに一意の値を決定します。 2 番目のダイアログでは、ユーザーは列ごとにこれらの一意の値のサブセットを選択でき、最終的には別のリスト (poschosen) になります。 私が苦労している問題は、collist の列を select where 関数に挿入することです。 eval、expr、eval expr、parseなどを適切に挿入しようとさまざまな試みを試みましたが、正しい方法が見つからないようです。 誰かがアドバイスをくれることを願っています。
これは、サンプル データ「子供の人気」に適応した私のコードです。 値(14行目)SchoolとGoalsをそれぞれcollist[1]とcollist[2]に置き換えたいと思います。 事前にご協力いただきありがとうございますエリザベス
dattable=Open( "$SAMPLE_DATA/Children's Popularity.jmp" );
poschosen={"Ridge","Sand","main","stop","Popular","Grades","stop"};
stoppos={4,7}; //determine the position of the separator "stop"
Test1pos=subtract(stoppos[1],1); //determine the # of school column values chosen
Test2posStart=add(stoppos[1],1); //determine where in the list the Goals column values start
collist={"School", "Goals"};
sumpositives=0;
For (i = 1, i <= Test1pos, i++, //loop through the chosen school column values
For(f=Test2posStart, f
dattable< & Goals==Poschosen);
num_selected=nrows(dattable<
sumpositives=sumpositives+num_selected; //add the current selection count to previous count
print(sumpositives); //should be 56 in this example
); //end of inner for loop
); //end of outer for loop
私はこれを理解しようとずっと努力していましたが、ついにこのスレッドを見つけました。 ありがとう!
気にしないでください、私はそれを思いついただけです(もちろん、質問を投稿した直後に、そうしてください)...これを行うと、行14が機能します。
dattable< & as column(dattable,collist[2])==Poschosen);