Char()關於交互效果我很難相信以前沒有問過,必須搜索錯誤的關鍵字。
背景:我假設用戶已運行Fit Model並將感興趣的結果作為腳本保存到數據表中。我編寫了JSL來從保存的腳本中提取Effects()參數。我們假設我們有效果(:A,:B:,:A *:B)。
我已經編寫了JSL來獲取這個結果(只要我不在模型的效果列表中使用Transform Column() - 這將創建一個全新的蠕蟲):
testList = {:A, :B, :A*:B};我的當前任務:我想編寫JSL以使我的用戶能夠選擇這三種效果中的一種。
現狀:到目前為止,我所做的是:
win = New Window( "Test", Panel Box( "Choose an Effect", Radio Box( testList ) ) );
如果我運行它,我會得到一個帶有效果“A”,“B”和“Multiply”的Radio Box。很明顯,Display Box選擇將Head()拉出第三個效果,而不是簡單地顯示“A * B”。
可能的解決方案:我想我可以通過編寫循環來檢查Head(testList [i])==“Multiply()”,如果是,然後編寫另一個循環來提取每個Arg(testList [i],j),將它們轉換為字符,將它們放在另一個列表中,將Concat Items()轉換為“*”分隔符。
問題:是否有比這更直接的路線會給我一個帶有效果“A”,“B”和“A * B”的收音機盒?
Re:Char()關於交互效果這就是我想出的。我決定建立一個準系統標準最小二乘,而不是替代人格,因為我不知道某些適合模型人物是否可能包含在標準最小二乘中不起作用的消息。
script = (Current Data Table() << Get Property("Fit Model"));
scriptAsStandardLeastSquares = Expr(Fit Model());
nFitModelArgs = N Arg( script );
For( k = 1, k <= nFitModelArgs, k++,
headString = Char( Head( Arg( script, k ) ) );
If(
headString == "Y" | headString == "Effects", Insert Into(scriptAsStandardLeastSquares, Arg(script, k))
);
);
Insert Into(scriptAsStandardLeastSquares, Expr(Run()));
Insert Into(scriptAsStandardLeastSquares, Expr(Personality("Standard Least Squares")));
Insert Into(scriptAsStandardLeastSquares, Expr(invisible));
fm = Eval(scriptAsStandardLeastSquares);
effectList = (fm << Get Effect Names);
fm << Close Window;Re:Char()關於交互效果這是我使用的那種代碼:
// s = model script
// easier to manipulate strings
str = Char(NameExpr(s));
// ensure there is a variable to store a reference to the model object
str = "mwin=" || str;<BR /><BR /><BR />// run in the background
SubstituteInto(str,"Fit Model(","Fit Model(Invisible,");
// change emphasis (could also change personality)
pattern = "Emphasis(" + PatArb() + ")" + PatRem();
replace = "Emphasis( Minimal Report ), Run)";
Pat Match(strScript, pattern, replace);
// execute and retrieve results
Eval(Parse(str));
effects = mwin << Get Effect Names;Re:Char()關於交互效果不,這不行。假設我有一位科學家故意在列名中使用冒號(也許代表一個比例)。然後是JSL @txnelson 可能看起來像這樣:
testList = {:Name("A:total"), :Name("B:total"), :Name("A:total") * :Name("B:total")};
newtestlist = testList;
For( i = 1, i <= N Items( testlist ), i++,
newtestlist[i] = Substitute(Char( testlist[i] ), ":", "")
);
win = New Window( "Test", Panel Box( "Choose an Effect", Radio Box( newtestList ) ) );然後收音機盒給出Atotal,Btotal和看起來非常難看的名字(“Atotal”)*名字(“Btotal”)。
不,我想我會更喜歡Get Effect Names消息,只要我可以讓它工作。我想我正在重寫保存到數據表的腳本以強制標準最小二乘法,所以我可以得到名字。
Re:Char()關於交互效果一旦他們“被追逐”,你就可以做一個S. ubstituteInto 刪除冒號
Re:Char()關於交互效果雖然也許我可以簡單地重新編寫Fit Model腳本來強制標準最小二乘的個性並運行(錯誤的)模型到足以讓我獲得效果名稱?
Re:Char()關於交互效果這對我的應用來說實際上非常有前景,但只適用於Fit Least Squares的個性。不幸的是,我需要的東西可以在Fit Least Squares中運行,但也可以使用Fit Mixed和Generalized Regression。
Re:Char()關於交互效果這有效但留下了冒號。如果列名包含強制JMP在Name()函數中包裝列名的字符,這也會變得非常難看。
Re:Char()關於交互效果我以前用以下方式解決了這個問題
testList = {:A, :B, :A * :B};
newtestlist = testList;
For( i = 1, i <= N Items( testlist ), i++,
newtestlist[i] = Char( testlist[i] )
);
win = New Window( "Test", Panel Box( "Choose an Effect", Radio Box( newtestList ) ) );Re:Char()關於交互效果有時間接路線更容易。 由於您有腳本,在後台運行它將獲取效果名稱發送到適合模型對象,然後您有可用於單選按鈕的列表。