選択した行の列値を、分布に追加された参照行に注釈を付けるために使用される連結ラベルに取り込もうとしています。
連結時のエラー メッセージは、リストのディメンションの不一致が原因です。選択された行から値を収集するために使用される連想配列呼び出しによって重複値が削除され、一意の値のリストが生成されます。
私の目標は、特定の選択された行の名前、年齢、体重を、後の add ref 呼び出しでラベルとして使用できる文字列に変換することです。
現在のアプローチでは、エラー コードがあり、場合によってはエラー コードがなくてもデータの不整合が発生します。
例 1 - エラー状態: 年齢と名前のリストで、選択した行からそれぞれ 2 つの項目しか見つからない場合に、3 つの一意の重みが見つかりました。リストのディメンションが異なるため、インデックス作成の 3 回目の反復は失敗します。
例 2 - 不整合データ: Leslie と Patty という名前を使用して 3 つの行が選択されています。Patty という名前のエントリが 2 つあり、1 つは年齢 14 歳、体重 85、もう 1 つは年齢 16 歳、体重 134 です。Patty のエントリの 1 つと Leslie のエントリはどちらも 14 歳です。ラベルが名前 {"LESLIE", "PATTY"} と年齢 {14,16} のリストのみを考慮している場合、不整合データの結果を確認できます。インデックスを作成すると、2 つのエントリのみが作成されます。1 つ目は "Leslie ...14"、2 つ目は "Patty ...16" で、これは正しい関連付けですが、"Patty ...14" が欠落しており、リストのディメンションはデータに依存しています。
連想配列呼び出しを削除して、代わりにサブセット/テーブル アプローチに移行する必要がありますか。それとも、各反復または各選択された行で取得された名前、年齢、体重を含むリストであるリスト項目を持つように連想配列呼び出しを修正する必要がありますか。
ありがとう、
ブライアン
リストの次元を超えた場合のエラー コード:
引数は 'Concat' のアクセスまたは評価の行 41 の文字である必要があります。不正な引数 ( theAges[i] )、 theNames[i] || /*###*/" ..." || /*###*/theAges[i] /*###*/

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col_name_list = dt << get column names( string );
newColName = "State";
// New column: State
If( !Contains( col_name_list, newColName ),
Local( {dt, tempStrings},
dt = Data Table( "Big Class" );
dt << New Column( "State", Character, "Nominal" ) << Begin Data Update;
tempStrings = {"CA", "WA", "OR"};
For Each Row( dt, :State = tempStrings[Sequence( 1, 3, 1, 1 )] );
dt << End Data Update;
);
//Make it a double Patty :), another person with the same name.
dt << Add Rows( 1, At End );
//Cheat and use a constant of 41 for the last row index
dt[[41], {name, age, sex, height, weight, State}] = {{"PATTY", 16, "F", 57, 134, "WA"}};
);
// For illustration, select some names
dt << select where( Contains Item( :name, {"LESLIE", "PATTY"} ) );
dist = dt << Distribution(
Stack( 1 ),
Continuous Distribution(
Column( :height ),
Quantiles( 0 ),
Summary Statistics( 0 ),
Horizontal Layout( 1 ),
Normal Quantile Plot( 0 ), // disable, if the user enabled it in the preferences :)
Vertical( 0 ),
Set Bin Width( 2 ),
Process Capability( 0 )
//);
),
By( :State )
);
// get all reports
// if there is a BY group, get the info - if there is none, put it into a list
If( Is List( dist ),
dists=dist;
myBys = Transform each ({myexpr} , dist << Get Where Expr, Arg(myExpr , 2 ))
, //no By
dists = Eval List( {dist} );
myBys= {};
);
//get the reports
distRPTs = Transform Each( {dist}, dists, Report( dist ) );
// Find the Midpoints of the bins the selected rows are in
dist << Save( "Level Midpoints" );
//loop though the By groups and add the reflines
For Each( {report, idx}, distRPTs,
//report = distRPTs[2]; idx=2;
selected rows = dt << get selected rows;
// there is a BY group -> restrict the selection
if(N Items(myBys),
Eval( Eval Expr( selected rows = dt << get rows where( Contains( Expr( selected rows ), Row() ) & :State == Expr( myBys[idx] ) ) ) );
);
theBins = (Associative Array( Column( dt, N Cols( dt ) )[selected rows] )) << get keys;
theNames = (Associative Array( Column(dt, "name") [dt << get selected rows] )) << get keys;
theAges = (Associative Array( Column(dt, "age") [dt << get selected rows] )) << get keys;
theWeights = (Associative Array( Column(dt, "weight") [dt << get selected rows] )) << get keys;
For( i = 1, i <= N Items(theWeights), i++,
theLabels[i] = theNames[i] || " ..." || theAges[i] ;
);
);
dt << delete columns( N Cols( dt ) );こんにちは、Bryan。変換列を使用して正しい結果を準備し、必要なエントリを選択できます。

