將報告輸出保存到數據表中通常會創建很長的列名,這在後續分析中變得很麻煩。 這是一個愚蠢的小腳本,用於從選定列的名稱中替換/刪除文本。
使用方法:選擇要修改的列,運行腳本,輸入需要修改的文本(包括空格),然後輸入要修改的文本(同樣包括空格,留空替換為空)。
顯然,如果沒有打開的數據表,腳本什麼都不做。 如果沒有選擇任何列,即沒有任何列被標識為需要更改,則腳本當前不執行任何操作,但可以添加選擇列的提示。
更新:首先選擇的列名包含在文本框中,以便更容易指示要查找的文本
Here is the updated script (the only change was to add << Return Result, so the Text Box would return what was entered (not sure why it worked before):
//!
// Initialize
Names Default to Here( 1 );
Clear Log();
dt = Current Data Table( );
// Stop the script if no open data tables
If( Is Empty( dt ), Stop());
cols = dt << Get Selected Columns( );
// Stop the script if no columns selected
If( N Items( cols ) == 0, Stop());
// Prompt user for text to remove
eBox1 = New Window(
"Find",
<< Modal,
<< Return Result,
Text Box(
"What text should be removed from the column names
(including spaces, i.e. delete the text you want to keep)?",
Justify Text ("Center"),
Set Width(500)
),
Spacer Box( Size( 12.5, 12.5 ) ),
editBox = Text Edit Box(cols[1] << Get Name()),
editBox << Set Width(500),
Spacer Box( Size( 12.5, 12.5 ) ),
H List Box( Button Box( "OK",
remove this = editBox << Get Text;
// Stop the script if the user doesn't enter any text
If( remove this == "", Stop())
),
Button Box( "Cancel" ),
<< Horizontal Alignment( "Center" )
)
);
// Stop the script if the user hits the cancel button
If( eBox1["Button"] == -1, Print("Canceled"); Stop());
// Prompt user for text to replace
eBox2 = New Window(
"Replace With",
<< Modal,
<< Return Result,
Text Box(
"What should the text be replaced with
(including spaces, or leave blank)?",
Justify Text ("Center"),
Set Width(300)
),
Spacer Box( Size( 12.5, 12.5 ) ),
editBox2 = Text Edit Box(),
editBox2 << Set Width(300),
Spacer Box( Size( 12.5, 12.5 ) ),
H List Box( Button Box( "OK",
replace with = editBox2 << Get Text
),
Button Box( "Cancel" ),
<< Horizontal Alignment( "Center" )
)
);
// Stop the script if the user hits the cancel button
If( eBox2["Button"] == -1, Print("Cancled"); Stop());
// Loop through the columns adding the tag to the end of the existing name
For( i = 1, i <= N Items( cols ), i++,
cols[ i ] << set name( munger(cols[ i ] << get name, 1, remove this, replace with))
); // Next column
// End抱歉這麼久才回复,我忘了我把這個貼在這裡了。 是的,它可以修復。 - 完畢
感謝您的分享。
但是這個很棒的插件不能用在 JMP16 上。
它顯示錯誤消息:刪除對象引用:編輯框<<在訪問或評估“膠水”時獲取下一個
有什麼解決辦法嗎?