使用特殊名稱更改列數據類型我喜歡編寫一個腳本來獲取以“WIFI”和“BR”開頭的列名,然後將建模類型更改為“連續”)。像貝爾沃這樣的東西
當前數據表 ();
col_list = dt << 獲取列名稱 ( “無線上網” , “BR” );
col_list << 設置建模類型 ( “連續” );
你能幫助我嗎 ?謝謝
Re:使用特殊名稱更改列數據類型我不認為您選擇的“解決方案”的響應是解決方案。
Re:使用特殊名稱更改列數據類型非常感謝。它工作正常。
Re:使用特殊名稱更改列數據類型接得好 @txnelson 。 除了簡單的匹配,我默認使用正則表達式。 因此,我提出了另一種選擇:
dt = Open( "$Sample_data/iris.jmp" );
cols = dt << Get column Names();
for( i = 1, i <= N Items( cols ), i++,
if( !Is missing(Regex( char( cols[i] ) , "^(sepal|width)(.*)", "\0", IGNORECASE) ),
Column( dt, cols[i] ) << Set Modeling Type( "Nominal" );
)
);
Re:使用特殊名稱更改列數據類型我帶著少量的自由 @ih JSL。 既然你指定了,你正在尋找具有特定字符串值“開始”的列名,我會通過指定Contains返回值必須為1來確保這一點,表明在第1列中找到了值。
dt = Open( "$Sample_data/iris.jmp" );
cols = dt << Get column Names();
for( i = 1, i <= N Items( cols ), i++,
if( contains( uppercase( cols[i] ), "SEPAL" ) ==1 |
contains( uppercase( cols[i] ), "WIDTH" ) == 1
,
Column( dt, cols[i] ) << Set Modeling Type( "Nominal" );
)
);
您也可以選擇以下方法,我發現它實際上更具可讀性
Names Default to Here( 1 );
dt = Open( "$Sample_data/iris.jmp" );
cols = dt << Get column Names();
for( i = 1, i <= N Items( cols ), i++,
if( Left( uppercase( cols[i] ), 5 ) == "SEPAL" |
Left( uppercase( cols[i] ), 5 ) == "WIDTH"
,
Column( dt, cols[i] ) << Set Modeling Type( "Nominal" );
)
);
Re:使用特殊名稱更改列數據類型也許是這樣的?
Names default to here ( 1 );
dt = Open( "$Sample_data/iris.jmp" );
cols = dt << Get column Names();
for( i = 1, i <= N Items( cols ), i++,
if( contains( uppercase( cols[i] ), "SEPAL" ) |
contains( uppercase( cols[i] ), "WIDTH" )
,
Column( dt, cols[i] ) << Set Modeling Type( "Nominal" );
)
);