Re: 목록의 문자열을 새 열의 수식 본문으로 변환하는 스크립트입니다.이 예에서 모든 "수식"은 "(" 이후에 시작하는 열 이름을 가지므로 "(:"으로 대체한 다음 Parse를 사용할 수 있습니다.
Names Default To Here(1);
dtinit = Open("$SAMPLE_DATA/Bands Data.jmp");
dtfeat = New Table("features",
Add Rows(14),
New Column("Term",
Character,
"Nominal",
Set Property("ID Column", 1),
Set Values(
{"press speed", "(roller durometer-34.5151)*(anode space ratio-102.914)", "(proof cut-44.9671)*(blade pressure-30.8904)",
"(anode space ratio-102.914)*(chrome content-99.6164)", "(humidity-78.6849)*(press speed-1851.21)", "roller durometer",
"(roller durometer-34.5151)*(current density-39.0164)", "(humidity-78.6849)*(wax-2.4037)",
"(wax-2.4037)*(chrome content-99.6164)", "(viscosity-50.7836)*(press speed-1851.21)", "(wax-2.4037)*(hardener-0.96014)",
"(roughness-0.71969)*(current density-39.0164)", "(humidity-78.6849)*(ink pct-55.6473)",
"(blade pressure-30.8904)*(press speed-1851.21)"}
)
),
Set Label Columns(:Term)
);
dtfeat << New Column("interaction", Character, "Nominal", Formula(If(Starts With(:term, "("), :term, ""))) <<
Move Selected Columns({:interaction}, after(:term));
value = dtfeat:interaction << get values();
uniqueinteraction = Associative Array(value) << get keys;
For Each({uniq}, uniqueinteraction,
f_str = Substitute(uniq, "(", "(:");
If(IsMissing(f_str),
continue();
);
Eval(EvalExpr(
dtinit << New Column(uniq, Numeric, "Continuous",
Formula(Expr(Parse(f_str)))
)));
);
Eval Insert, Eval Expr, Parse 및 Substitute를 사용하여 한 표현식을 다른 표현식에 삽입
Re: 목록의 문자열을 새 열의 수식 본문으로 변환하는 스크립트입니다.뛰어난. 트릭을했다. 정말 감사합니다.
목록의 문자열을 새 열의 수식 본문으로 변환하는 스크립트입니다.적합 플랫폼을 사용하고 일부 상호 작용(계승...)을 찾은 후 일부 상호 작용하는 열을 식별하는 프로세스를 따릅니다. 상호 작용의 결과 용어(예: cA*0.1+cB*0.3)를 시작점으로 사용하여 해당 용어에서 열 수식을 자동으로 생성하려고 합니다. "cA*0.1+cB*0.3"과 같은 문자열의 내용을 사용하는 방법을 찾는 데 어려움을 겪고 있습니다. 여기서 cA와 cB는 새 수식을 작성하기 위해 테이블에 있는 2개의 열 이름을 나타냅니다.
스크립트의 마지막 부분은 수식을 생성하지만 해당 내용을 평가하는 대신 문자열의 내용을 나타낼 뿐입니다.
어떤 제안이라도 대단히 감사하겠습니다.
세바스티앙
names default to here(1);
clear log();
dtinit=Open( "$SAMPLE_DATA/Bands Data.jmp" );
// Make TableBox into a Data Table
// → Data Table( "Untitled 3" )
//terms tables resulting from a generalized regression taking into consideration term interaction.
dtfeat = New Table( "features",
Add Rows( 14 ),
New Column( "Term",
Character,
"Nominal",
Set Property( "ID Column", 1 ),
Set Values(
{"press speed", "(roller durometer-34.5151)*(anode space ratio-102.914)", "(proof cut-44.9671)*(blade pressure-30.8904)",
"(anode space ratio-102.914)*(chrome content-99.6164)", "(humidity-78.6849)*(press speed-1851.21)", "roller durometer",
"(roller durometer-34.5151)*(current density-39.0164)", "(humidity-78.6849)*(wax-2.4037)", "(wax-2.4037)*(chrome content-99.6164)",
"(viscosity-50.7836)*(press speed-1851.21)", "(wax-2.4037)*(hardener-0.96014)", "(roughness-0.71969)*(current density-39.0164)",
"(humidity-78.6849)*(ink pct-55.6473)", "(blade pressure-30.8904)*(press speed-1851.21)"}
)
),
Set Label Columns( :Term )
);
//Identifies interacting terms
// New column: interaction
dtfeat << New Column( "interaction", Character, "Nominal", Formula( If( Starts With( :term, "(" ), :term, "" ) ) ) <<
Move Selected Columns( {:interaction}, after( :term ) );
value = dtfeat:interaction << get values();
uniqueinteraction = Associative Array( value ) << get keys;
nvinteract = N Items( uniqueinteraction );
//Will create a column named after the interacting terms
//Should apply a formula based on the interacting terms
//However, not sure how to extract the string from the list 'uniqueinteraction' so that is it not seen as a string but rather as 'formula instruction' where some portion of the term is recognized as a column namealready present in the original table
For( i = 1, i <= nvinteract, i++,
dtinit << New Column( uniqueinteraction[i], Numeric, "Continuous", Format( "Best", 12 ), Formula( Eval( uniqueinteraction[i] ) )
소비자 및 시장 조사