大家好,
我最近開始編寫 JSL,它使用 Table Box() 功能在新視窗中匯總一些信息,因為我希望用戶能夠選擇行來執行下一步程序。 有時製作互動式表格框可能很麻煩。我最近還了解到,您可以使用「獲取報告」命令將資料表轉換為類似互動式錶框的介面,這使得建立介面變得更加容易和快速。
例如,請參閱此 JSL:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Boston Housing.jmp" );
RptWin = New Window( "Data Table as report",
Outline Box("Data Table as Report",
dt_Rpt = dt << Get as Report();
)
);
我遇到的唯一問題是如何在新視窗中使用輸出,就像使用表格框一樣。
在「錶框」環境中,您可以設定函數,以便它傳回您選擇的訊息,並且可以在程式碼中進一步使用這些資訊。 但是,“獲取為報告”命令不允許您執行此操作。 至少我還沒有找到任何有關如何執行此操作的範例,而且腳本索引中沒有太多有關“獲取為報告”命令的內容。
以下程式碼是我如何建立一次可選擇單行的表格框的範例。
tb = Table Box(
Number Col Box( "PC Number", Eval List( PC_n ) ),
Number Col Box( "Eigenvalue", Eval List( PC_eigv ), <<SET format=""> 1, Throw( "Too many items selected!\!rOnly one selection possible." ),
N Items( SelRows ) == 1,
SelRows = this << Get Selected Rows;
N_PCs = SelRows[1];
);
)
)
)</SET>使用「取得報告」輸出時是否有辦法獲得相同類型的功能?
感謝您的任何反饋!,
DS
你打賭。 該圖已經綁定到表格,因此我認為如果您只需將下面的兩行添加到“設定行更改函數”中,您應該會看到該行為。
tb << Set Row Change Function(
Function( {this},
{SelRows},
SelRows = this << Get Selected Rows;
If(
N Items( SelRows ) > 1, Throw( "Too many items selected!\!rOnly one selection possible." ),
N Items( SelRows ) == 1,
SelRows = this << Get Selected Rows;
NPCs = SelRows[1];
);
// ** Added next two lines **
dt_results << Clear Select;
dt_results << Select rows(SelRows);
)
);你好@ih ,
感謝您的快速回覆和解決方案 - 這正是我正在尋找的。 工作完美。 這是我試圖實現它的較大部分程式碼。 我知道這是一個單獨的主題,但是您是否碰巧知道如何將下面程式碼中的圖形生成器顯示與“獲取為報告”表格框鏈接起來,以便當用戶單擊表格框中的行時它會突出顯示圖形生成器中對應的數據點?順便說一句,我只是使用 Boston Housing 作為範例資料集,其中 mvalue 作為回應,所有其他列作為分區中的預測變量,並且我使用的驗證部分為 0.3。
謝謝!,
DS
Names Default To Here( 1 );
lbWidth = 168;
dt = Open( "$SAMPLE_DATA/Boston Housing.jmp" );
// Expression to store the current settings in global variables
recallRolesS1 = Expr(
::dtchosenRecall = dtchosen
);
// Expression to clear all current settings. KW: Clear
clearRoles = Expr(
Try(
colListY << RemoveAll;
ColListX << RemoveAll;
ColListW << RemoveAll;
ColListF << RemoveAll;
colListV << RemoveAll;
)
);
// Expression to store the current settings in global variables
recallRoles = Expr(
::ycolRecall = colListY << GetItems;
::xcolRecall = colListX << GetItems;
::WcolRecall = colListW << GetItems;
::FcolRecall = colListF << GetItems;
::vcolRecall = colListV << GetItems;
::max_spRecall = max_sp_input << get;
::partVPRecall = partVP_input << Get;
);
//Function to choose the data table to model. KW: choose_data
choose_data_table = Function( {},
list = {};
For( i = 1, i <= N Table(), i++,
list[i] = Data Table( i ) << get name
);
win = New Window( "Select a data table",
<<MODAL> 1, Throw( "Too many items selected!\!rOnly one selection possible." ),
N Items( SelRows ) == 1,
SelRows = this << Get Selected Rows;
NPCs = SelRows[1];
);
)
);
);
Part = Expr(
If(
N Items( vcols ) == 1,
dt_results = New Table( "Partition_Results",
Add Rows( max_sp ),
New Column( "Splits", Numeric, Continuous ),
New Column( "Training RSquare", Numeric, Continuous ),
New Column( "Validation RSquare", Numeric, Continuous ),
New Column( "Training RASE", Numeric, Continuous ),
New Column( "Validation RASE", Numeric, Continuous ),
New Column( "Training N", Numeric, Continuous ),
New Column( "Validation N", Numeric, Continuous ),
New Column( "RSquare Diff", Numeric, Continuous, Formula( "Training RSquare"n - "Validation RSquare"n ) ),
New Column( "Penalized Valid RSquare", Numeric, Continuous, Formula( "Training RSquare"n - 0.05 * "Splits"n ) )
),
N Items( vcols ) == 0 & Is Missing( partVP ) == 0,
dt_results = New Table( "Partition_Results",
Add Rows( max_sp ),
New Column( "Splits", Numeric, Continuous ),
New Column( "Training RSquare", Numeric, Continuous ),
New Column( "Validation RSquare", Numeric, Continuous ),
New Column( "Training RASE", Numeric, Continuous ),
New Column( "Validation RASE", Numeric, Continuous ),
New Column( "Training N", Numeric, Continuous ),
New Column( "Validation N", Numeric, Continuous ),
New Column( "RSquare Diff", Numeric, Continuous, Formula( "Training RSquare"n - "Validation RSquare"n ) ),
New Column( "Penalized Valid RSquare", Numeric, Continuous, Formula( "Validation RSquare"n - 0.05 * "Splits"n ) )
),
N Items( vcols ) == 0,
dt_results = New Table( "Partition_Results",
Add Rows( max_sp ),
New Column( "Splits", Numeric, Continuous ),
New Column( "Training RSquare", Numeric, Continuous ),
New Column( "Training RASE", Numeric, Continuous ),
New Column( "Training N", Numeric, Continuous ),
New Column( "Penalized Train RSquare", Numeric, Continuous, Formula( "Training RSquare"n - 0.05 * "Splits"n ) )
)
);
For( i = 1, i <= max_sp, i++,
dt_results:"Splits"n[i] = i
);
dt_name = dtchosen << Get Name;
For( i = 1, i <= N Rows( dt_results ), i++,
Psplit = dt_results:"Splits"n[i];
str = Eval Insert(
"report = (dtchosen<<PARTITION></PARTITION></MODAL>我想是的,您只需在從 Get are Report() 函數傳回的參考參考中走低一級即可到達該表。嘗試這個:
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Boston Housing.jmp" );
RptWin = New Window( "Data Table as report",
Outline Box("Data Table as Report",
dt_Rpt = dt << Get as Report();
)
);
tb = dt_Rpt[Table Box( 1 )];
tb << Set Shade Headings( 1 );
tb << Append(
Plot Col Box( "",
:mvalue << get values,
<<SET scale=""> 1, Throw( "Too many items selected!\!rOnly one selection possible." ),
N Items( SelRows ) == 1,
SelRows = this << Get Selected Rows;
N_PCs = SelRows[1];
);
)
);</SET>