안녕하십니까,
아래와 같은 테이블이 있습니다.
ABC ..n 열
1 2 3
7 6 4
3 7 9
.
.
m 행
나는 모든 열에 대해 " n번째 행의 값 = n번째 행의 값 - 첫 번째 행의 값"이라는 스크립트를 작성하고 결국 첫 번째 행을 0으로 재설정하고 싶습니다. 결국 내 테이블은 다음과 같아야합니다.
알파벳
0 0 0..
6 4 1
2 5 6
.
.
누군가가 그러한 작업에 대한 스크립트를 도와줄 수 있습니까? 감사
여기에 루핑을 하는 몇 가지 방법이 있습니다........ 더 많은 방법이 있지만 다른 사람들이 보여주도록 하겠습니다.
Names Default To Here( 1 );
// Open the data table
dt1 = Open( "$SAMPLE_DATA\Blood Pressure.jmp" );
// Create a second copy
dt2 = dt1 << subset( selected columns( 0 ), selected rows( 0 ) );
// Get all numeric, continuous column names
colList = dt1 << get column names( string, numeric, continuous );
// Loop across all numeric, continuous columns and use a
// matrix operation to handle the math
For( i = 1, i <= N Items( colList ), i++,
mat = Column( dt1, colList[i] ) << get values;
mat = mat - mat[1];
Column( dt1, colList[i] ) << set values( mat );
);
// Now do the same thing looping with the data in place
// Loop across all numeric, continuous columns
For( i = 1, i <= N Items( colList ), i++,
// Go through each row, from the bottom to the top to subtract
// the value of the first row from each rows value
For( k = N Rows( dt2 ), k >= 1, k--,
Column( dt2, colList[i] )[k] = Column( dt2, colList[i] )[k] - Column( dt2, colList[i] )[1]
)
);