Ci sono già alcune opzioni su come farlo (ma l'indice delle espressioni potrebbe essere utile). Come ho già detto nella voce della lista dei desideri ( Indicizzazione delle espressioni: aiutami a scalare l'albero delle espressioni - Comunità degli utenti JMP ), JMP dispone di Extract Expr() che utilizza Wild() e Wild List()
Names Default To Here(1);
myExpr = Expr(
gb = dt << Graph Builder(
Size(437, 413),
Graph Spacing(4),
Variables(X(:height), Y(:weight), Overlay(:sex)),
Elements(Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2)))
)
);
yexpr = Extract Expr(myExpr, Y(Wild()));
variables_expr = Extract Expr(myExpr, Variables(Wild List()));
Names Default To Here(1);
myExpr = Expr(
gb = dt << Graph Builder(
Size(437, 413),
Graph Spacing(4),
Variables(X(:height), Y(:weight), Y(:height), Overlay(:sex)),
Elements(Points(X, Y, Legend(1)), Smoother(X, Y, Legend(2)))
)
);
variables_expr = Extract Expr(myExpr, Variables(Wild List()));
idx = 0;
For(i = 1, i <= N Arg(variables_expr), i++,
firstlevel = Arg(variables_expr, i); // could use Extract Expr
If(Head(firstlevel) == Expr(Y) & idx == 2,
secondlevel = Arg(firstlevel, 1);
);
);
show(secondlevel);
Ci sono anche altre cose che puoi fare (ma non sono sicuro se dovresti)
Names Default To Here(1);
myExpr = Expr(
Variables(X(:height), Y(:weight), Y(:height), Overlay(:sex))
);
listconversion = Substitute(Name Expr(myExpr), Expr(Variables()), Expr(List()));
yexprs = {};
While(yexpr = Contains(listconversion, Extract Expr(listconversion, Y(Wild()))),
Insert Into(yexprs, Remove From(listconversion, yexpr));
);
show(yexprs);
yexprs[2];
Potrebbero esserci altre cose strane che potresti fare con le liste...
Espressioni, macro ed elenchi avanzati (jmp.com) può essere una buona lettura
Questo post è nato come una voce di una lista dei desideri, ma a quanto pare il desiderio è già in parte realizzabile (vedi la risposta di @jthi qui sotto).
Quindi l'ho spostato qui per rendere i risultati più visibili.
Il desiderio originale, che richiede una funzionalità che vada oltre ciò che è già possibile, può essere trovato qui:
Indicizzazione delle espressioni: accesso in lettura e scrittura
Dai un'occhiata e decidi se può essere utile anche a te...
_____________________________________________
In molti linguaggi di programmazione, è possibile indicizzare liste e matrici. Ciò è possibile anche in Jmp:
list= {"A", "B", "C"};
mat=[1,2,3];
list[3]
mat[2]
Con Jmp 13, un altro livello di indicizzazione è diventato possibile: l'indicizzazione delle tabelle dati
Oggigiorno l'utente può facilmente indicizzare le voci nella tabella dati con accesso in lettura e scrittura.
Esiste un terzo tipo di indicizzazione: indicizzazione ad albero di visualizzazione
Per un dato report, è possibile scorrere l'albero di visualizzazione per identificare un oggetto specifico:
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = dt << Graph Builder(
Size( 437, 413 ),
Graph Spacing( 4 ),
Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
)
Report(gb)["Graph Builder"][AxisBox(1)]
Forse ci sono più punti in Jmp in cui l'indicizzazione aiuta l'utente nel suo lavoro quotidiano...
Per le espressioni è molto più complicato procedere lungo l'albero:
Per ottenere la variabile Y :weight da
myExpr=Expr(gb = dt << Graph Builder(
Size( 437, 413 ),
Graph Spacing( 4 ),
Variables( X( :height ), Y( :weight ), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
));
bisogna usare
Arg(Arg(Arg(Arg(Arg(myExpr,2),2),3),2),1) // :weight
molto fragile!!!!
Una soluzione alternativa: convertire l'espressione delle variabili in un elenco e utilizzare l'indicizzazione dell'elenco :
myExpr=Expr(Variables( X( :height ), Y( :weight ), Overlay( :sex ) ))
Substitute(Name Expr(myExpr),Expr(Variables()),Expr(List()))["Y"];
ma ci sono diversi svantaggi:
- funziona solo per un singolo livello - gerarchia piatta
- just the first named argument is found, further named arguments with the same identifier are ignored:
myExpr=Expr(Variables( X( :height ), Y( :weight ),Y(:height ), Overlay( :sex ) ));
Substitute(Name Expr(myExpr),Expr(Variables()),Expr(List()))["Y"]; // returns :weight, ignores Y(:height)
- just returns the first argument, further arguments get lost
myExpr = Expr(Distribution(columns(:height, :weight)));
Substitute(Name Expr(myExpr),Expr(Distribution()),Expr(List()))["columns"];
//returns :height -> :weight gets lost
Esiste la possibilità, analogamente all'indicizzazione dell'albero di visualizzazione, di scalare un albero di espressione?
invece di
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
myExpr=Expr(gb = dt << Graph Builder(
Size( 437, 413 ),
Graph Spacing( 4 ),
Variables( X( :height ), Y( :weight ), Y(:height), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
));
//instead of:
Arg(Arg(Arg(Arg(Arg(myExpr,2),2),3),3),1)
Voglio usare
myExpr[2][2["Variables"]["Y"(2)][1]
Grazie, @jthi. Extract Expr() è molto utile per arrivare al livello corretto dell'albero.
Mi è stato di grande aiuto l'anno scorso : )
Ho appena notato che l'elaborazione degli argomenti all'interno di un livello può essere eseguita molto più facilmente:
Per ogni , Trasforma ogni e Filtra ogni possono essere usati con le espressioni. Fantastico!

Main Script = Expr(dt << Graph Builder(
Size( 437, 413 ),
Graph Spacing( 4 ),
Variables( X( :height ), Y( :weight ), Y (:sex), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 1 ) ), Smoother( X, Y, Legend( 2 ) ) )
));
snippet = Extract Expr(Main Script, Variables(Wild List()))
For each({variable}, Name Expr(snippet), Show(Head(variable), Arg(variable)))
selection = Filter Each ({code}, Name Expr(snippet), Head(code)==Expr(Y()));
Show(selection)
changed= Transform Each ({code}, Name Expr(snippet), If (Head(code)==Expr(X()), Expr(my changed code),Name Expr(code)))
Show(changed);