在許多程式語言中,可以對列表和矩陣進行索引。 這在 Jmp 中也是可能的:
list= {"A", "B", "C"};
mat=[1,2,3];
list[3]
mat[2]
從 Jmp 13 開始,另一個層級的索引成為可能:數據表下標
如今,用戶可以輕鬆地透過讀寫存取來索引資料表中的條目。
還有第三種索引:顯示樹索引
對於給定的報告,您可以沿著顯示樹向下查找以識別特定物件:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
Size( 437, 413 ),
Graph Spacing( 4 ),
Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
)
Report(gb)["Graph Builder"][AxisBox(1)]
也許 Jmp 中有更多地方索引可以幫助使用者進行日常工作...
對於表達式來說,沿著樹走下去要複雜得多:
取得 Y 變數:重量從
myExpr=Expr(gb = dt << Graph Builder(
Size( 437, 413 ),
Graph Spacing( 4 ),
Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
));
一個人必須使用
Arg(Arg(Arg(Arg(Arg(myExpr,2),2),3),2),1) // :weight
非常脆弱!!!!
解決方法:將變數表達式轉換為列表並使用列表索引:
myExpr=Expr(Variables( X( :height ), Y( :weight ), Overlay( :sex ) ))
Substitute(Name Expr(myExpr),Expr(Variables()),Expr(List()))["Y"];
但也有幾個缺點:
- 僅適用於單級 - 扁平層次結構
- 僅找到第一個命名參數,具有相同標識符的其他命名參數將被忽略:
myExpr=Expr(Variables( X( :height ), Y( :weight ),Y(:height ), Overlay( :sex ) ));
Substitute(Name Expr(myExpr),Expr(Variables()),Expr(List()))["Y"]; // returns :weight, ignores Y(:height)
- 只傳回第一個參數,其他參數會遺失
myExpr = Expr(Distribution(columns(:height, :weight)));
Substitute(Name Expr(myExpr),Expr(Distribution()),Expr(List()))["columns"];
//returns :height -> :weight gets lost
是否有可能類似於顯示樹索引來攀爬表達式樹?
就像是:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
myExpr=Expr(gb = dt << Graph Builder(
Size( 437, 413 ),
Graph Spacing( 4 ),
Variables( X( :height ), Y( :weight ), Y(:height), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
));
//instead of:
Arg(Arg(Arg(Arg(Arg(myExpr,2),2),3),3),1)
<BR />// I want to use:
myExpr[2][2["Variables"]["Y"(2)][1]
//assign // send // Graph Builder // Variables