열의 조건부 개수꽤 많은 열(>100)이 있는 테이블이 있습니다. 1보다 큰 행의 열 수를 계산하는 열을 만들려고 합니다. 그렇게 하려면 공식을 어떻게 작성해야 합니까? 아래는 예제 테이블의 작은 그림입니다.
이것이 독립형 JSL 스크립트가 아닌 테이블에 놓을 수 있는 공식이라면 더 좋을 것입니다.
데이터 테이블스크립팅Re: 열 전체의 조건부 개수한 가지 방법은 다음과 같습니다.
NamesDefaultToHere(1);
// Build a table
nr = 20; // Number of rows
nc = 10; // Number of columns
dt = AsTable(J(nr, nc, RandomNormal(1, 1)));
dt << setName("Above and Below One");
// Find out what columns are in the table
cols = dt << getColumnNames("String");
// Build an expression to be used as the formula:
// Sum the results of an 'if' clause for each column that exists
form = Expr(Add());
for(c=1, c<=NItems(cols), c++,
ifClause = Expr(If(columnTBD > 1, 1, 0));
SubstituteInto(ifClause, Expr(columnTBD), Parse(":"||cols[c]));
InsertInto(form, NameExpr(ifClause));
);
// Inspect the resulting formula
Print(form);
// Add the formula column
fc = dt << NewColumn("Count Above One", Numeric, Ordinal, Formula(NameExpr(form)));Re: 열 전체에 걸친 조건부 카운트데이터 업데이트를 용이하게 하기 위해 입력 열 중 하나(여기서는 height )를 더미로 열 수식에 추가할 수 있습니다. 그러면 JMP가 이 열을 모니터링합니다. 업데이트를 트리거하려면 이 열의 값을 편집하기만 하면 됩니다.
또한, 데이터 테이블 "access"와 열 정의를 상수 로 넣을 수 있습니다.
Open( "$SAMPLE_DATA/Big Class.jmp" );
New Column( "values > 60",
Formula(
As Constant(
dt = Current Data Table();
//cols = Index(4,5);
cols = {"height", "weight"};
);
:height;
Sum( dt[Row(), cols] > 60 );
)
);