배포판에서 추가된 참조 줄에 주석을 달 때 사용되는 연결된 레이블에 선택된 행의 열 값을 가져오려고 합니다.
연결 오류 메시지는 목록 차원의 불일치로 인해 발생합니다. 선택한 행에서 값을 수집하는 데 사용된 연관 배열 호출은 중복 값을 제거하여 고유한 값 목록을 생성합니다.
제 목표는 선택된 행에 대한 이름, 나이, 체중을 나중에 참조 추가 호출에서 레이블로 사용할 수 있는 문자열로 변환하는 것입니다.
현재 접근방식에서는 오류 코드가 발생하고, 어떤 경우에는 오류 코드 없이도 데이터가 정렬되지 않는 경우가 있습니다.
예 1 - 오류 조건: 세 개의 고유한 가중치가 발견되었는데, 연령과 이름에 대한 목록은 선택된 행에서 각각 두 개의 항목만 찾았습니다. 목록 차원의 차이로 인해 인덱싱의 세 번째 반복이 실패합니다.
예제 2 - 정렬되지 않은 데이터: Leslie와 Patty라는 이름을 사용하여 선택된 행이 3개 있습니다. Patty라는 이름이 있는 항목이 두 개 있는데, 하나는 나이가 14세이고 체중이 85이고, 다른 하나는 나이가 16세이고 체중이 134입니다. Patty에 대한 항목 중 하나와 Leslie에 대한 항목은 모두 14세입니다. 정렬되지 않은 데이터의 결과는 레이블이 이름 {"LESLIE", "PATTY"}과 나이 {14,16}에 대한 목록만 고려하는 경우 확인할 수 있습니다. 인덱싱을 통해 두 개의 항목만 만들면 첫 번째는 "Leslie ...14"이고 두 번째는 "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 ) );안녕하세요 브라이언, 변환 열을 사용하여 올바른 결과를 준비한 다음 필요한 항목을 선택할 수 있습니다.

더 보기...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 ) );
안녕하세요 @호기
이 글과 참조선 추가에 관한 관련 글에서 여러분의 아이디어를 결합했습니다.
스택에 있는 플롯에 빈을 올바르게 추가하는 동시에 반복되는 값을 손실하지 않고 올바른 정보를 정렬하는 솔루션은 중첩된 for 루프 내에서 선택한 행을 인덱싱하여 테이블의 필드에서 목록을 준비하는 것이었습니다.
- 플롯 분포
- 보고서의 인스턴스에 있는 각 플롯에 대한 배열로 기준별로 수집(각 데이터 항목에 대한 3개 플롯, 3개 배열)
- 반복에 사용되는 객체로 보고서를 수집합니다.
- 플롯된 데이터의 중간점을 추가합니다(3개 플롯, 데이터 테이블에 추가된 3개 열)
- For Each를 사용하여 객체를 반복하여 각 플롯에 액세스하고 확장합니다.
- 빈과 레이블에 대한 목록 변수 초기화
- 기준선 기준(예: 일련 번호)에 따라 데이터의 행을 선택합니다.
- 플롯의 기준에 맞는 기준에 따라 선택된 행을 세분화합니다.
- 선택한 행의 수만큼 for 루프를 사용합니다.
- 첨부된 중간점 열에서 빈을 수집합니다(각 플롯에는 해당 열이 있음)
- 관심 있는 열(예: 측정 날짜, 일련 번호)에서 레이블에 정보를 수집합니다.
- 수집된 정보를 사용하여 참조 라인을 추가합니다.
- 1단계의 플롯 설정이 변경될 경우 오래된 데이터가 표시되는 것을 방지하려면 중간점 열을 삭제하세요.
도움이 된 주요 변경 사항:
1. 중복 값을 제거하지 않고 정렬을 유지하기 위해 연관 배열에서 반복을 통해 채워진 목록으로 변경합니다.
2. 각 조건에 대해 별도의 변수를 만듭니다.
이것이 루프를 닫는 데 도움이 되었으면 좋겠습니다. 귀하의 조언은 감사합니다. 그것은 제 학습과 진전을 가능하게 했습니다.