特定の名前を持つ 3 番目 (n+3) 列ごとに名前を変更します。 100以上の列こんにちは、みんな、
100以上の列に名前を付けようとしています。 私はたくさんのテキストから列への変換を行ってきましたが、同じ名前を付けたい 3 つの列のセットがたくさんあります。 下記参照:

上記は、赤い線の左側に、付けたい名前の列を示しています。 また、置き換えたい名前の列も表示されます。 ご覧のとおり、n=1 (または開始したい任意の列番号) から 3 列ごとに変更し、その後 3 列ごと (n+3) に列の名前を「pX」に変更したいと思います。 "。 「num_after_pipe」と「value」についても同様です。 それらのすべてがポイントまで。
次のスクリプトを使用して、3 つの列のすべてのセットの名前を変更しています。」
dt_stack:"Data 1"n+3<<Set Name("pX");
dt_stack:"Data 2"n<<Set Name("num_after_pipe");
dt_stack:"Data 3"n<<Set Name("value");
dt_stack:"Data 4"n<<Set Name("pX");
dt_stack:"Data 5"n<<Set Name("num_after_pipe");
dt_stack:"Data 6"n<<Set Name("value");
dt_stack:"Data 7"n<<Set Name("pX");
dt_stack:"Data 8"n<<Set Name("num_after_pipe");
.....
助言がありますか?
ありがとう!
よろしく、
AlphaLion662
データ表スクリプティングRe: 特定の名前を持つ 3 つおき (n+3) 列の名前を変更します。 100以上の列こんにちは@AlphaLion662 、
これはあなたが探していたものですか? 列名を変更する方法がわからないので、プレフィックスを追加しただけです。変数 first、second、および third のプレフィックスを確認できます。列の名前変更は、メモの下のブロックで行われます。列名変更はこちら"。
Names default to here(1);
clear log();
dt = open( "$SAMPLE_DATA/Arrhythmia.jmp" );
// Gets all column names in a list
allcols = dt << Get column names();
// Stores the number of columns
numcols = N Items( allcols );
// Some modifier to column names
first = "Tree";
second = "Car";
third = "Star";
For( i = 1, i <= numcols, i++,
// Temporarly stores the column name for later usage
temp = column( dt, allcols[i] ) << Get Name;
if(
// First col, then every 3rd col thereafter
i == 1 | Modulo( i - 1, 3 ) == 0,
// Col name change here
col_Name1 = column(dt,i) << Get Name;
newname1 = first || "_" || col_Name1;
eval( column(allcols[i] ) ) << Set Name( newname1 ),
// Second col, then every 3rd col thereafter
i == 2 | Modulo( i - 2, 3 ) == 0, //( i - 2 ) % 3
// Col name change here
col_Name2 = column(dt,i) << Get Name;
newname2 = second || "_" || col_Name2;
eval( column(allcols[i] ) ) << Set Name( newname2 ),
// Third col, then every 3rd col thereafter
i == 3 | Modulo( i - 3, 3 ) == 0,
// Col name change here
col_Name3 = column(dt,i) << Get Name;
newname3 = third || "_" || col_Name3;
eval( column(allcols[i] ) ) << Set Name( newname3 ),
);
);
Re: 特定の名前を持つ 3 つおき (n+3) 列の名前を変更します。 100以上の列ねえスターフルーツボブ、
しばらくいじった後、これでうまくいきました。 ありがとう!
Re: 特定の名前を持つ 3 つおき (n+3) 列の名前を変更します。 100以上の列あなたの場合、3秒でループをインクリメントし、単一のループで同時に3つの列を設定することもできます
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Probe.jmp");
dt << Ungroup Columns(); // easier to see what is going on if we remove Responses column group
start_col_idx = 4;
colnames = {"px", "num_after_pipe", "value"};
For(i = start_col_idx, i <= N Cols(dt), i = i + 3, // we can increment in 3s
Try( // lazy try-catch to exit when we cannot set more column names
Column(i) << Set Name(colnames[1]);
Column(i + 1) << Set Name(colnames[2]);
Column(i + 2) << Set Name(colnames[3]);
,
show(exception_msg);
break();
);
);
