Ciao a tutti,
Ho un pezzo di codice che funziona come previsto di seguito. Ma il problema è che la ripetizione del codice rende inutilmente lunghe 500 righe di codice in cui una sostituzione del ciclo for in teoria dovrebbe essere in grado di funzionare per salvare righe di codice.
old win = New Window( "Old Win", vlis old = V List Box() );
df movies = Open("C:\Program Files\JMP\JMP\18\Samples\Data\Movies.jmp");
df action = df movies << Subset( Columns(), Rows(), Output Table Name( "df action" ));
Column( df action, "Rating" ) << Set Property( "Value Colors", {"R" = 0} );
color_or_not = 1;
df action << Select Where(
Or(
!Contains( :Type, "Action" ),
Contains( :Rating, "13" )
)
) << Exclude;
df action << Delete Rows;
action lbx = V List Box(
If(color_or_not == 1,
vc action = df action << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for Action" ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( 1999, "Dotted", "Medium Light Green", "1999", 1 )}
),
Dispatch(
{""},
"Variability Chart",
FrameBox,
{Row Legend(
Rating,
Color( 1 ),
Color Theme( "" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
);
);
);
,
vc action = df action << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for Action" ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( 1999, "Dotted", "Medium Light Green", "1999", 1 )}
);
);
);
);
);
vlis old << Append( action lbx );
df comedy = df movies << Subset( Columns(), Rows(), Output Table Name( "df comedy" ));
Column( df comedy, "Rating" ) << Set Property( "Value Colors", {"R" = 0} );
df comedy << Select Where(
Or(
!Contains( :Type, "Comedy" ),
Contains( :Rating, "13" )
)
) << Exclude;
df comedy << Delete Rows;
comedy lbx = V List Box(
If(color_or_not == 1,
vc comedy = df comedy << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for Comedy" ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( 2000, "Dotted", "Medium Light Green", "2000", 1 )}
),
Dispatch(
{""},
"Variability Chart",
FrameBox,
{Row Legend(
Rating,
Color( 1 ),
Color Theme( "" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
);
);
);
,
vc comedy = df comedy << Variability Chart(
Y( :Movie ),
X( :Year ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for Comedy" ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( 2000, "Dotted", "Medium Light Green", "2000", 1 )}
);
);
);
);
);
vlis old << Append( comedy lbx );
df family = df movies << Subset( Columns(), Rows(), Output Table Name( "df family" ));
Column( df family, "Rating" ) << Set Property( "Value Colors", {"R" = 0} );
df family << Select Where(
Or(
!Contains( :Type, "Family" ),
Contains( :Rating, "13" )
)
) << Exclude;
df family << Delete Rows;
family lbx = V List Box(
If(color_or_not == 1,
vc family = df family << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for Family" ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( 1995, "Dotted", "Medium Light Green", "1995", 1 )}
),
Dispatch(
{""},
"Variability Chart",
FrameBox,
{Row Legend(
Rating,
Color( 1 ),
Color Theme( "" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
);
);
);
,
vc family = df family << Variability Chart(
Y( :Movie ),
X( :Year ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for Family" ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( 2000, "Dotted", "Medium Light Green", "2000", 1 )}
);
);
);
);
);
vlis old << Append( family lbx );Ora ho provato a utilizzare la mia comprensione della sostituzione jmp delle espressioni per creare questo ciclo for e posso vedere nel registro che le tabelle di dati sono correttamente sottoinsiemi ma non sono in grado di aggiungere la casella di riepilogo V alla finestra poiché il codice sopra è in grado di fare a meno di qualsiasi problema. Qualsiasi aiuto per far funzionare il ciclo for come sopra sarebbe molto apprezzato. Grazie!
Clear Globals();
Clear Log();
df movie = Open("C:\Program Files\JMP\JMP\18\Samples\Data\Movies.jmp");
color_or_not = 1;
df action = df movie << Subset( Columns(), Rows(), Output Table Name( "df action" ), Invisible );
df comedy = df movie << Subset( Columns(), Rows(), Output Table Name( "df comedy" ), Invisible );
df family = df movie << Subset( Columns(), Rows(), Output Table Name( "df family" ), Invisible );
new win = New Window( "New Win", vlis = V List Box() );
df list = {df action, df comedy, df family};
to remove one = {"Action", "Comedy", "Family"};
to remove two = {"13", "13", "13"};
names = {"Action", "Comedy", "Family"};
ref val = {1999, 2000, 1995};
ref line = {"1999", "2000", "1995"};
for (i = 1, i<=3, i++,
Eval(
Substitute(
Expr(
Column( _df list_ , "Rating" ) << Set Property( "Value Colors", {"R" = 0} );
_df list_ << Select Where(
Or(
!Contains( :"Type", _to remove one_ ),
Contains( :"Rating", _to remove two_ )
)
) << Exclude;
_df list_ << Delete Rows;
),
Expr( _df list_ ), df list[i],
Expr( _to remove one_ ), to remove one[i],
Expr( _to remove two_ ), to remove two[i],
);
);
If(color_or_not == 1,
Substitute(
Expr(
graph = V List Box(
vc = _df list_ << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for " || _names_ ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( _ref val_ , "Dotted", "Medium Light Green", _ref line_ , 1 )}
),
Dispatch(
{""},
"Variability Chart",
FrameBox,
{Row Legend(
Rating,
Color( 1 ),
Color Theme( "" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
);
);
);
);
vlis << Append( graph );
),
Expr( _df list_ ), df list[i],
Expr( _names_ ), names[i],
Expr( _ref val_ ), ref val[i],
Expr( _ref line_ ), ref line[i]
);
,
Substitute(
Expr(
graph = V List Box(
vc = _df list_ << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for " || _names_ ),
SendToReport(
Dispatch(
{"Variability Chart for Signal"},
"2",
ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line( _ref val_ , "Dotted", "Medium Light Green", _ref line_ , 1 )}
);
);
);
);
vlis << Append( graph );
),
Expr( _df list_ ), df list[i],
Expr( _names_ ), names[i],
Expr( _ref val_ ), ref val[i],
Expr( _ref line_ ), ref line[i]
);
);
);Hai omesso la funzione Eval() nell'elaborazione Eval(Substitute(Expr))).
Names Default To Here( 1 );
Clear Globals();
Clear Log();
df movie = Open( "$SAMPLE_DATA\Movies.jmp" );
color_or_not = 1;
df action = df movie << Subset( Columns(), Rows(), Output Table Name( "df action" ), Invisible );
df comedy = df movie << Subset( Columns(), Rows(), Output Table Name( "df comedy" ), Invisible );
df family = df movie << Subset( Columns(), Rows(), Output Table Name( "df family" ), Invisible );
new win = New Window( "New Win", vlis = V List Box() );
df list = {df action, df comedy, df family};
to remove one = {"Action", "Comedy", "Family"};
to remove two = {"13", "13", "13"};
names = {"Action", "Comedy", "Family"};
ref val = {1999, 2000, 1995};
ref line = {"1999", "2000", "1995"};
For( i = 1, i <= 3, i++,
Eval(
Substitute(
Expr(
Column( _df list_, "Rating" ) << Set Property( "Value Colors", {"R" = 0} );
_df list_ << Select Where(
Or( !Contains( :"Type", _to remove one_ ), Contains( :"Rating", _to remove two_ ) )
) << Exclude;
_df list_ << Delete Rows;
),
Expr( _df list_ ), df list[i],
Expr( _to remove one_ ), to remove one[i],
Expr( _to remove two_ ), to remove two[i],
)
);
If( color_or_not == 1,
Eval(
Substitute(
Expr(
graph = V List Box(
vc = _df list_ << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for " || _names_ ),
SendToReport(
Dispatch( {"Variability Chart for Year"}, "2", ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line(
_ref val_, "Dotted", "Medium Light Green", _ref line_, 1
)}
),
Dispatch( {""}, "Variability Chart", FrameBox,
{Row Legend(
Rating,
Color( 1 ),
Color Theme( "" ),
Marker( 0 ),
Marker Theme( "" ),
Continuous Scale( 0 ),
Reverse Scale( 0 ),
Excluded Rows( 0 )
)}
)
)
)
);
Show( "at vlis" );
vlis << Append( graph );
),
Expr( _df list_ ), df list[i],
Expr( _names_ ), names[i],
Expr( _ref val_ ), ref val[i],
Expr( _ref line_ ), ref line[i]
)
)
,
Eval(
Substitute(
Expr(
graph = V List Box(
vc = _df list_ << Variability Chart(
Y( :Year ),
X( :Movie ),
Show Range Bars( 0 ),
Show Cell Means( 0 ),
Std Dev Chart( 0 ),
Points Jittered( 1 ),
Title( "Variability chart for " || _names_ ),
SendToReport(
Dispatch( {"Variability Chart for Year"}, "2", ScaleBox,
{Min( -50 ), Add Ref Line( 0, "Dotted", "Medium Light Gray", "", 1 ),
Add Ref Line(
_ref val_, "Dotted", "Medium Light Green", _ref line_, 1
)}
)
)
)
);
vlis << Append( graph );
),
Expr( _df list_ ), df list[i],
Expr( _names_ ), names[i],
Expr( _ref val_ ), ref val[i],
Expr( _ref line_ ), ref line[i]
)
)
);
);