열 그룹의 모든 다른 조합의 합계를 구하려면 어떻게 해야 합니까?안녕,
JMP PRO v16을 사용하고 있습니다.
숫자 값이 있는 10개의 열 그룹이 있고 이 10개 열 사이의 가능한 모든 조합(예: 열 A+ 열 B, 열 A+ 열 B + 열 C, 열 B + 열 C 등).
도와 주셔서 정말 감사합니다
자동화 및 스크립팅Re: 열 그룹의 모든 다른 조합의 합계를 구하려면 어떻게 해야 합니까?안녕 @DivisiveFerret8 .,
JMP에서 대화식으로 이 작업을 수행하는 빠른 방법을 모르지만 jsl을 사용하면 해당 열을 빠르게 만들 수 있습니다.
Names Default to Here (1);
dt = Current Data Table();
// Get the number of columns
ncols = N Col( dt );
// Nested loop to go through all pairwise combinations of columns
For( i = 1, i < ncols, i++,
For( j = i + 1, j <= ncols, j++,
colName1 = Column( dt, i ) << get name;
colName2 = Column( dt, j ) << get name;
// create new column
newColName = colName1 || " + " || colName2;
dt << New Column( newColName, Numeric, "Continuous", Format( "Best", 12 ) );
// compute the sum
Column( dt, newColName ) << set each value(
Column( dt, colName1 )[Row()] + Column( dt, colName2 )[Row()]
);
)
);
//편집하다//
위의 코드는 테이블의 모든 열 조합에 대한 것이지만 지금은 열 그룹에 대해 질문하고 있는 것을 볼 수 있습니다.
Names Default to Here (1);<BR />dt = Current Data Table();
// List of specific columns
// columns = {"Column A", "Column B", "Column C", "Column D", "Column E", "Column F", "Column G", "Column H", "Column I", "Column J"};
// Using selected columns
// columns = dt << Get Selected Columns;
// Referencing by Group Name
columns = dt << get column group( "XY" );
// Number of specific columns
ncols = N Items( columns );
// Nested loop to go through all pairwise combinations of specified columns
For( i = 1, i < ncols, i++,
For( j = i + 1, j <= ncols, j++,
colName1 = columns[i]<<GET name=""></GET>
특정 열 목록이나 선택한 열 사용과 같은 다른 옵션은 그대로 두었습니다.
이게 도움이 되길 바란다!
@줄리안
Re: 열 그룹의 모든 다른 조합의 합계를 구하려면 어떻게 해야 합니까?매우 감사합니다! 이 스크립트는 쌍으로 된 조합만 생성한다고 생각합니다. 가능한 모든 조합을 가질 수 있는 방법이 있습니까? (즉, 2, 3, 4, 5, 6, 7, 8 및 9 열의 모든 가능한 조합),
도움을 주셔서 다시 한 번 감사드립니다.
Re: 열 그룹의 모든 다른 조합의 합계를 구하려면 어떻게 해야 합니까?최종 결과가 정확히 무엇인지 명확하지 않습니다.그러나 아래는 7개(10개가 아니라 10개와 함께 작동) 숫자 열이 있는 데이터 테이블에 대한 모든 열 조합을 요약하는 스크립트입니다.생성되는 각 열 조합의 합계로 새 테이블을 생성합니다.

Names Default To Here( 1 );
dt =
// Open Data Table: Blood Pressure.jmp
// → Data Table( "Blood Pressure" )
Open( "$SAMPLE_DATA/Blood Pressure.jmp" );
startCol = 3;
endCol = N Col( dt ) - startCol - 1;
colNames = dt << get column names( string );
Remove From( colNames, 1, startCol - 1 );
dtOutput = New Table( "output", New Column( "Columns Used", character ), New Column( "Sum" ) );
// Build Combinations
For( nInCombo = 2, nInCombo <= endCol, nInCombo++,
combos = NChooseK Matrix( endCol, nInCombo );
Show( endcol, combos );
For( row = 1, row <= N Rows( combos ), row++,
Current Data Table( dt );
name = "";
cols = N Cols( combos );
code = "x=Sum( col sum( :\!"" || colNames[combos[row, 1, 1]] || "\!"n)";
name = colNames[combos[row, 1, 1]];
For( col = 2, col <= cols, col++,
code = code || ", col sum( :\!"" || colNames[combos[row, col, 1]] || "\!"n)";
name = name || " + " || colNames[combos[row, col, 1]];
);
code = code || " )";
Eval( Parse( code ) );
dtOutput << add rows( 1 );
dtOutput:Columns Used[N Rows( dtOutput )] = name;
dtOutput:Sum[N Rows( dtOutput )] = x;
);
);
행별로 합산을 수행하려는 경우 내 코드를 쉽게 변경하여 기존 데이터 테이블에 각 조합에 대한 새 열을 만들 수 있습니다.
Re: 열 그룹의 모든 다른 조합의 합계를 구하려면 어떻게 해야 합니까?안녕 짐,
도와 주셔서 정말 감사합니다,
이것이 바로 내가 찾던 것입니다. 가능한 경우 각 조합의 합계가 포함된 열을 가져와야 합니다(2, 3, 4, 5, 6, 7, 8 및 9 열의 가능한 모든 조합).
저는 JSL을 이제 막 시작했으며 여러분의 모든 도움에 진심으로 감사드립니다.
Re: 열 그룹의 모든 다른 조합의 합계를 구하려면 어떻게 해야 합니까?이전에 제출한 코드에 대한 수정 사항은 다음과 같습니다.이 코드는 처음 10개 열의 각 조합에 대해 새 열을 추가합니다.1013개의 새 열을 추가합니다.데이터 표에 추가된 내용의 정확성을 확인하십시오.
Names Default To Here( 1 );
dt = data table("sum combined");
startCol = 2;
endCol = N Col( dt ) ;
colNames = dt << get column names( string );
// Build Combinations
For( nInCombo = 2, nInCombo <= endCol, nInCombo++,
combos = NChooseK Matrix( endCol, nInCombo );
For( row = 1, row <= N Rows( combos ), row++,
// create the column name and the formula for the new column
name = "";
cols = N Cols( combos );
code = "Sum( :\!"" || colNames[combos[row, 1, 1]] || "\!"n";
name = "\!"" || colNames[combos[row, 1, 1]];
For( col = 2, col <= cols, col++,
code = code || ", :\!"" || colNames[combos[row, col, 1]] || "\!"n";
name = name || " + " || colNames[combos[row, col, 1]];
);
name = name || "\!"";
code = code || " )";
eval(parse("dt << new column(" || name || ", formula(" || code || "));"));
// Uncomment the next line to remove the formula for the column. This
// will probably make the data table run faster
//column(dt,ncols(dt)) << delete property("formula");
);
);Re: 열 그룹의 모든 다른 조합의 합계를 구하려면 어떻게 해야 합니까?도움을 주신 Jim에게 감사드립니다!