특정 이름을 가진 모든 세 번째(n+3) 열의 이름을 변경합니다. 100개 이상의 열안녕 모두,
100개 이상의 열에 이름을 지정하려고 합니다. 나는 많은 텍스트-열 작업을 해왔고 동일한 이름을 부여하고 싶은 세 개의 열 집합이 많이 있습니다. 아래를 참조하십시오.

위의 빨간색 선 왼쪽에 내가 갖고 싶은 이름이 있는 열이 표시됩니다. 또한 바꾸려는 이름이 있는 열도 표시됩니다. 보시다시피 n=1(또는 시작하려는 열 번호)에서 시작하여 세 번째 열마다 변경하고 그 이후(n+3) 세 열마다 열 이름을 "pX ". "num_after_pipe"와 "value"도 마찬가지입니다. 그들 모두는 어느 정도까지입니다.
세 열의 모든 세트 이름을 바꾸기 위해 다음 스크립트로 작업하고 있습니다."
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");
.....
어떤 제안?
감사해요!
문안 인사,
알파라이온662
데이터 테이블스크립팅Re: 특정 이름을 가진 모든 세 번째(n+3) 열의 이름을 변경합니다. 100개 이상의 열안녕하세요 @AlphaLion662 ,
이것이 당신이 찾고 있던 것입니까? 열 이름을 어떻게 수정하고 싶은지 모르기 때문에 접두사만 추가했습니다.첫 번째, 두 번째 및 세 번째 변수에서 접두사를 볼 수 있습니다.열 이름 바꾸기는 "라는 메모 아래의 블록에서 발생합니다. 여기에서 열 이름 변경 ".
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: 특정 이름을 가진 모든 세 번째(n+3) 열의 이름을 변경합니다. 100개 이상의 열이봐 StarfruitBob,
한동안 이것저것 만지작거리다가 이 방법이 저에게 도움이 되었습니다. 감사합니다!
Re: 특정 이름을 가진 모든 세 번째(n+3) 열의 이름을 변경합니다. 100개 이상의 열귀하의 경우 루프를 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();
);
);
