0으로 설정된 값을 점으로 바꾸도록 데이터 테이블을 어떻게 변경할 수 있습니까? 점을 0으로 변경하는 스크립트를 찾았지만 대안은 아닙니다.
감사,
좋은 타이밍. 지난 주에 일부 관련 코드를 작업하면서 실행 시간을 단축하고 이미 언급된 내용에 추가하고 싶었습니다.행을 반복하고 하나의 스크립트에서 행렬 방법(위에서 Vince 참조)으로 대체하면 실행 시간이 약 20x-25x 향상되었습니다.다른 스크립트에서 행 가져오기 where()에서 행렬 메서드로 변경하면 거의 2배 향상되었습니다. 하다가 나중에 공유하거나 참고할 수 있도록 아래에 코드를 작성했는데 여기에 올리는 것이 타당해 보입니다. 문자 열의 목록과 함께 Loc()를 사용하면 다른 구문이 사용되며 숫자 열에서 가져온 모든 행렬 변수로 할 수 있는 것처럼 더 복잡한 논리를 작성할 수 없습니다. 그래서 저는 Craige Hales가 공유한 기술을 사용했습니다( 여기 링크 ) 연관 배열과 교차 함수를 사용합니다. 유용하게 사용하시길 바랍니다.
이 스크립트는 데모 목적으로 작성했기 때문에 새 문자 열을 추가하고 거기에 주석을 넣습니다. 여기에 원래 질문이 주어지면 다음과 같은 할당 줄을 바꿀 수 있습니다. c3[rowsMale] = "남성"; ~와 함께 열(dtData, "연령") [rowsMale] = .; 또는 유사.
names default to here(1);
dtData = Open( "$SAMPLE_DATA/Big Class.jmp" );
mAge = column(dtData, "age") << get values(); //a matrix
mHeight = column(dtData, "height") << get values(); //a matrix
lSex = column(dtData, "sex") << get values(); //a list
lName = column(dtData, "name") << get values(); //a list
<BR />//note the results of the Loc() function will return a matrix that corresponds to the rows that match the criteria<BR />
rowsTall = Loc(mHeight > 63); // simple comparison in Loc() function.
c1 = new column("Comments 1","Character");
c1[rowsTall] = "Tall";
rowsTallAndOver13 = Loc( (mHeight > 63) & (mAge > 13)); // can build more complex logic in Loc() function
c2 = new column("Comments 2","Character");
c2[rowsTallAndOver13] = "Tall and 14 or older";
rowsMale = Loc(lSex, "M"); // note syntax is slightly different with Loc() for lists when dealing with character columns.
//rowsMaleNamedRobert = Loc((lSex, "M"), (lName, "Robert")); // Cannot build complex comparisons with Character columns, see below on the intersection and AA's
c3 = new column("Comments 3","Character");
c3[rowsMale] = "Male";
//rowsTall17M = Loc((mHeight > 63) & (mAge == 17) & (lSex == "M") ); // attempt at building complex logic but the syntax is not correct, and can't have lists in a compound comparison
//rowsTall17M = Loc((mHeight > 63) & (mAge == 17) & (lSex, "M") ); // attempt at building complex logic. Syntax is closer to correct, but can't have lists in a compound comparison<BR />//Build numeric comparisons all at once, then do character comparisons one at a time. Only 1 character comparison shown here.
rowsTall17 = Loc((mHeight > 63) & (mAge == 17) ); // Build the numeric parts separate from char column(s)
rowsMale = Loc(lSex, "M"); // Character columns separately. Seems you need one variable per character column, and then intersect them all later.
<BR />//insert above into associative arrays, use intersection function to get the matrices intersection
aa_rowsTall17 = associative array(rowsTall17);
aa_rowsMale = associative array(rowsMale);
intersection = aa_rowsMale; // copy of aa_rowsMale, as intersection gets modified in next line
intersection<<INTERSECT> 63) );
c5 = new column("Comments 5 - using get rows where","Character");
c5[gRowsTallM17] = "Tall, Male, 17";</INTERSECT>
전체 테이블을 수행하려는 경우 jsut 할 수 있습니다.
Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
dt:weight[[1, 5, 6, 8]] = 0; // just setting them to 0
dt:height[[11, 15, 16, 18]] = 0;
wait(2);
// this is the bit you'll want
numeric_cols = dt << Get Column Names("Numeric", "string");
m = dt[0, numeric_cols]; // get the values as a matrix;
m[Loc(m==0)]=.; // set them to missing
dt[0, numeric_cols] = m; // set the data to the matrix다음은 "A"라는 열에 대해 모든 "0"을 누락된 값으로 변환하는 한 가지 방법입니다.
Names Default To Here( 1 );
dt = Current Data Table();
theRows = dt << get rows where( :A == 0 );
Try( :A[theRows] = . );
이 포스팅을 참고하시면 좋을 것 같아요 데이터 테이블을 반복하거나 코드 변경을 사용하거나 Get Rows Where를 사용하여 데이터 테이블의 값을 변경해야 합니까? (그리고 원본 우편 ) 그리고 거기에 토론. 내 기억이 맞다면 999를 누락된 값으로 대체해야 한다는 점이었습니다. 기본 아이디어는 일반적으로 행이나 열을 반복하고 값을 바꾸는 것입니다.