もっと見る...Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col_name_list = dt << get column names( string );
newColName = "State";
// New column: State
If( !Contains( col_name_list, newColName ),
Local( {dt, tempStrings},
dt = Data Table( "Big Class" );
dt << New Column( "State", Character, "Nominal" ) << Begin Data Update;
tempStrings = {"CA", "WA", "OR"};
For Each Row( dt, :State = tempStrings[Sequence( 1, 3, 1, 1 )] );
dt << End Data Update;
);
//Make it a double Patty :), another person with the same name.
dt << Add Rows( 1, At End );
//Cheat and use a constant of 41 for the last row index
dt[[41], {name, age, sex, height, weight, State}] = {{"PATTY", 16, "F", 57, 134, "WA"}};
);
// For illustration, select some names
dt << select where( Contains Item( :name, {"LESLIE", "PATTY"} ) );
dist = dt << Distribution(
Stack( 1 ),
Continuous Distribution(
Column( :height ),
Quantiles( 0 ),
Summary Statistics( 0 ),
Horizontal Layout( 1 ),
Normal Quantile Plot( 0 ), // disable, if the user enabled it in the preferences :)
Vertical( 0 ),
Set Bin Width( 2 ),
Process Capability( 0 )
//);
),
By( :State )
);
// get all reports
// if there is a BY group, get the info - if there is none, put it into a list
If( Is List( dist ),
dists=dist;
myBys = Transform each ({myexpr} , dist << Get Where Expr, Arg(myExpr , 2 ))
, //no By
dists = Eval List( {dist} );
myBys= {};
);
//get the reports
distRPTs = Transform Each( {dist}, dists, Report( dist ) );
// Find the Midpoints of the bins the selected rows are in
dist << Save( "Level Midpoints" );
dt << transform column ("label",Character, Formula (:name || " ..." || Char(age)));
//loop though the By groups and add the reflines
For Each( {report, idx}, distRPTs,
//report = distRPTs[2]; idx=2;
selected rows = dt << get selected rows;
// there is a BY group -> restrict the selection
if(N Items(myBys),
Eval( Eval Expr( selected rows = dt << get rows where( Contains( Expr( selected rows ), Row() ) & :State == Expr( myBys[idx] ) ) ) );
);
myLabels = Associative Array(:label[selected rows]) << get keys;
print(myLabels)
);
dt << delete columns( N Cols( dt ) );
こんにちは@hogi
この投稿と、参照ラインの追加に関する関連投稿で、あなたのアイデアを組み合わせました。
スタック内のプロットにビンを正しく追加しながら、重複した値を失うことなく正しい情報を揃えるための解決策は、ネストされた for ループ内で選択した行にインデックスを付けて、テーブル内のフィールドからリストを準備することでした。
- プロット分布
- レポートのインスタンス内の各プロットの配列に条件別に収集します (データ項目ごとに 3 つのプロット、3 つの配列)
- 反復処理で使用されるオブジェクトにレポートを収集する
- プロットされたデータの中間点を追加します(3 つのプロット、3 つの列がデータ テーブルに追加されます)
- For Eachでオブジェクトをループし、各プロットにアクセスして拡張する
- ビンとラベルのリスト変数を初期化する
- ベースライン基準(シリアル番号など)に基づいてデータ内の行を選択します。
- プロットのBy基準に一致する基準に基づいて選択した行を絞り込む
- 選択した行の数だけforループを使用する
- 追加された中間点の列からビンを収集します(各プロットにはそれぞれの列があります)
- 興味のある列(測定日、シリアル番号など)からラベルに情報を収集します。
- 収集した情報を含む参照行を追加します。
- 手順 1 のプロット設定が変更された場合にデータが古くなるのを避けるため、中間点の列を削除します。
役立った主な変更点:
1. 重複する値の削除を回避し、配置を維持するために、連想配列から反復処理によって設定されるリストに変更します。
2. それぞれの条件ごとに個別の変数を作成します。
これがループを閉じるのに役立つことを願っています。あなたのアドバイスに感謝します。それらは私の学習と進歩を可能にしました。