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 aggiungere manualmente la linea di riferimento richiederebbe troppo tempo.
Devo creare due tabelle dati, una per generare una tabella dati e l'altra per generare linee di riferimento.
Voglio avere un ciclo per il Box plot Player (in questo caso "a" e "b) sull'asse X e la colonna cambierebbe per tutti i giochi ("Badminton", "Tennis da tavolo", "Tennis su prato"). Lo script JMP leggerebbe anche un altro file che contiene la linea di riferimento e sovrapporrebbe le linee di riferimento di un particolare gioco a quella particolare trama.
Per favore aiutaci a scrivere uno script per questo requisito.
Grazie 
| Gioco | Linea di riferimento 1 | Linea di riferimento 2 |
| Badminton | 7 | 1 |
| Ping-pong | 8 | 2 |
| Tennis sull'erba | 6 | 3 |
| Giocatore | Zona | Badminton | Ping-pong | Tennis sull'erba |
| a | Nord | 2 | 2 | 3 |
| a | Nord | 3 | 6 | 3 |
| a | Nord | 4 | 6 | 5 |
| a | Nord | 5 | 2 | 2 |
| a | Nord | 2 | 5 | 6 |
| a | Nord | 4 | 5 | 6 |
| a | Nord | 4 | 3 | 6 |
| a | Nord | 4 | 5 | 2 |
| a | Nord | 9 | 7 | 6 |
| a | 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 |
Allora si dovrebbe utilizzare un approccio diverso. I limiti di risposta supportano solo Inferiore, Medio e Superiore.
Ecco un semplice script che funziona con le tabelle di dati fornite e 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 visualizzate nella prima voce, seguite 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]
)
)
)
);