CIAO,
Voglio scrivere uno script con ciclo for per generare box plot con linee di riferimento orizzontali e salvarlo. Posso farlo anche nel generatore di grafici, ma il mio set di dati è enorme, quindi l'aggiunta manuale della linea di riferimento richiederebbe troppo tempo.
Devo due tabelle dati una per generare la tabella dati e l'altra per generare linee di riferimento.
Voglio avere un loop su Box plot Player (in questo caso 'a' e 'b) sull'asse X e la colonna cambierebbe per tutti i giochi ('Badminton', 'Table Tennis', 'Lawn Tennis'). Lo script JMP legge anche un altro file che contiene la linea di riferimento e sovrappone le linee di riferimento di un particolare gioco a quella particolare trama.
Si prega di aiutare a scrivere uno script per questo requisito.
Grazie 
| Gioco | Riga di riferimento 1 | Riga di riferimento 2 |
| Badminton | 7 | 1 |
| Ping Pong | 8 | 2 |
| Tennis sull'erba | 6 | 3 |
| Giocatore | Zona | Badminton | Ping Pong | Tennis sull'erba |
| UN | Nord | 2 | 2 | 3 |
| UN | Nord | 3 | 6 | 3 |
| UN | Nord | 4 | 6 | 5 |
| UN | Nord | 5 | 2 | 2 |
| UN | Nord | 2 | 5 | 6 |
| UN | Nord | 4 | 5 | 6 |
| UN | Nord | 4 | 3 | 6 |
| UN | Nord | 4 | 5 | 2 |
| UN | Nord | 9 | 7 | 6 |
| UN | Nord | 5 | 0 | 5 |
| B | Sud | 1 | 3 | 7 |
| B | Sud | 2 | 4 | 7 |
| B | Sud | 4 | 7 | 8 |
| B | Sud | 3 | 6 | 3 |
| B | Sud | 6 | 4 | 5 |
| B | Sud | 2 | 2 | 2 |
| B | Sud | 5 | 8 | 6 |
| B | Sud | 6 | 5 | 2 |
| B | Sud | 7 | 2 | 3 |
| B | Sud | 6 | 4 | 6 |
Quindi dovrebbe essere utilizzato un approccio diverso.I limiti di risposta supportano solo Inferiore, Medio e Superiore.
Ecco un semplice script che funziona con le tabelle di dati che hai fornito, che traccerà tutte le linee di riferimento
Names Default To Here( 1 );
dtMain = Data Table( "Main" );
dtLimits = Data Table( "Limits" );
// Get the columns to create box plots for
boxPlotList = dtMain << get column names( string, numeric );
// Get the columns that contain limits
refLineList = dtLimits << get column names( string, numeric );
// Loop across the box plot columns and generate the box plots
For( i = 1, i <= N Items( boxPlotList ), i++,
ow = Oneway( Y( Column( boxPlotList[i] ) ), X( :Player ), Box Plots( 1 ) );
// Find out if any reference line references are specified for the current
// box plot column
refLineMatrix = dtLimits << get rows where( :game == boxPlotList[i] );
// If references are found, then loop across the columns and rows in the Limits table
// and add the reference lines
If( N Rows( refLineMatrix ) > 0,
For( refRow = 1, refRow <= N Rows( refLineMatrix ), refRow++,
For( refCol = 1, refCol <= N Items( refLineList ), refCol++,
refLineValue = Column( dtLimits, refLineList[refCol] )[refRow];
Report( ow )[AxisBox( 1 )] << Add Ref Line( refLineValue, "Solid", "Black", "", 1 );
)
)
);
);Ecco uno script che crea prima le 2 tabelle di dati che hai visualizzato nella tua prima voce, seguito dal codice che copia i limiti dalla tabella dei limiti e li applica a ciascuna colonna nella tabella principale
Names Default To Here( 1 );
dtMain = New Table( "Main",
Add Rows( 20 ),
New Column( "Player",
Character,
"Nominal",
Set Values(
{"a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "b", "b", "b", "b", "b", "b"}
)
),
New Column( "Zone",
Character,
"Nominal",
Set Values(
{"North", "North", "North", "North", "North", "North", "North", "North", "North", "North", "South",
"South", "South", "South", "South", "South", "South", "South", "South", "South"}
)
),
New Column( "Badminton",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [2, 3, 4, 5, 2, 4, 4, 4, 9, 5, 1, 2, 4, 3, 6, 2, 5, 6, 7, 6] )
),
New Column( "Table Tennis",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [2, 6, 6, 2, 5, 5, 3, 5, 7, 0, 3, 4, 7, 6, 4, 2, 8, 5, 2, 4] )
),
New Column( "Lawn Tennis",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [3, 3, 5, 2, 6, 6, 6, 2, 6, 5, 7, 7, 8, 3, 5, 2, 6, 2, 3, 6] )
)
);
dtLimits = New Table( "Limits",
Add Rows( 3 ),
New Column( "Game",
Character,
"Nominal",
Set Values( {"Badminton", "Table Tennis", "Lawn Tennis"} ),
Set Display Width( 128 )
),
New Column( "Reference Line 1", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [7, 8, 6] ) ),
New Column( "Reference Line 2", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1, 2, 3] ) )
);
// Here is the code that sets the Response Limits
For( i = 1, i <= N Rows( dtLimits ), i++,
If( Try( (Column( dtMain, (Column( dtLimits, "Game" )[i]) )) << get name, "" ) != "",
Eval(
Substitute(
Expr(
Column( dtMain, Column( dtLimits, "Game" )[i] ) << set property(
"response limits",
{Goal( Maximize ), Lower( __Low__, 1 ), Upper( __up__, 1 ), Importance( 1 ),
Show Limits( 1 )}
)
),
Expr( __Low__ ), dtLimits:Reference Line 2[i],
Expr( __Up__ ),
dtLimits:Reference Line 1[i]
)
)
)
);