Salut tout le monde,
J'ai un morceau de code qui fonctionne comme prévu ci-dessous. Mais le problème est que la répétition du code génère 500 lignes de code inutilement longues alors qu'une boucle for via substitution devrait en théorie pouvoir fonctionner pour enregistrer des lignes de code.
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 );J'ai maintenant essayé d'utiliser ma compréhension de la substitution jmp des expressions pour créer cette boucle for et je peux voir dans le journal que les tables de données sont correctement sous-ensembles, mais je ne parviens pas à ajouter la zone de liste V à la fenêtre car le code ci-dessus est pouvoir le faire sans aucun problème. Toute aide pour faire fonctionner la boucle for comme ci-dessus serait grandement appréciée. Merci!
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]
);
);
);Vous avez omis la fonction Eval() dans le traitement 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]
)
)
);
);