Espressione del Taylor Graph BuilderCara comunità,
Vorrei creare uno script Graph Builder (inserirlo come script in una nuova tabella) che contenga un lungo elenco di variabili y.
Il mio primo tentativo è stato quello di manipolare le espressioni, ma non ha funzionato come previsto.
Qualcuno può spiegare qual è un buon modo per scrivere quella sceneggiatura?
L'esempio seguente contiene anche il mio metodo attuale, ovvero creare l'istanza GB e aggiungere le variabili y in seguito.
Grazie e distinti saluti,
Names Default To Here( 1 );
cdt = Open( "$SAMPLE_DATA\Big Class.jmp" );
col_lst = cdt << get column names( Continuous, "String" );
gb_expr = Expr(
cdt << Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( :height ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 4 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 5 ) ) )
)
);
// this does not work, Expr() does not accept comma separated items
// Substitute Into( gb_expr, Expr( Y( :height ) ), Expr( Y( :height ), Y( :weight ) ) );
// gb_obj = gb_expr;
// this works
// creating GB instance
gb_obj = cdt << Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables( X( :age )),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 4 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 5 ) ) )
);
// adding Y's
For Each( {ycol}, col_lst, Eval( Parse( Eval Insert( "gb_obj << variables( Y(:^ycol^ ))" ) ) ) );
// this I would like to create directly, w/o large parse/eval parts, that are bad for maintenance
my_target_expression = gb_obj << get script();
Automazione e scriptingRe: Espressione Taylor Graph BuilderQuesta piccola modifica per usare Eval(Eval Expr()) potrebbe fornirti ciò che desideri
Names Default To Here( 1 );
cdt = Open( "$SAMPLE_DATA\Big Class.jmp" );
col_lst = cdt << get column names( Continuous, "String" );
gb_expr = Expr(
cdt << Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables( X( :age ), Y( :height ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 4 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 5 ) ) )
)
);
// this does not work, Expr() does not accept comma separated items
// Substitute Into( gb_expr, Expr( Y( :height ) ), Expr( Y( :height ), Y( :weight ) ) );
// gb_obj = gb_expr;
// this works
// creating GB instance
gb_obj = cdt << Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables( X( :age ) ),
Elements( Position( 1, 1 ), Points( X, Y, Legend( 4 ) ) ),
Elements( Position( 1, 2 ), Points( X, Y, Legend( 5 ) ) )
);
// adding Y's
For Each( {ycol}, col_lst,
Eval( Eval Expr( gb_obj << variables( Y( Expr( ycol ) ) ) ) )
);
// this I would like to create directly, w/o large parse/eval parts, that are bad for maintenance
my_target_expression = gb_obj << get script();Re: Espressione di Taylor Graph BuilderCiao Jim,
grazie, funziona anche usando eval/evalexpr.
Ma la mia domanda era, come potevo costruire quel gb_expr completo nella parte superiore,
il mio colpo di scena è stato questo:
Substitute Into( gb_expr, Expr( Y( :height ) ), Expr( Y( :height ), Y( :weight ) ) );
non ha funzionato.
Quindi voglio sostituire molti "Y(:c1), Y(:c2) ..." nell'espressione del Graph Builder utilizzando la manipolazione dell'espressione (non la manipolazione della stringa).
Distinti saluti,
Re: Espressione Taylor Graph BuilderNon so come aggirare il problema del sostituto. Potresti voler esplorare i messaggi di Scripting Index Graph Builder che possono essere passati a Graph Builder

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
Variables( X( :sex ) ),
Elements( Points( X, Y ), Smoother( X, Y ) )
);
gb << Add Variable( {:height, Role( "Y" )} );
gb << Add Variable( {:weight, Role( "Y" )} );Re: Espressione di Taylor Graph Builder@Georg
Seguendo il suggerimento di @txnelson sull'invio di messaggi al generatore di grafici, questo potrebbe aiutarti ad avvicinarti a ciò che stai cercando:
Names Default To Here( 1 );
cdt = Open( "$SAMPLE_DATA/Big Class.jmp" );
col_lst = cdt << get column names( Continuous, "String" );
gb = Graph Builder(
Variables( X( :age ) ),
Elements( Points( X, Y ) )
);
for each( { yCol }, col_lst,
gb << Add Variable( { eval( yCol ), Role( "Y" ) } );
);
Lo script risultante per la creazione di grafici è:
Graph Builder(<BR />Variables( X( :age ), Y( :height ), Y( :weight ) ),<BR />Elements( Position( 1, 1 ), Points( X, Y, Legend( 1 ) ) ),<BR />Elements( Position( 1, 2 ), Points( X, Y, Legend( 2 ) ) )<BR />);
Re: Espressione Taylor Graph BuilderGrazie a tutti, sembra buono!
Re: Espressione Taylor Graph BuilderDi solito non uso sostituti per questo, ma piuttosto li costruisco usando espressioni, di seguito è riportata un'opzione, ma ce ne sono altre.
Names Default To Here(1);
dt = Open("$SAMPLE_DATA\Big Class.jmp");
col_lst = cdt << get column names(Continuous, "String");
var_expr = Expr(Variables(X(:age)));
For Each({colname}, col_lst,
colname = "height";
Insert Into(var_expr, EvalExpr(Y(Expr(Name Expr(As Column(dt, colname))))));
);
gb_expr = EvalExpr(
dt << Graph Builder(
Size(534, 450),
Show Control Panel(0),
Expr(Name Expr(var_expr))
);
);
gb = Eval(gb_expr);
// gb << get script
gb << Save Script to Data Table("Plot");
Se vuoi usare solo Substitute, penso che dovrai sostituire l'intera parte Variables (o eventualmente usare qualche trucco)
Names Default To Here(1);
cdt = Open("$SAMPLE_DATA\Big Class.jmp");
col_lst = cdt << get column names(Continuous, "String");
gb_expr = Expr(
cdt << Graph Builder(
Size(534, 450),
Show Control Panel(0),
Variables(X(:age), Y(:height)),
Elements(Position(1, 1), Points(X, Y, Legend(4))),
Elements(Position(1, 2), Points(X, Y, Legend(5)))
)
);
Substitute Into(gb_expr, Expr(Variables(X(:age), Y(:height))), Expr(Variables(X(:age), Y(:height), Y(:weight))));
show(gb_expr);