JMP 18: 지정된 열의 오른쪽에 있는 모든 열 선택Adders라는 열의 오른쪽에 있는 모든 열을 선택하려고 합니다. 아래 코드는 실행되지만 Adders 오른쪽에 있는 열은 눈에 띄게 선택되지 않습니다. Adders의 왼쪽과 오른쪽에 있는 열의 수는 다를 수 있습니다.
<JSL> Names Default To Here(1);
dt = Data Table("Test Table");
dt << Bring Window To Front;
Show(dt << Get Name);
// Step 1: Get all column names and show them
colNames = dt << Get Column Names();
Show(colNames);
// Step 2: Find the index of the "Adders" column
targetColName = "Adders";
colIndex = Loc(colNames, targetColName);
Show(colIndex); // Should be > 0 if found
// Step 3: Try to visually select all columns to the right
If(colIndex > 0 & colIndex < N Cols(dt),
dt << Clear Column Selection;
For(i = colIndex + 1, i <= N Cols(dt), i++,
Column(dt, i) << Set Selected(1);
);
// Step 4: Show what JMP thinks is selected
selected = dt << Get Selected Columns;
Show(selected);
,
New Window("Error", Text Box("Column 'Adders' not found, or it's the last column."));
);</JSL>
산출:
dt << Get Name = "Test Table";
colNames = {A, B, Adders, X, Y};
colIndex = [];자동화 및 스크립팅윈도우Re: JMP 18: 지정된 열의 오른쪽에 있는 모든 열 선택여기서 두 가지 변경을 하겠습니다. Get Column Names 메시지에 "string"을 지정해야 합니다. 그런 다음 Loc() 함수를 Contains()로 변경해야 합니다. Loc()는 행렬을 반환하는데, 때로는 비어 있습니다. Contains()는 정수(찾을 수 없는 경우 0)를 반환합니다.
Names Default To Here(1);
dt = Data Table("Test Table");
dt << Bring Window To Front;
Show(dt << Get Name);
// Step 1: Get all column names and show them
colNames = dt << Get Column Names( "string" );
Show(colNames);
// Step 2: Find the index of the "Adders" column
targetColName = "Adders";
colIndex = Contains(colNames, targetColName);
Show(colIndex); // Should be > 0 if found
// Step 3: Try to visually select all columns to the right
If(colIndex > 0 & colIndex < N Cols(dt),
dt << Clear Column Selection;
For(i = colIndex + 1, i <= N Cols(dt), i++,
Column(dt, i) << Set Selected(1);
);
// Step 4: Show what JMP thinks is selected
selected = dt << Get Selected Columns;
Show(selected);
,
New Window("Error", Text Box("Column 'Adders' not found, or it's the last column."));
);
//Output:
//dt << Get Name = "Test Table";
//colNames = {"A", "B", "Adders", "X", "Y"};
//colIndex = 3;<BR />//selected = {:X, :Y};Re: JMP 18: 지정된 열의 오른쪽에 있는 모든 열 선택이 작업을 수행하는 다른 방법도 있을 것이라고 확신하지만 다음 스크립트는 "Adders" 열을 찾은 다음 해당 열과 오른쪽의 모든 열을 선택합니다.
names default to here(1);
dt = current data table();
targetCol = "Adders";
targetColNum = 0;
for( i = 1, i <= n cols( dt ), i++,
if( column( dt,i ) << get name == targetCol, targetColNum = i )
);
dt << select columns( targetColNum::n cols(dt) )
Re: JMP 18: 지정된 열의 오른쪽에 있는 모든 열 선택귀하의 최초 게시물을 편집하고 편집 입력 창의 상단에 있는 입력 아이콘을 사용하여 JSL과 해당 출력을 각각 JSL 창과 코드 창으로 옮겼습니다.
또한 <<가 열 이름을 가져오고 문자열을 반환하고 Loc() 대신 Contains()를 사용하여 행렬 값이 아닌 단일 값을 반환하도록 코드를 수정했습니다.
Names Default To Here(1);
dt = Data Table("Test Table");
dt << Bring Window To Front;
Show(dt << Get Name);
// Step 1: Get all column names and show them
colNames = dt << Get Column Names(string);
Show(colNames);
// Step 2: Find the index of the "Adders" column
targetColName = "Adders";
// Loc() returns a matrix, contains returns a scaler value
colIndex = contains(colNames, targetColName );
Show( colIndex ); // Should be > 0 if found
// Step 3: Try to visually select all columns to the right
If( colIndex > 0 & colIndex < N Cols( dt ),
dt << Clear Column Selection;
For( i = colIndex + 1, i <= N Cols( dt ), i++,
Column( dt, i ) << Set Selected( 1 )
);
// Step 4: Show what JMP thinks is selected
selected = dt << Get Selected Columns;
Show( selected );
,
New Window( "Error", Text Box( "Column 'Adders' not found, or it's the last column." ) )
);Re: JMP 18: 지정된 열의 오른쪽에 있는 모든 열 선택수정해 주셔서 감사합니다.
Re: JMP 18: 지정된 열의 오른쪽에 있는 모든 열 선택짐: 수정해 주셔서 감사합니다.
Re: JMP 18: 지정된 열의 오른쪽에 있는 모든 열 선택스콧: 작동하는 코드를 공유해 주셔서 감사합니다.
Re: JMP 18: 지정된 열의 오른쪽에 있는 모든 열 선택포함 + 인덱싱을 사용하면 이를 매우 간단하게 만들 수 있습니다.
Names Default To Here(1);
dt = Data Table("Test Table");
collist = dt << Get Column Names("String");
adders_idx = Contains(collist, "Adders");
If(adders_idx == 0,
Throw("No Adders column found");
);
dt << Select columns(collist[adders_idx + 1::N Items(collist)]);
Show(dt << Get Selected Columns);