JSL을 사용하여 여러 Y 변수로 GraphBuilder 플롯을 그리는 가장 좋은 방법모두,
여러 매개변수가 있는 GB 플롯을 스크립팅하는 가장 좋은 방법에 대한 정보를 요청하고 싶습니다.
다음과 같은 테이블이 있다고 가정해 보겠습니다.
New Table( "Untitled 140",
Add Rows( 12 ),
New Column( "Category",
Character,
"Nominal",
Set Values( {"A", "A", "A", "B", "B", "B", "C", "C", "C", "D", "D", "D"} )
),
New Column( "Value1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 4, 2, 3, 6, 2, 3, 5, 4, 1, 3, 6] )
),
New Column( "Value2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [6, 3, 5, 2, 8, 6, 5, 2, 6, 3, 5, 4] )
)
)그리고 다음과 같은 플롯을 작성하고 싶습니다.

여기서 자동 생성된 스크립트는 다음과 같습니다.
;Graph Builder(
Size( 522, 450 ),
Show Control Panel( 0 ),
Variables( X( :Category ), Y( :Value1 ), Y( :Value2, Position( 1 ) ) ),
Elements( Bar( X, Y( 1 ), Y( 2 ), Legend( 4 ), Summary Statistic( "Range" ) ) )
)
임의의 수의 Y 열이 있고 이름도 임의적이라는 캐치가 있습니다.
가변성 플롯과 같은 플롯의 경우 다음과 같습니다.
parameters = {:"Value1"n, :"Value2"n};
yExpr = Expr( Y() );
For Each( {value, index}, parameters, Insert Into( yExpr, Name Expr( value ), 1 ) );
Eval(
Substitute(
Expr(
Variability Chart( placeholder, X( :Category ), Std Dev Chart( 0 ) )
),
Expr( placeholder ), Name Expr( yExpr )
)
);여기서 열 이름을 목록으로 받은 다음 Y 표현식을 구성한 다음 차트의 스크립트에 넣습니다. 그것은 나에게 변동성 도표의 목록을 줄 것이지만 그것은 나에게 괜찮습니다.
GB의 경우 동일한 경로를 사용하려면 두 개의 표현식을 구성해야 하는 것처럼 보입니다.
Y( :Value1 ), Y( :Value2, Position( 1 ) )
그리고
Elements( Bar( X, Y( 1 ), Y( 2 ), Legend( 4 ), Summary Statistic( "Range" ) ) )
본질적으로 전체 스크립트입니다.
내 질문: 이 두 줄을 조합하기 위해 식으로 여러 번 대체하는 것보다 더 좋은 방법이 있습니까?
감사해요!
소비자 및 시장 조사Re: JSL을 사용하여 여러 Y 변수로 GraphBuilder 플롯을 그리는 가장 좋은 방법멋진!터치를 추가해 주셔서 감사합니다.내가 직접 시도했으면 좋겠다!
Re: JSL을 사용하여 여러 Y 변수로 GraphBuilder 플롯을 그리는 가장 좋은 방법@pmroz 다음은 Eval(Parse())이 없는 동일한 코드입니다.나는 이것이 훨씬 더 깨끗하다는 데 동의합니다!
Names default to here(1);
dt = New Table( "Test",
Add Rows( 12 ),
New Column( "Category", Character, "Nominal",
Set Values( {"A", "A", "A", "B", "B", "B", "C", "C", "C", "D", "D", "D"} ) ),
New Column( "Value1", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [1, 4, 2, 3, 6, 2, 3, 5, 4, 1, 3, 6] ) ),
New Column( "Value2", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [6, 3, 5, 2, 8, 6, 5, 2, 6, 3, 5, 4] ) ),
New Column( "Value3", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [1, 4, 3, 6, 5, 7, 3, 4, 2, 8, 6, 1] ) )
);
dt_cols = dt << get column references();
remove from(dt_cols, 1); // Remove Category
dts = dt << Stack(invisible,
columns( dt_cols ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" )
);
dts << Graph Builder(
Size( 518, 448 ),
Show Control Panel( 0 ),
Variables( X( :Category ), Y( :Data ), Overlay( :Label ) ),
Elements( Bar( X, Y, Legend( 7 ) ) )
);
Re: JSL을 사용하여 여러 Y 변수로 GraphBuilder 플롯을 그리는 가장 좋은 방법잊지 마세요 스택 명령.eval(parse()) 이 필요하지만 그렇지 않으면 꽤 깨끗합니다.다음은 플롯할 세 개의 열이 있는 예입니다.
dt = New Table( "Test",
Add Rows( 12 ),
New Column( "Category",
Character,
"Nominal",
Set Values( {"A", "A", "A", "B", "B", "B", "C", "C", "C", "D", "D", "D"} )
),
New Column( "Value1",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 4, 2, 3, 6, 2, 3, 5, 4, 1, 3, 6] )
),
New Column( "Value2",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [6, 3, 5, 2, 8, 6, 5, 2, 6, 3, 5, 4] )
),
New Column( "Value3",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 4, 3, 6, 5, 7, 3, 4, 2, 8, 6, 1] )
)
);
dt_cols = dt << get column names(string);
removefrom(dt_cols, 1); // Remove Category
// Create the list of columns, like this: ":Value1, :Value2, :Value3"
col_list = ":" || concat items(dt_cols, ", :");
stack_str = evalinsert(
"\[dts = dt << Stack(invisible,
columns( ^col_list^ ),
Source Label Column( "Label" ),
Stacked Data Column( "Data" ))]\");
eval(parse(stack_str));
dts << Graph Builder(
Size( 518, 448 ),
Show Control Panel( 0 ),
Variables( X( :Category ), Y( :Data ), Overlay( :Label ) ),
Elements( Bar( X, Y, Legend( 7 ) ) )
);

