通過帶有字符串變量的dispatch控制ANOVA報告輸出你好,
我正在嘗試引用一個字符串變量( colname的 ) 在派遣,但它沒有遵守 OutlineBox, {關閉(0)} (要么關閉(1) )而不是明確寫入字符串時。
非常感謝你的幫助。
莉薇
這是代碼:
For( i = 1, i <= N Items( ColumnNames ), i++,
colname = "Response " || char(colnameames[i]);
Cobj = dt << Fit Model(
Y( colnameames[i] ),
Effects( :Visit, :Group, :Group * :Visit ),
Random Effects( :SubjectNumber[:Group] ),
Personality( "Standard Least Squares" ),
Method( "REML" ),
Emphasis( "Minimal Report" ),
Run(
colnameames[i] << {Analysis of Variance( 0 ), Lack of Fit( 0 ),
Plot Actual by Predicted( 0 ), Plot Regression( 0 ),
Plot Residual by Predicted( 0 ), Plot Effect Leverage( 0 ), {:Visit <<
{LSMeans Plot( 1 ), LSMeans Contrast( [1 0 0 -1] )}, :Group << {LSMeans Plot( 1 ),
LSMeans Contrast( [1 0 0 -1] )}, :Group * :Visit << {LSMeans Plot( 1 )}}
),
SendToReport(
Dispatch(
{colname , "Effect Details", "Visit", "Contrast"},
"Test Detail",
OutlineBox,
{Close( 0 )}
),
Dispatch(
{colname , "Effect Details", "Group", "Contrast"},
"Test Detail",
OutlineBox,
{Close( 0 )}
),
Dispatch(
{colname , "Effect Details"},
"SubjectNumber[Group]",
OutlineBox,
{Close( 1 )}
)
)
);Re:使用字符串變量通過dispatch控制ANOVA報告輸出非常感謝幫忙。我在你的例子中使用了解決方案,它工作了!!
Revtal
Re:使用字符串變量通過dispatch控制ANOVA報告輸出在評估表達式的其餘部分之前,您需要構建包含大綱框名稱的字符串。 您可以使用字符串以幾種不同的方式執行此操作,檢查Parse(Substitute())和Eval Insert(),因為在某些情況下,它們可能是更好的選擇。 但是,一種方法是使用Eval Expr(),如下所示:
嘗試替換Eval(使用Write(Char)(查看日誌以查看實際評估的代碼)。您可以將日誌複製並粘貼到腳本窗口,然後使用“重新格式化腳本”按鈕。
Names default to here( 1 );
dt = Open( "$Sample_data/Iris.jmp" );
targets = {"Sepal length", "Petal length"};
For( i = 1, i <= N Items( targets ), i++,
//Here is a Fit Model expression with some parts contained in Expr()
//First the Fit model 'code' goes to Eval Expr() to evalute only those parts
//contained in Expr(). Then it goes to Eval() to actually run the code.
Eval( Eval Expr(
Fit Model(
Y( targets[i] ),
Effects( :Sepal width, :Petal width ),
Random Effects( :Species ),
NoBounds( 1 ),
Personality( "Standard Least Squares" ),
Method( "REML" ),
Emphasis( "Minimal Report" ),
Run(
:Sepal length << {Summary of Fit( 1 ), Analysis of Variance( 0 ),
Parameter Estimates( 1 ), Lack of Fit( 0 ), Plot Actual by Predicted( 0 ),
Plot Regression( 0 ), Plot Residual by Predicted( 0 ),
Plot Studentized Residuals( 0 ), Plot Effect Leverage( 0 )}
),
SendToReport(
Dispatch(
{ Expr( "Response" || targets[i] ) }, //This is evaluated first
"Parameter Estimates",
OutlineBox,
{Close( 1 )}
),
Dispatch(
{ Expr( "Response" || targets[i] ) }, //This is evaluated first
"REML Variance Component Estimates",
OutlineBox,
{Close( 1 )}
),
Dispatch(
{ Expr( "Response" || targets[i] ) }, //This is evaluated first
"Fixed Effect Tests",
OutlineBox,
{Close( 1 )}
)
)
)
) );
);