大家好,
我最近開始編寫 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();
)
);
我遇到的唯一問題是如何像使用表格框一樣在新窗口中使用輸出。
在 Table Box 環境中,您可以設置函數,以便它返回您選擇的信息,並且可以在代碼中進一步使用這些信息。 但是,Get As Report 命令不允許您這樣做。 至少我還沒有找到任何有關如何執行此操作的示例,並且腳本索引中關於 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>有沒有辦法在使用 Get As Report 輸出時獲得相同類型的功能?
感謝您的任何反饋!,
DS
我認為是這樣,您只需要在從 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>你好@ih ,
感謝您的快速回復和解決方案——這正是我正在尋找的。 完美運行。 這是我試圖實現它的較大代碼段。 我知道這是一個單獨的主題,但您是否碰巧知道我如何將下面代碼中的圖形構建器顯示與“獲取為報告”表格框鏈接起來,以便當用戶單擊表格框中的行時它會突出顯示圖形構建器中的相應數據點?順便說一下,我只是使用波士頓住房作為樣本數據集,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>你打賭。 該圖已經與表格相關聯,所以我認為如果您只是將下面的兩行添加到您的 Set Row Change Function 中,您應該會看到這種行為。
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);
)
);