こんにちは、みんな、
以下に、意図したとおりに動作するコードがあります。しかし、問題は、コードの繰り返しによって、理論上は for ループによる置換によってコード行数を節約できるはずのコードが 500 行と不必要に長くなることです。
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 );私は今、jmp 式の置換に関する知識を活用してこの for ループを作成しようとしており、ログでデータ テーブルが適切にサブセット化されていることを確認できますが、上記のコードのように問題なく V リスト ボックスをウィンドウに追加できません。上記のように for ループを機能させるための支援があれば、大変助かります。ありがとうございます!
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]
);
);
);Eval(Substitute(Expr))) 処理で Eval() 関数を省略しました
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]
)
)
);
);