수식을 기반으로 여러 개의 새 열을 만듭니다.안녕하세요 jmp 커뮤니티
바이오마커 발현으로부터 얻은 연속형 데이터 값을 담고 있는 19,000열 x 88행의 데이터가 있습니다.
각 마커에 대해 바이오마커 발현 값에서 참조 값을 뺀 공식이 포함된 새로운 열을 만들고 싶습니다.
바이오마커와 참조 모두에서 모든 행이 필요하므로 행을 선택할 필요가 없습니다.
그래서 그것은 매우 간단해 보이지만 바이오마커 데이터를 새 열에 삽입하는 것만 해도 어려움을 겪고 있습니다(수식을 테스트했지만 작동하지 않았습니다)
코드에는 반복이 포함되어 있지 않습니다. 먼저 단일 열에 대해 작동하는지 확인하고 싶을 뿐이기 때문입니다.

자동화 및 스크립팅기본 데이터 분석 및 모델링데이터 접근Re: 수식을 기반으로 여러 개의 새 열 만들기안녕하세요 @BioJmPCoder , 다음을 사용하여 코드를 붙여넣을 수 있습니까? 게시물 버튼에 아이콘이 있나요?
Re: 수식을 기반으로 여러 개의 새 열 만들기다음은 Blood Pressure 샘플 데이터 테이블을 사용하여 데이터 테이블의 모든 새 열을 만드는 예입니다. 스크립트는 두 가지 다른 방법을 사용하여 새 열을 만들어서 다른 방법을 사용하여 동일한 결과를 얻을 수 있음을 보여줍니다.
names default to here(1);
// Open a sample data table to use for illustration
dt =
// Open Data Table: Blood Pressure.jmp
// → Data Table( "Blood Pressure" )
Open( "$SAMPLE_DATA/Blood Pressure.jmp" );
// Get all of the numeric continuous column names
colNames = dt << get column names( string, continuous );
// Method 1
// Cycle through all Numeric, Continuous columns and create
// a new column with the values from the original column,
// using "set each value()"
For Each( {col}, colNames,
dt << New Column( col || " Dif1", numeric, continuous,
format( "Fixed Dec", 3, 0 ),
set each value( as column(col))
)
);
// Method 2
// Cycle through all Numeric, Continuous columns and create
// a new column with the values from the original column,
// pulling all of the values for a column into a matrix,
// and then creating a new column and populating the new
// column with the values from the matrix
For Each( {col}, colNames,
theValues = column( col ) << get values;
dt << New Column( col || " Dif2", numeric, continuous,
format( "Fixed Dec", 3, 0 )
);
column( dt, nCols(dt) ) << set values( theValues );
);Re: 수식을 기반으로 여러 개의 새 열 만들기안녕하세요 짐,
입력해 주셔서 감사합니다. 저는 열 1의 값에서 빼서 열의 모든 데이터 포인트를 정규화하려고 합니다. 여기서는 열 3의 값을 얻었지만 아래에 표시된 오류가 발생합니다. 아마도 값을 벡터화하고 문자열이 아닌 것으로 만들어야 할까요? 차이를 실행하기 전에?
dt = Current data table();
col_names = dt << get column names(string, continuous);
markerCount = Column(3);
normCount = markerCount - Column(1);
dt << New Column( "Norm_" || col_names[3],
numeric,
continuous,
format( "Fixed Dec", 3, 2 ),
set each value( as column(normCount))
);
//set each value( as column(Column(3)) - column(Column(1)))<BR /><BR /><BR /><BR /><SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 381px;"><SPAN class="lia-inline-image-display-wrapper" image-alt="image.png" style="width: 381px;"><span class="lia-inline-image-display-wrapper" image-alt="image.png" style="width: 381px;"><img src="https://us.v-cdn.net/6038925/uploads/images/71119i06611C84D006971E/image.png" role="button" title="image.png" alt="image.png" /></span></SPAN></SPAN>
Re: 수식을 기반으로 여러 개의 새 열 만들기데이터 테이블의 열을 조작하는 방법과 JSL 변수로 작업하는 방법에 대한 혼란이 있는 것 같습니다. 아래는 2가지 방법을 사용하여 "BP 6M" 열의 값에서 "BP 8M" 열의 값을 뺀 값을 만드는 스크립트입니다.
방법 1은 열 Norm_BP 6M을 생성하고 방법 2는 열 Norm2_BP 6M을 생성합니다.

저는 여러분이 2가지 다른 접근 방식이 무엇을 하는지 이해하는 데 도움이 되기를 바라며 JSL에 주석을 달았습니다.
names default to here(1);
// Open a sample data table to use for illustration
dt =
// Open Data Table: Blood Pressure.jmp
// → Data Table( "Blood Pressure" )
Open( "$SAMPLE_DATA/Blood Pressure.jmp" );
// The data table has the following columns in it
// Subject, Dosec BP 8M, BP 12M, BP 6M, BP 8W, BP 12W, BP 6W,
// BP 8F, BP 12F, BP 6F, Norm_BP 6M
// Get all of the numeric continuous column names
col_Names = dt << get column names( string, continuous );
// Get Column Names returns a JMP List of column names
// of the columns that have a Modeling Type of Continuous
// {"BP 8M", "BP 12M", "BP 6M", "BP 8W", "BP 12W", "BP 6W",
// "BP 8F", "BP 12F", "BP 6F"}
// Note that the first 2 column in the data table, Subject and Dose
// are not in the list
// Note: Specifying
// Column( 1 )
// references the 1st column in the data table, which is Subject
// Specifying
// Column( col_Names[1] )
// references the 1st column in the col_Names List, which is BP 8M
// Method 1
// Create the new column. Set Each Value loops through each
// row in the data table and applies the specified formula
// which is to subtract the value in the 1st column in the
// col_Names list from the value in the 3rd column in the
// col_Names list
dt << New Column( "Norm_" || col_names[3],
numeric,
continuous,
Format( "Fixed Dec", 3, 2 ),
set each value( As Column( col_Names[3] ) - As Column( col_Names[1] ) )
);
// Method 2
// Perform the same subtraction, however do it by pulling all of the
// values from each of the 2 target columns into 2 matrices and then
// use matrix math to do the subtraction into an additional matrix
// and then take those values and put them into the new column
// Create the new column with no values
dt << New Column( "Norm2_" || col_names[3],
numeric,
continuous,
Format( "Fixed Dec", 3, 2 )
);
// Pull the data from the 2 columns in the data table
matCola = column( col_Names[1]) << get values;
matColb = column( col_Names[3]) << get values;
// Subtract the values in matCola from matColb
matResults = matColb - matCola;
// Put the results into the new column
column( "Norm2_" || col_names[3] ) << set values( matResults);