根據匹配的列名稱突出顯示單元格我有一個腳本,將表中每個 Studentized 列的最小值塗成黃色。 我還想突出顯示原始列中與這些值相鄰的值。 例如,對於學生化殘渣休息脈衝,休息脈衝列中與 -2.321144119 相鄰的單元格,即 44。 我怎樣才能在jsl中做到這一點? 正則表達式或匹配有幫助嗎? 謝謝
dt = current data table();
col = dt << get column names( string );
nc = N Items( col );
For( i = 1, i <= nc, i++,
Cols = Column(dt,i);
If( Contains( col[i], "Studentized Resid" ),
Min = dt << get rows where(as column(Cols)==(Col Min( Cols )));
Cols << color cells(Yellow, Min);
)
);
我正在尋找這樣的東西:

回复:根據匹配的列名稱突出顯示單元格@傑夫·珀金森嗨,傑夫,我已經解決了子字符串部分。 不過謝謝!!回复:根據匹配的列名稱突出顯示單元格@tx尼爾森你的意思是這樣的嗎?
dt = Current Data Table();
// I changed the name from "col" to colNameList to keep from
// it being confused with the variable "Cols". It isn't
// confusing to JMP, just to me
colNameList = dt << get column names( string );
nc = N Items( colNameLIst );
// Loop across all columns
For( i = 1, i <= nc, i++,
// Create a variable that contains the "column" representation
// of the column name string value
Cols = Column( dt, i );
// If the column name starts with the string "Studentized Resid"
// and if so, then process
// I changed this because your Substr() function below indicates
// that the column with "Studentized Resid" will be at the beginning
If( Left( colNameList[i], 17 ) == "Studentized Resid",
// Find the minimum value for the column
MinValue = Col Min( Cols );
// Find all of the rows that have the minimum value. There
// could be more than one row with the minimum value, but this
// code only uses the first row
MinRows = dt << get rows where( As Column( Cols ) == MinValue );
// Theoretically, there should always be a matching value for this,
// but it is a good way to make sure the code will not fail. Also,
// if you ever want to deal with the posibility of more than one
// row matching the minimum, you would do it using this type of
// code structure
If( N Rows( MinRows ) > 0,
Cols << color cells( Yellow, MinRows ),
//column( Substr( colNameList[i], 19 ) ) << color cells( Yellow, MinRows )
);<BR /> column( Substr( colNameList[i], 19 ) ) << color cells( Yellow, MinRows )
)
);
我成功了。 非常感謝指導..
回复:根據匹配的列名稱突出顯示單元格我可能沒理解你的問題。如果您想為包含“Studentized .....”的列中找到的最小值附近的單元格著色,那麼您所要做的就是這樣做。您有列名稱列表......colNamesList,並且您正在瀏覽這些列。當您找到其中包含“Studentized......”的列時,您會找到要著色的另一列的名稱以及最小值的行。這意味著,您還知道與您要著色的單元格相鄰的單元格......
column( Substr( colNameList[i], 19 ) ) << << color cells( Yellow, MinRows )<BR />
如果您在“Studentized......”列的著色之後添加此內容,它將為相應的單元格著色
回复:根據匹配的列名稱突出顯示單元格是個子字符串()功能你缺少什麼?
resid_colname="Studentized Resid Rest Pulse";
//There are 19 characters in "Studentized Resid "
orig_colname = substr(resid_colname, 19);
show(orig_colname);
/*:
orig_colname = "Rest Pulse";
回复:根據匹配的列名稱突出顯示單元格@tx尼爾森嗨吉姆,如果我在這裡遺漏了什麼,我很抱歉。 我還想突出顯示每個學生化專欄的相鄰原始專欄。 我無法完成這項工作。
回复:根據匹配的列名稱突出顯示單元格這是對腳本的簡單修改。它適用於您的示例數據,並且應適用於數據表中盡可能多的列
dt = Current Data Table();
// I changed the name from "col" to colNameList to keep from
// it being confused with the variable "Cols". It isn't
// confusing to JMP, just to me
colNameList = dt << get column names( string );
nc = N Items( colNameLIst );
// Loop across all columns
For( i = 1, i <= nc, i++,
// Create a variable that contains the "column" representation
// of the column name string value
Cols = Column( dt, i );
// If the column name starts with the string "Studentized Resid"
// and if so, then process
// I changed this because your Substr() function below indicates
// that the column with "Studentized Resid" will be at the beginning
If( Left( colNameList[i], 17 ) == "Studentized Resid",
// Find the minimum value for the column
MinValue = Col Min( Cols );
// Find all of the rows that have the minimum value. There
// could be more than one row with the minimum value, but this
// code only uses the first row
MinRows = dt << get rows where( As Column( Cols ) == MinValue );
// Theoretically, there should always be a matching value for this,
// but it is a good way to make sure the code will not fail. Also,
// if you ever want to deal with the posibility of more than one
// row matching the minimum, you would do it using this type of
// code structure
If( N Rows( MinRows ) > 0,
Cols << color cells( Yellow, MinRows )
);
// Output the requested values
Show( Substr( colNameList[i], 19 ), Cols[MinRows[1]] );
);
);
回复:根據匹配的列名稱突出顯示單元格我仍然無法弄清楚如何解決這個問題。 我查看了其他問題和腳本指南以找到我最近的腳本。
這是我最近的腳本:
dt = current data table();
col = dt << get column names( string );
nc = N Items( col );
For( i = 1, i <= nc, i++,
Cols = Column(dt,i);
If( Contains( col[i], "Studentized Resid" ),
Min = dt << get rows where(as column(Cols)==(Col Min( Cols )));
Cols << color cells(Yellow, Min);
//show(Loc())
MinValue = Col Min(Cols);
ColValue = As List(Cols << Get Values);
show(Loc(ColValue,MinValue));
show(substr(col[i], 19,100));
)
);
如果有人可以向我展示如何使用 Substring 方法來匹配列,我將非常感激。 先感謝您。
回复:根據匹配的列名稱突出顯示單元格這聽起來是一個合理的方法。
回复:根據匹配的列名稱突出顯示單元格所有具有/匹配 Studentized 列的原始列都將突出顯示。 我正在查看書寫指南,並一直在嘗試使用正則表達式匹配以及子字符串來提取其中不包含“學生化殘差”的列名稱。 我也在此處保留突出顯示列的行號列表,希望它有助於實現我想要的。 任何更好的方法將不勝感激。@tx尼爾森
回复:根據匹配的列名稱突出顯示單元格您如何設想需要處理哪些列的輸入?
您讀過腳本指南嗎?書中有很多例子可以給你一些想法。
幫助==>書籍==>腳本指南
回复:根據匹配的列名稱突出顯示單元格@pmroz謝謝您的回复,但是,我正在尋找一個更動態的解決方案來解決這個問題,因為我可能有
a) 很多列
b) 將來的不同列名稱。
是否有任何 JMP 函數可以完成該任務? 謝謝
回复:根據匹配的列名稱突出顯示單元格這是使用硬編碼列名稱的一種方法:
dt = Current Data Table();
col = dt << get column names( string );
nc = N Items( col );
For( i = 1, i <= nc, i++,
Cols = Column( dt, i );
If( Contains( col[i], "Studentized Resid" ),
Min = dt << get rows where( As Column( Cols ) == (Col Min( Cols )) );
Cols << color cells( Yellow, Min );
:Rest Pulse << color cells( Yellow, Min );
:Run Pulse << color cells( Yellow, Min );
:Max Pulse << color cells( Yellow, Min );
);
);