Re: JSL을 사용하여 여러 Y 변수로 GraphBuilder 플롯을 그리는 가장 좋은 방법이것은 여전히 루프를 사용하여 해당 표현식을 작성하지만 인수 목록을 대체하는 대신 연결합니다.
Names default to here(1);
//call another function (f) with the arguments provided in a list (l)
do.call = function({l,f},
Substitute(
Name Expr(l),
Expr({}),
Name Expr(f)
);
);
dt = New Table( "Data",
Add Rows( 12 ),
New Column( "Category", Character, "Nominal",
Set Values( {"A", "A", "A", "B", "B", "B", "C", "C", "C", "D", "D", "D"} )
),
New Column( "Value1", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [1, 4, 2, 3, 6, 2, 3, 5, 4, 1, 3, 6] )
),
New Column( "Value2", Numeric, "Continuous", Format( "Best", 12 ),
Set Values( [6, 3, 5, 2, 8, 6, 5, 2, 6, 3, 5, 4] )
)
);
vars = {:Value1, :Value2};
VarExpr = do.call(
{ X( :Category ) } || transform each({v}, vars, eval expr( Y( Expr( Name Expr( v ) ), Position( 1 ) ) ) ),
expr(Variables())
);
BarExpr = do.call(
{ X } || transform each({v, i}, vars, eval expr( Y( Expr( i ) ) ) ) || { Legend( 4 ), Summary Statistic( "Range" ) },
expr(Bar())
);
Eval( Eval Expr(
dt << Graph Builder(
Size( 522, 450 ),
Show Control Panel( 0 ),
Expr( Name Expr( VarExpr ) ),
Elements( Expr( Name Expr( BarExpr ) ) )
)
) );Re: JSL을 사용하여 여러 Y 변수로 GraphBuilder 플롯을 그리는 가장 좋은 방법나는 일반적으로 그러한 그래프 빌더를 구축하기 위해 당신과 비슷한 방법을 사용했습니다. 이것은 좋은 읽을 거리가 될 것입니다. Re: 표현식을 문자열로 작성하지 않고 이것을 구성할 수 있습니까?
Re: JSL을 사용하여 여러 Y 변수로 GraphBuilder 플롯을 그리는 가장 좋은 방법자 이렇게 해결했는데 더 간단한 방법은 없나요? 이렇게 간단한 것을 스크립팅하기 위해 그런 종류의 복잡성에 들어가야 한다는 것을 믿을 수 없습니다...:
parameters = {:"Value1"n, :"Value2"n};
yExpr = Expr( Y() );
yExprPos = Expr( Y( Position( 1 ) ) );
barExpr = Expr(
Bar( X, Summary Statistic( "Range" ) )
);
yNExpr = Expr( Y() );
variablesExpr = Expr(
Variables( X( :Category ) )
);
For Each( {value, index}, parameters,
Insert Into( yExpr, Name Expr( value ), 1 );
yExprPos = Expr( Y( Position( 1 ) ) );
Insert Into( yExprPos, Name Expr( value ), 1 );
Insert Into( variablesExpr, Name Expr( yExprPos ) );
//This is for Y(1) etc. in Bar()
yNExpr = Expr( Y() );
Insert Into( yNExpr, Name Expr( index ) );
Insert Into( barExpr, Name Expr( yNExpr ), 2 );
);
//Name Expr( yExpr );
Show(Name Expr( variablesExpr ));
Show(Name Expr( barExpr ));
gbExpr = Expr(
Graph Builder( Size( 522, 450 ), Show Control Panel( 0 ), placeholder1, Elements( placeholder2 ) )
);
Eval(
Substitute(
Substitute(
Name Expr(gbExpr),
Expr( placeholder1 ),
Name Expr( variablesExpr )
),
Expr( placeholder2 ),
Name Expr( barExpr )
)
);