“Group Columns()”的變量列組名稱大家好,
我試圖根據字符串列表選擇列,並將這些列轉儲到也基於該列表的組中。
這是我正在使用的代碼:
dt = Current Data Table();<BR />// phase names by which we want to group
groupnames = {"Centering", "Dwell", "Capture", "Locking"};
// all column names in the table
allcols = dt << Get Column Names();
For( i = 1, i <= N Items( groupnames ), i++,
curgroup = {};
dt << Clear Column Selection;
// get all cols with the phase name
For( j = 1, j <= N Items( allcols ), j++,
If( Contains( allcols[j], groupnames[i] ),
As Column( allcols[j] ) << Set Selected( 1 );
//Insert Into(curgroup, allcols[j]);
);
);
// make a new group from these columns
//dt << Group Columns(char(groupnames[i]), curgroup);
dt << Group Columns( groupnames[i] );
);我收到錯誤“JMP 無法確定要根據給定腳本進行分組的列。”
如果我將最後一行更改為 dt << Group Columns (“fixed string”) 之類的內容,它將起作用(但它們都在同一組中)。我不確定我做錯了什麼。groupnames[i] 應該是一個字符串(對嗎?),這是 Group Columns() 的預期輸入。
謝謝,
克里斯托
回复:“Group Columns()”的變量列組名稱再次感謝。我只是在看 html 文檔,而不是書籍。
回复:“Group Columns()”的變量列組名稱以下是如何獲取有關轉義字符的文檔。去
幫助==>書籍==>腳本指南
然後進行頁面搜索
\!
它將直接帶您進入轉義字符表
回复:“Group Columns()”的變量列組名稱Eval Insert() 計算字符串中的變量。 字符串中的變量用“^”字符包裹。 Parse() 將字符串轉換為表達式。 Eval() 計算表達式。
因此,基本上,您將表達式構建為字符串,並在字符串中解析變量值,將字符串解析為表達式,然後計算該表達式。
回复:“Group Columns()”的變量列組名稱謝謝,就這樣搞定了!有沒有關於不同轉義序列用途的文檔的指針?Parse() 的“幫助”不太有用。
回复:“Group Columns()”的變量列組名稱有時,JMP 在評估應解析為預期參數類型的變量時會很奇怪。我通常盡量不這樣做,但您通常可以使用 Eval-Parse-Eval Insert 序列來解決這些問題。這總感覺有點像黑客,但它就像帶有 JSL 的管道膠帶。
dt = Current Data Table();// phase names by which we want to group
groupnames = {"Centering", "Dwell", "Capture", "Locking"};
// all column names in the table
allcols = dt << Get Column Names();
For( i = 1, i <= N Items( groupnames ), i++,
curgroup = {};
// get all cols with the phase name
For( j = 1, j <= N Items( allcols ), j++,
If( Contains( allcols[j], groupnames[i] ) > 0,
Insert Into(curgroup, allcols[j]);
);
);
// make a new group from these columns
Eval(Parse(Eval Insert("\[dt << Group Columns( "^groupnames[i]^", curgroup )]\")));
);